babylon.d.ts 2.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174
  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. let Epsilon: number;
  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 Color3 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. * Adds the translation vector (using 3 floats) in the current matrix
  2943. * @param x defines the 1st component of the translation
  2944. * @param y defines the 2nd component of the translation
  2945. * @param z defines the 3rd component of the translation
  2946. * @returns the current updated matrix
  2947. */
  2948. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2949. /**
  2950. * Inserts the translation vector in the current matrix
  2951. * @param vector3 defines the translation to insert
  2952. * @returns the current updated matrix
  2953. */
  2954. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2955. /**
  2956. * Gets the translation value of the current matrix
  2957. * @returns a new Vector3 as the extracted translation from the matrix
  2958. */
  2959. getTranslation(): Vector3;
  2960. /**
  2961. * Fill a Vector3 with the extracted translation from the matrix
  2962. * @param result defines the Vector3 where to store the translation
  2963. * @returns the current matrix
  2964. */
  2965. getTranslationToRef(result: Vector3): Matrix;
  2966. /**
  2967. * Remove rotation and scaling part from the matrix
  2968. * @returns the updated matrix
  2969. */
  2970. removeRotationAndScaling(): Matrix;
  2971. /**
  2972. * Multiply two matrices
  2973. * @param other defines the second operand
  2974. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2975. */
  2976. multiply(other: DeepImmutable<Matrix>): Matrix;
  2977. /**
  2978. * Copy the current matrix from the given one
  2979. * @param other defines the source matrix
  2980. * @returns the current updated matrix
  2981. */
  2982. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2983. /**
  2984. * Populates the given array from the starting index with the current matrix values
  2985. * @param array defines the target array
  2986. * @param offset defines the offset in the target array where to start storing values
  2987. * @returns the current matrix
  2988. */
  2989. copyToArray(array: Float32Array, offset?: number): Matrix;
  2990. /**
  2991. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the matrix where to store the multiplication
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2997. /**
  2998. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2999. * @param other defines the second operand
  3000. * @param result defines the array where to store the multiplication
  3001. * @param offset defines the offset in the target array where to start storing values
  3002. * @returns the current matrix
  3003. */
  3004. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3005. /**
  3006. * Check equality between this matrix and a second one
  3007. * @param value defines the second matrix to compare
  3008. * @returns true is the current matrix and the given one values are strictly equal
  3009. */
  3010. equals(value: DeepImmutable<Matrix>): boolean;
  3011. /**
  3012. * Clone the current matrix
  3013. * @returns a new matrix from the current matrix
  3014. */
  3015. clone(): Matrix;
  3016. /**
  3017. * Returns the name of the current matrix class
  3018. * @returns the string "Matrix"
  3019. */
  3020. getClassName(): string;
  3021. /**
  3022. * Gets the hash code of the current matrix
  3023. * @returns the hash code
  3024. */
  3025. getHashCode(): number;
  3026. /**
  3027. * Decomposes the current Matrix into a translation, rotation and scaling components
  3028. * @param scale defines the scale vector3 given as a reference to update
  3029. * @param rotation defines the rotation quaternion given as a reference to update
  3030. * @param translation defines the translation vector3 given as a reference to update
  3031. * @returns true if operation was successful
  3032. */
  3033. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3034. /**
  3035. * Gets specific row of the matrix
  3036. * @param index defines the number of the row to get
  3037. * @returns the index-th row of the current matrix as a new Vector4
  3038. */
  3039. getRow(index: number): Nullable<Vector4>;
  3040. /**
  3041. * Sets the index-th row of the current matrix to the vector4 values
  3042. * @param index defines the number of the row to set
  3043. * @param row defines the target vector4
  3044. * @returns the updated current matrix
  3045. */
  3046. setRow(index: number, row: Vector4): Matrix;
  3047. /**
  3048. * Compute the transpose of the matrix
  3049. * @returns the new transposed matrix
  3050. */
  3051. transpose(): Matrix;
  3052. /**
  3053. * Compute the transpose of the matrix and store it in a given matrix
  3054. * @param result defines the target matrix
  3055. * @returns the current matrix
  3056. */
  3057. transposeToRef(result: Matrix): Matrix;
  3058. /**
  3059. * Sets the index-th row of the current matrix with the given 4 x float values
  3060. * @param index defines the row index
  3061. * @param x defines the x component to set
  3062. * @param y defines the y component to set
  3063. * @param z defines the z component to set
  3064. * @param w defines the w component to set
  3065. * @returns the updated current matrix
  3066. */
  3067. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3068. /**
  3069. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3070. * @param scale defines the scale factor
  3071. * @returns a new matrix
  3072. */
  3073. scale(scale: number): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor to a given result matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Scale the current matrix values by a factor and add the result to a given matrix
  3083. * @param scale defines the scale factor
  3084. * @param result defines the Matrix to store the result
  3085. * @returns the current matrix
  3086. */
  3087. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3088. /**
  3089. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3090. * @param ref matrix to store the result
  3091. */
  3092. toNormalMatrix(ref: Matrix): void;
  3093. /**
  3094. * Gets only rotation part of the current matrix
  3095. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3096. */
  3097. getRotationMatrix(): Matrix;
  3098. /**
  3099. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3100. * @param result defines the target matrix to store data to
  3101. * @returns the current matrix
  3102. */
  3103. getRotationMatrixToRef(result: Matrix): Matrix;
  3104. /**
  3105. * Toggles model matrix from being right handed to left handed in place and vice versa
  3106. */
  3107. toggleModelMatrixHandInPlace(): void;
  3108. /**
  3109. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3110. */
  3111. toggleProjectionMatrixHandInPlace(): void;
  3112. /**
  3113. * Creates a matrix from an array
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @returns a new Matrix set from the starting index of the given array
  3117. */
  3118. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3119. /**
  3120. * Copy the content of an array into a given matrix
  3121. * @param array defines the source array
  3122. * @param offset defines an offset in the source array
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3126. /**
  3127. * Stores an array into a matrix after having multiplied each component by a given factor
  3128. * @param array defines the source array
  3129. * @param offset defines the offset in the source array
  3130. * @param scale defines the scaling factor
  3131. * @param result defines the target matrix
  3132. */
  3133. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3134. /**
  3135. * Gets an identity matrix that must not be updated
  3136. */
  3137. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3138. /**
  3139. * Stores a list of values (16) inside a given matrix
  3140. * @param initialM11 defines 1st value of 1st row
  3141. * @param initialM12 defines 2nd value of 1st row
  3142. * @param initialM13 defines 3rd value of 1st row
  3143. * @param initialM14 defines 4th value of 1st row
  3144. * @param initialM21 defines 1st value of 2nd row
  3145. * @param initialM22 defines 2nd value of 2nd row
  3146. * @param initialM23 defines 3rd value of 2nd row
  3147. * @param initialM24 defines 4th value of 2nd row
  3148. * @param initialM31 defines 1st value of 3rd row
  3149. * @param initialM32 defines 2nd value of 3rd row
  3150. * @param initialM33 defines 3rd value of 3rd row
  3151. * @param initialM34 defines 4th value of 3rd row
  3152. * @param initialM41 defines 1st value of 4th row
  3153. * @param initialM42 defines 2nd value of 4th row
  3154. * @param initialM43 defines 3rd value of 4th row
  3155. * @param initialM44 defines 4th value of 4th row
  3156. * @param result defines the target matrix
  3157. */
  3158. 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;
  3159. /**
  3160. * Creates new matrix from a list of values (16)
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @returns the new matrix
  3178. */
  3179. 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;
  3180. /**
  3181. * Creates a new matrix 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. * @returns a new matrix
  3186. */
  3187. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3188. /**
  3189. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3190. * @param scale defines the scale vector3
  3191. * @param rotation defines the rotation quaternion
  3192. * @param translation defines the translation vector3
  3193. * @param result defines the target matrix
  3194. */
  3195. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3196. /**
  3197. * Creates a new identity matrix
  3198. * @returns a new identity matrix
  3199. */
  3200. static Identity(): Matrix;
  3201. /**
  3202. * Creates a new identity matrix and stores the result in a given matrix
  3203. * @param result defines the target matrix
  3204. */
  3205. static IdentityToRef(result: Matrix): void;
  3206. /**
  3207. * Creates a new zero matrix
  3208. * @returns a new zero matrix
  3209. */
  3210. static Zero(): Matrix;
  3211. /**
  3212. * Creates a new rotation matrix for "angle" radians around the X axis
  3213. * @param angle defines the angle (in radians) to use
  3214. * @return the new matrix
  3215. */
  3216. static RotationX(angle: number): Matrix;
  3217. /**
  3218. * Creates a new matrix as the invert of a given matrix
  3219. * @param source defines the source matrix
  3220. * @returns the new matrix
  3221. */
  3222. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3223. /**
  3224. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3225. * @param angle defines the angle (in radians) to use
  3226. * @param result defines the target matrix
  3227. */
  3228. static RotationXToRef(angle: number, result: Matrix): void;
  3229. /**
  3230. * Creates a new rotation matrix for "angle" radians around the Y axis
  3231. * @param angle defines the angle (in radians) to use
  3232. * @return the new matrix
  3233. */
  3234. static RotationY(angle: number): Matrix;
  3235. /**
  3236. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3237. * @param angle defines the angle (in radians) to use
  3238. * @param result defines the target matrix
  3239. */
  3240. static RotationYToRef(angle: number, result: Matrix): void;
  3241. /**
  3242. * Creates a new rotation matrix for "angle" radians around the Z axis
  3243. * @param angle defines the angle (in radians) to use
  3244. * @return the new matrix
  3245. */
  3246. static RotationZ(angle: number): Matrix;
  3247. /**
  3248. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3249. * @param angle defines the angle (in radians) to use
  3250. * @param result defines the target matrix
  3251. */
  3252. static RotationZToRef(angle: number, result: Matrix): void;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3262. * @param axis defines the axis to use
  3263. * @param angle defines the angle (in radians) to use
  3264. * @param result defines the target matrix
  3265. */
  3266. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3267. /**
  3268. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3269. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3270. * @param from defines the vector to align
  3271. * @param to defines the vector to align to
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3275. /**
  3276. * Creates a rotation matrix
  3277. * @param yaw defines the yaw angle in radians (Y axis)
  3278. * @param pitch defines the pitch angle in radians (X axis)
  3279. * @param roll defines the roll angle in radians (X axis)
  3280. * @returns the new rotation matrix
  3281. */
  3282. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3283. /**
  3284. * Creates a rotation matrix and stores it in a given matrix
  3285. * @param yaw defines the yaw angle in radians (Y axis)
  3286. * @param pitch defines the pitch angle in radians (X axis)
  3287. * @param roll defines the roll angle in radians (X axis)
  3288. * @param result defines the target matrix
  3289. */
  3290. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3291. /**
  3292. * Creates a scaling matrix
  3293. * @param x defines the scale factor on X axis
  3294. * @param y defines the scale factor on Y axis
  3295. * @param z defines the scale factor on Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Scaling(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a scaling matrix and stores it in a given matrix
  3301. * @param x defines the scale factor on X axis
  3302. * @param y defines the scale factor on Y axis
  3303. * @param z defines the scale factor on Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Creates a translation matrix
  3309. * @param x defines the translation on X axis
  3310. * @param y defines the translation on Y axis
  3311. * @param z defines the translationon Z axis
  3312. * @returns the new matrix
  3313. */
  3314. static Translation(x: number, y: number, z: number): Matrix;
  3315. /**
  3316. * Creates a translation matrix and stores it in a given matrix
  3317. * @param x defines the translation on X axis
  3318. * @param y defines the translation on Y axis
  3319. * @param z defines the translationon Z axis
  3320. * @param result defines the target matrix
  3321. */
  3322. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3323. /**
  3324. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3325. * @param startValue defines the start value
  3326. * @param endValue defines the end value
  3327. * @param gradient defines the gradient factor
  3328. * @returns the new matrix
  3329. */
  3330. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3331. /**
  3332. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3333. * @param startValue defines the start value
  3334. * @param endValue defines the end value
  3335. * @param gradient defines the gradient factor
  3336. * @param result defines the Matrix object where to store data
  3337. */
  3338. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3339. /**
  3340. * Builds a new matrix whose values are computed by:
  3341. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3342. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3343. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3344. * @param startValue defines the first matrix
  3345. * @param endValue defines the second matrix
  3346. * @param gradient defines the gradient between the two matrices
  3347. * @returns the new matrix
  3348. */
  3349. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3350. /**
  3351. * Update a matrix to values which are computed by:
  3352. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3353. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3354. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3355. * @param startValue defines the first matrix
  3356. * @param endValue defines the second matrix
  3357. * @param gradient defines the gradient between the two matrices
  3358. * @param result defines the target matrix
  3359. */
  3360. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3361. /**
  3362. * 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"
  3363. * This function works in left handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * 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".
  3372. * This function works in left handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * 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"
  3381. * This function works in right handed mode
  3382. * @param eye defines the final position of the entity
  3383. * @param target defines where the entity should look at
  3384. * @param up defines the up vector for the entity
  3385. * @returns the new matrix
  3386. */
  3387. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3388. /**
  3389. * 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".
  3390. * This function works in right handed mode
  3391. * @param eye defines the final position of the entity
  3392. * @param target defines where the entity should look at
  3393. * @param up defines the up vector for the entity
  3394. * @param result defines the target matrix
  3395. */
  3396. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param width defines the viewport width
  3400. * @param height defines the viewport height
  3401. * @param znear defines the near clip plane
  3402. * @param zfar defines the far clip plane
  3403. * @returns a new matrix as a left-handed orthographic projection matrix
  3404. */
  3405. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3406. /**
  3407. * Store a left-handed orthographic projection to a given matrix
  3408. * @param width defines the viewport width
  3409. * @param height defines the viewport height
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @param result defines the target matrix
  3413. */
  3414. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3415. /**
  3416. * Create a left-handed orthographic projection matrix
  3417. * @param left defines the viewport left coordinate
  3418. * @param right defines the viewport right coordinate
  3419. * @param bottom defines the viewport bottom coordinate
  3420. * @param top defines the viewport top coordinate
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @returns a new matrix as a left-handed orthographic projection matrix
  3424. */
  3425. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3426. /**
  3427. * Stores a left-handed orthographic projection into a given matrix
  3428. * @param left defines the viewport left coordinate
  3429. * @param right defines the viewport right coordinate
  3430. * @param bottom defines the viewport bottom coordinate
  3431. * @param top defines the viewport top coordinate
  3432. * @param znear defines the near clip plane
  3433. * @param zfar defines the far clip plane
  3434. * @param result defines the target matrix
  3435. */
  3436. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3437. /**
  3438. * Creates a right-handed orthographic projection matrix
  3439. * @param left defines the viewport left coordinate
  3440. * @param right defines the viewport right coordinate
  3441. * @param bottom defines the viewport bottom coordinate
  3442. * @param top defines the viewport top coordinate
  3443. * @param znear defines the near clip plane
  3444. * @param zfar defines the far clip plane
  3445. * @returns a new matrix as a right-handed orthographic projection matrix
  3446. */
  3447. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3448. /**
  3449. * Stores a right-handed orthographic projection into a given matrix
  3450. * @param left defines the viewport left coordinate
  3451. * @param right defines the viewport right coordinate
  3452. * @param bottom defines the viewport bottom coordinate
  3453. * @param top defines the viewport top coordinate
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @param result defines the target matrix
  3457. */
  3458. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3459. /**
  3460. * Creates a left-handed perspective projection matrix
  3461. * @param width defines the viewport width
  3462. * @param height defines the viewport height
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @returns a new matrix as a left-handed perspective projection matrix
  3466. */
  3467. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3468. /**
  3469. * Creates a left-handed perspective projection matrix
  3470. * @param fov defines the horizontal field of view
  3471. * @param aspect defines the aspect ratio
  3472. * @param znear defines the near clip plane
  3473. * @param zfar defines the far clip plane
  3474. * @returns a new matrix as a left-handed perspective projection matrix
  3475. */
  3476. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3477. /**
  3478. * Stores a left-handed perspective projection into a given matrix
  3479. * @param fov defines the horizontal field of view
  3480. * @param aspect defines the aspect ratio
  3481. * @param znear defines the near clip plane
  3482. * @param zfar defines the far clip plane
  3483. * @param result defines the target matrix
  3484. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3485. */
  3486. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3487. /**
  3488. * Creates a right-handed perspective projection matrix
  3489. * @param fov defines the horizontal field of view
  3490. * @param aspect defines the aspect ratio
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @returns a new matrix as a right-handed perspective projection matrix
  3494. */
  3495. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3496. /**
  3497. * Stores a right-handed perspective projection into a given matrix
  3498. * @param fov defines the horizontal field of view
  3499. * @param aspect defines the aspect ratio
  3500. * @param znear defines the near clip plane
  3501. * @param zfar defines the far clip plane
  3502. * @param result defines the target matrix
  3503. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3504. */
  3505. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3506. /**
  3507. * Stores a perspective projection for WebVR info a given matrix
  3508. * @param fov defines the field of view
  3509. * @param znear defines the near clip plane
  3510. * @param zfar defines the far clip plane
  3511. * @param result defines the target matrix
  3512. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3513. */
  3514. static PerspectiveFovWebVRToRef(fov: {
  3515. upDegrees: number;
  3516. downDegrees: number;
  3517. leftDegrees: number;
  3518. rightDegrees: number;
  3519. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3520. /**
  3521. * Computes a complete transformation matrix
  3522. * @param viewport defines the viewport to use
  3523. * @param world defines the world matrix
  3524. * @param view defines the view matrix
  3525. * @param projection defines the projection matrix
  3526. * @param zmin defines the near clip plane
  3527. * @param zmax defines the far clip plane
  3528. * @returns the transformation matrix
  3529. */
  3530. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3531. /**
  3532. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3533. * @param matrix defines the matrix to use
  3534. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3535. */
  3536. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3537. /**
  3538. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3539. * @param matrix defines the matrix to use
  3540. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3541. */
  3542. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3543. /**
  3544. * Compute the transpose of a given matrix
  3545. * @param matrix defines the matrix to transpose
  3546. * @returns the new matrix
  3547. */
  3548. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3549. /**
  3550. * Compute the transpose of a matrix and store it in a target matrix
  3551. * @param matrix defines the matrix to transpose
  3552. * @param result defines the target matrix
  3553. */
  3554. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3555. /**
  3556. * Computes a reflection matrix from a plane
  3557. * @param plane defines the reflection plane
  3558. * @returns a new matrix
  3559. */
  3560. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3561. /**
  3562. * Computes a reflection matrix from a plane
  3563. * @param plane defines the reflection plane
  3564. * @param result defines the target matrix
  3565. */
  3566. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3567. /**
  3568. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3569. * @param xaxis defines the value of the 1st axis
  3570. * @param yaxis defines the value of the 2nd axis
  3571. * @param zaxis defines the value of the 3rd axis
  3572. * @param result defines the target matrix
  3573. */
  3574. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3575. /**
  3576. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3577. * @param quat defines the quaternion to use
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3581. }
  3582. /**
  3583. * Represens a plane by the equation ax + by + cz + d = 0
  3584. */
  3585. export class Plane {
  3586. /**
  3587. * Normal of the plane (a,b,c)
  3588. */
  3589. normal: Vector3;
  3590. /**
  3591. * d component of the plane
  3592. */
  3593. d: number;
  3594. /**
  3595. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3596. * @param a a component of the plane
  3597. * @param b b component of the plane
  3598. * @param c c component of the plane
  3599. * @param d d component of the plane
  3600. */
  3601. constructor(a: number, b: number, c: number, d: number);
  3602. /**
  3603. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3604. */
  3605. asArray(): number[];
  3606. /**
  3607. * @returns a new plane copied from the current Plane.
  3608. */
  3609. clone(): Plane;
  3610. /**
  3611. * @returns the string "Plane".
  3612. */
  3613. getClassName(): string;
  3614. /**
  3615. * @returns the Plane hash code.
  3616. */
  3617. getHashCode(): number;
  3618. /**
  3619. * Normalize the current Plane in place.
  3620. * @returns the updated Plane.
  3621. */
  3622. normalize(): Plane;
  3623. /**
  3624. * Applies a transformation the plane and returns the result
  3625. * @param transformation the transformation matrix to be applied to the plane
  3626. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3627. */
  3628. transform(transformation: DeepImmutable<Matrix>): Plane;
  3629. /**
  3630. * Calcualtte the dot product between the point and the plane normal
  3631. * @param point point to calculate the dot product with
  3632. * @returns the dot product (float) of the point coordinates and the plane normal.
  3633. */
  3634. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3635. /**
  3636. * Updates the current Plane from the plane defined by the three given points.
  3637. * @param point1 one of the points used to contruct the plane
  3638. * @param point2 one of the points used to contruct the plane
  3639. * @param point3 one of the points used to contruct the plane
  3640. * @returns the updated Plane.
  3641. */
  3642. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3643. /**
  3644. * Checks if the plane is facing a given direction
  3645. * @param direction the direction to check if the plane is facing
  3646. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3647. * @returns True is the vector "direction" is the same side than the plane normal.
  3648. */
  3649. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3650. /**
  3651. * Calculates the distance to a point
  3652. * @param point point to calculate distance to
  3653. * @returns the signed distance (float) from the given point to the Plane.
  3654. */
  3655. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Creates a plane from an array
  3658. * @param array the array to create a plane from
  3659. * @returns a new Plane from the given array.
  3660. */
  3661. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3662. /**
  3663. * Creates a plane from three points
  3664. * @param point1 point used to create the plane
  3665. * @param point2 point used to create the plane
  3666. * @param point3 point used to create the plane
  3667. * @returns a new Plane defined by the three given points.
  3668. */
  3669. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3670. /**
  3671. * Creates a plane from an origin point and a normal
  3672. * @param origin origin of the plane to be constructed
  3673. * @param normal normal of the plane to be constructed
  3674. * @returns a new Plane the normal vector to this plane at the given origin point.
  3675. * Note : the vector "normal" is updated because normalized.
  3676. */
  3677. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3678. /**
  3679. * Calculates the distance from a plane and a point
  3680. * @param origin origin of the plane to be constructed
  3681. * @param normal normal of the plane to be constructed
  3682. * @param point point to calculate distance to
  3683. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3684. */
  3685. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3686. }
  3687. /**
  3688. * Class used to represent a viewport on screen
  3689. */
  3690. export class Viewport {
  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 Viewport object located at (x, y) and sized (width, height)
  3701. * @param x defines viewport left coordinate
  3702. * @param y defines viewport top coordinate
  3703. * @param width defines the viewport width
  3704. * @param height defines the viewport height
  3705. */
  3706. constructor(
  3707. /** viewport left coordinate */
  3708. x: number,
  3709. /** viewport top coordinate */
  3710. y: number,
  3711. /**viewport width */
  3712. width: number,
  3713. /** viewport height */
  3714. height: number);
  3715. /**
  3716. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3717. * @param renderWidth defines the rendering width
  3718. * @param renderHeight defines the rendering height
  3719. * @returns a new Viewport
  3720. */
  3721. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3722. /**
  3723. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3724. * @param renderWidth defines the rendering width
  3725. * @param renderHeight defines the rendering height
  3726. * @param ref defines the target viewport
  3727. * @returns the current viewport
  3728. */
  3729. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3730. /**
  3731. * Returns a new Viewport copied from the current one
  3732. * @returns a new Viewport
  3733. */
  3734. clone(): Viewport;
  3735. }
  3736. /**
  3737. * Reprasents a camera frustum
  3738. */
  3739. export class Frustum {
  3740. /**
  3741. * Gets the planes representing the frustum
  3742. * @param transform matrix to be applied to the returned planes
  3743. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3744. */
  3745. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3746. /**
  3747. * Gets the near frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the far frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the left frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Gets the right frustum plane transformed by the transform matrix
  3766. * @param transform transformation matrix to be applied to the resulting frustum plane
  3767. * @param frustumPlane the resuling frustum plane
  3768. */
  3769. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3770. /**
  3771. * Gets the top frustum plane transformed by the transform matrix
  3772. * @param transform transformation matrix to be applied to the resulting frustum plane
  3773. * @param frustumPlane the resuling frustum plane
  3774. */
  3775. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3776. /**
  3777. * Gets the bottom frustum plane transformed by the transform matrix
  3778. * @param transform transformation matrix to be applied to the resulting frustum plane
  3779. * @param frustumPlane the resuling frustum plane
  3780. */
  3781. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3782. /**
  3783. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3784. * @param transform transformation matrix to be applied to the resulting frustum planes
  3785. * @param frustumPlanes the resuling frustum planes
  3786. */
  3787. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3788. }
  3789. /** Defines supported spaces */
  3790. export enum Space {
  3791. /** Local (object) space */
  3792. LOCAL = 0,
  3793. /** World space */
  3794. WORLD = 1,
  3795. /** Bone space */
  3796. BONE = 2
  3797. }
  3798. /** Defines the 3 main axes */
  3799. export class Axis {
  3800. /** X axis */
  3801. static X: Vector3;
  3802. /** Y axis */
  3803. static Y: Vector3;
  3804. /** Z axis */
  3805. static Z: Vector3;
  3806. }
  3807. /** Class used to represent a Bezier curve */
  3808. export class BezierCurve {
  3809. /**
  3810. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3811. * @param t defines the time
  3812. * @param x1 defines the left coordinate on X axis
  3813. * @param y1 defines the left coordinate on Y axis
  3814. * @param x2 defines the right coordinate on X axis
  3815. * @param y2 defines the right coordinate on Y axis
  3816. * @returns the interpolated value
  3817. */
  3818. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3819. }
  3820. /**
  3821. * Defines potential orientation for back face culling
  3822. */
  3823. export enum Orientation {
  3824. /**
  3825. * Clockwise
  3826. */
  3827. CW = 0,
  3828. /** Counter clockwise */
  3829. CCW = 1
  3830. }
  3831. /**
  3832. * Defines angle representation
  3833. */
  3834. export class Angle {
  3835. private _radians;
  3836. /**
  3837. * Creates an Angle object of "radians" radians (float).
  3838. * @param radians the angle in radians
  3839. */
  3840. constructor(radians: number);
  3841. /**
  3842. * Get value in degrees
  3843. * @returns the Angle value in degrees (float)
  3844. */
  3845. degrees(): number;
  3846. /**
  3847. * Get value in radians
  3848. * @returns the Angle value in radians (float)
  3849. */
  3850. radians(): number;
  3851. /**
  3852. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3853. * @param a defines first vector
  3854. * @param b defines second vector
  3855. * @returns a new Angle
  3856. */
  3857. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3858. /**
  3859. * Gets a new Angle object from the given float in radians
  3860. * @param radians defines the angle value in radians
  3861. * @returns a new Angle
  3862. */
  3863. static FromRadians(radians: number): Angle;
  3864. /**
  3865. * Gets a new Angle object from the given float in degrees
  3866. * @param degrees defines the angle value in degrees
  3867. * @returns a new Angle
  3868. */
  3869. static FromDegrees(degrees: number): Angle;
  3870. }
  3871. /**
  3872. * This represents an arc in a 2d space.
  3873. */
  3874. export class Arc2 {
  3875. /** Defines the start point of the arc */
  3876. startPoint: Vector2;
  3877. /** Defines the mid point of the arc */
  3878. midPoint: Vector2;
  3879. /** Defines the end point of the arc */
  3880. endPoint: Vector2;
  3881. /**
  3882. * Defines the center point of the arc.
  3883. */
  3884. centerPoint: Vector2;
  3885. /**
  3886. * Defines the radius of the arc.
  3887. */
  3888. radius: number;
  3889. /**
  3890. * Defines the angle of the arc (from mid point to end point).
  3891. */
  3892. angle: Angle;
  3893. /**
  3894. * Defines the start angle of the arc (from start point to middle point).
  3895. */
  3896. startAngle: Angle;
  3897. /**
  3898. * Defines the orientation of the arc (clock wise/counter clock wise).
  3899. */
  3900. orientation: Orientation;
  3901. /**
  3902. * Creates an Arc object from the three given points : start, middle and end.
  3903. * @param startPoint Defines the start point of the arc
  3904. * @param midPoint Defines the midlle point of the arc
  3905. * @param endPoint Defines the end point of the arc
  3906. */
  3907. constructor(
  3908. /** Defines the start point of the arc */
  3909. startPoint: Vector2,
  3910. /** Defines the mid point of the arc */
  3911. midPoint: Vector2,
  3912. /** Defines the end point of the arc */
  3913. endPoint: Vector2);
  3914. }
  3915. /**
  3916. * Represents a 2D path made up of multiple 2D points
  3917. */
  3918. export class Path2 {
  3919. private _points;
  3920. private _length;
  3921. /**
  3922. * If the path start and end point are the same
  3923. */
  3924. closed: boolean;
  3925. /**
  3926. * Creates a Path2 object from the starting 2D coordinates x and y.
  3927. * @param x the starting points x value
  3928. * @param y the starting points y value
  3929. */
  3930. constructor(x: number, y: number);
  3931. /**
  3932. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3933. * @param x the added points x value
  3934. * @param y the added points y value
  3935. * @returns the updated Path2.
  3936. */
  3937. addLineTo(x: number, y: number): Path2;
  3938. /**
  3939. * 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.
  3940. * @param midX middle point x value
  3941. * @param midY middle point y value
  3942. * @param endX end point x value
  3943. * @param endY end point y value
  3944. * @param numberOfSegments (default: 36)
  3945. * @returns the updated Path2.
  3946. */
  3947. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3948. /**
  3949. * Closes the Path2.
  3950. * @returns the Path2.
  3951. */
  3952. close(): Path2;
  3953. /**
  3954. * Gets the sum of the distance between each sequential point in the path
  3955. * @returns the Path2 total length (float).
  3956. */
  3957. length(): number;
  3958. /**
  3959. * Gets the points which construct the path
  3960. * @returns the Path2 internal array of points.
  3961. */
  3962. getPoints(): Vector2[];
  3963. /**
  3964. * Retreives the point at the distance aways from the starting point
  3965. * @param normalizedLengthPosition the length along the path to retreive the point from
  3966. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3967. */
  3968. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3969. /**
  3970. * Creates a new path starting from an x and y position
  3971. * @param x starting x value
  3972. * @param y starting y value
  3973. * @returns a new Path2 starting at the coordinates (x, y).
  3974. */
  3975. static StartingAt(x: number, y: number): Path2;
  3976. }
  3977. /**
  3978. * Represents a 3D path made up of multiple 3D points
  3979. */
  3980. export class Path3D {
  3981. /**
  3982. * an array of Vector3, the curve axis of the Path3D
  3983. */
  3984. path: Vector3[];
  3985. private _curve;
  3986. private _distances;
  3987. private _tangents;
  3988. private _normals;
  3989. private _binormals;
  3990. private _raw;
  3991. /**
  3992. * new Path3D(path, normal, raw)
  3993. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3994. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3995. * @param path an array of Vector3, the curve axis of the Path3D
  3996. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3997. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3998. */
  3999. constructor(
  4000. /**
  4001. * an array of Vector3, the curve axis of the Path3D
  4002. */
  4003. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4004. /**
  4005. * Returns the Path3D array of successive Vector3 designing its curve.
  4006. * @returns the Path3D array of successive Vector3 designing its curve.
  4007. */
  4008. getCurve(): Vector3[];
  4009. /**
  4010. * Returns an array populated with tangent vectors on each Path3D curve point.
  4011. * @returns an array populated with tangent vectors on each Path3D curve point.
  4012. */
  4013. getTangents(): Vector3[];
  4014. /**
  4015. * Returns an array populated with normal vectors on each Path3D curve point.
  4016. * @returns an array populated with normal vectors on each Path3D curve point.
  4017. */
  4018. getNormals(): Vector3[];
  4019. /**
  4020. * Returns an array populated with binormal vectors on each Path3D curve point.
  4021. * @returns an array populated with binormal vectors on each Path3D curve point.
  4022. */
  4023. getBinormals(): Vector3[];
  4024. /**
  4025. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4026. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4027. */
  4028. getDistances(): number[];
  4029. /**
  4030. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4031. * @param path path which all values are copied into the curves points
  4032. * @param firstNormal which should be projected onto the curve
  4033. * @returns the same object updated.
  4034. */
  4035. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4036. private _compute;
  4037. private _getFirstNonNullVector;
  4038. private _getLastNonNullVector;
  4039. private _normalVector;
  4040. }
  4041. /**
  4042. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4043. * A Curve3 is designed from a series of successive Vector3.
  4044. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4045. */
  4046. export class Curve3 {
  4047. private _points;
  4048. private _length;
  4049. /**
  4050. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4051. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4052. * @param v1 (Vector3) the control point
  4053. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4054. * @param nbPoints (integer) the wanted number of points in the curve
  4055. * @returns the created Curve3
  4056. */
  4057. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4058. /**
  4059. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4060. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4061. * @param v1 (Vector3) the first control point
  4062. * @param v2 (Vector3) the second control point
  4063. * @param v3 (Vector3) the end point of the Cubic Bezier
  4064. * @param nbPoints (integer) the wanted number of points in the curve
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4068. /**
  4069. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4070. * @param p1 (Vector3) the origin point of the Hermite Spline
  4071. * @param t1 (Vector3) the tangent vector at the origin point
  4072. * @param p2 (Vector3) the end point of the Hermite Spline
  4073. * @param t2 (Vector3) the tangent vector at the end point
  4074. * @param nbPoints (integer) the wanted number of points in the curve
  4075. * @returns the created Curve3
  4076. */
  4077. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4078. /**
  4079. * Returns a Curve3 object along a CatmullRom Spline curve :
  4080. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4081. * @param nbPoints (integer) the wanted number of points between each curve control points
  4082. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4083. * @returns the created Curve3
  4084. */
  4085. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4086. /**
  4087. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4088. * A Curve3 is designed from a series of successive Vector3.
  4089. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4090. * @param points points which make up the curve
  4091. */
  4092. constructor(points: Vector3[]);
  4093. /**
  4094. * @returns the Curve3 stored array of successive Vector3
  4095. */
  4096. getPoints(): Vector3[];
  4097. /**
  4098. * @returns the computed length (float) of the curve.
  4099. */
  4100. length(): number;
  4101. /**
  4102. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4103. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4104. * curveA and curveB keep unchanged.
  4105. * @param curve the curve to continue from this curve
  4106. * @returns the newly constructed curve
  4107. */
  4108. continue(curve: DeepImmutable<Curve3>): Curve3;
  4109. private _computeLength;
  4110. }
  4111. /**
  4112. * Contains position and normal vectors for a vertex
  4113. */
  4114. export class PositionNormalVertex {
  4115. /** the position of the vertex (defaut: 0,0,0) */
  4116. position: Vector3;
  4117. /** the normal of the vertex (defaut: 0,1,0) */
  4118. normal: Vector3;
  4119. /**
  4120. * Creates a PositionNormalVertex
  4121. * @param position the position of the vertex (defaut: 0,0,0)
  4122. * @param normal the normal of the vertex (defaut: 0,1,0)
  4123. */
  4124. constructor(
  4125. /** the position of the vertex (defaut: 0,0,0) */
  4126. position?: Vector3,
  4127. /** the normal of the vertex (defaut: 0,1,0) */
  4128. normal?: Vector3);
  4129. /**
  4130. * Clones the PositionNormalVertex
  4131. * @returns the cloned PositionNormalVertex
  4132. */
  4133. clone(): PositionNormalVertex;
  4134. }
  4135. /**
  4136. * Contains position, normal and uv vectors for a vertex
  4137. */
  4138. export class PositionNormalTextureVertex {
  4139. /** the position of the vertex (defaut: 0,0,0) */
  4140. position: Vector3;
  4141. /** the normal of the vertex (defaut: 0,1,0) */
  4142. normal: Vector3;
  4143. /** the uv of the vertex (default: 0,0) */
  4144. uv: Vector2;
  4145. /**
  4146. * Creates a PositionNormalTextureVertex
  4147. * @param position the position of the vertex (defaut: 0,0,0)
  4148. * @param normal the normal of the vertex (defaut: 0,1,0)
  4149. * @param uv the uv of the vertex (default: 0,0)
  4150. */
  4151. constructor(
  4152. /** the position of the vertex (defaut: 0,0,0) */
  4153. position?: Vector3,
  4154. /** the normal of the vertex (defaut: 0,1,0) */
  4155. normal?: Vector3,
  4156. /** the uv of the vertex (default: 0,0) */
  4157. uv?: Vector2);
  4158. /**
  4159. * Clones the PositionNormalTextureVertex
  4160. * @returns the cloned PositionNormalTextureVertex
  4161. */
  4162. clone(): PositionNormalTextureVertex;
  4163. }
  4164. /**
  4165. * @hidden
  4166. */
  4167. export class Tmp {
  4168. static Color3: Color3[];
  4169. static Color4: Color4[];
  4170. static Vector2: Vector2[];
  4171. static Vector3: Vector3[];
  4172. static Vector4: Vector4[];
  4173. static Quaternion: Quaternion[];
  4174. static Matrix: Matrix[];
  4175. }
  4176. }
  4177. declare module BABYLON {
  4178. /**
  4179. * Class used to enable access to offline support
  4180. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4181. */
  4182. export interface IOfflineProvider {
  4183. /**
  4184. * Gets a boolean indicating if scene must be saved in the database
  4185. */
  4186. enableSceneOffline: boolean;
  4187. /**
  4188. * Gets a boolean indicating if textures must be saved in the database
  4189. */
  4190. enableTexturesOffline: boolean;
  4191. /**
  4192. * Open the offline support and make it available
  4193. * @param successCallback defines the callback to call on success
  4194. * @param errorCallback defines the callback to call on error
  4195. */
  4196. open(successCallback: () => void, errorCallback: () => void): void;
  4197. /**
  4198. * Loads an image from the offline support
  4199. * @param url defines the url to load from
  4200. * @param image defines the target DOM image
  4201. */
  4202. loadImage(url: string, image: HTMLImageElement): void;
  4203. /**
  4204. * Loads a file from offline support
  4205. * @param url defines the URL to load from
  4206. * @param sceneLoaded defines a callback to call on success
  4207. * @param progressCallBack defines a callback to call when progress changed
  4208. * @param errorCallback defines a callback to call on error
  4209. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4210. */
  4211. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4212. }
  4213. }
  4214. declare module BABYLON {
  4215. /**
  4216. * A class serves as a medium between the observable and its observers
  4217. */
  4218. export class EventState {
  4219. /**
  4220. * Create a new EventState
  4221. * @param mask defines the mask associated with this state
  4222. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4223. * @param target defines the original target of the state
  4224. * @param currentTarget defines the current target of the state
  4225. */
  4226. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4227. /**
  4228. * Initialize the current event state
  4229. * @param mask defines the mask associated with this state
  4230. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4231. * @param target defines the original target of the state
  4232. * @param currentTarget defines the current target of the state
  4233. * @returns the current event state
  4234. */
  4235. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4236. /**
  4237. * An Observer can set this property to true to prevent subsequent observers of being notified
  4238. */
  4239. skipNextObservers: boolean;
  4240. /**
  4241. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4242. */
  4243. mask: number;
  4244. /**
  4245. * The object that originally notified the event
  4246. */
  4247. target?: any;
  4248. /**
  4249. * The current object in the bubbling phase
  4250. */
  4251. currentTarget?: any;
  4252. /**
  4253. * This will be populated with the return value of the last function that was executed.
  4254. * If it is the first function in the callback chain it will be the event data.
  4255. */
  4256. lastReturnValue?: any;
  4257. }
  4258. /**
  4259. * Represent an Observer registered to a given Observable object.
  4260. */
  4261. export class Observer<T> {
  4262. /**
  4263. * Defines the callback to call when the observer is notified
  4264. */
  4265. callback: (eventData: T, eventState: EventState) => void;
  4266. /**
  4267. * Defines the mask of the observer (used to filter notifications)
  4268. */
  4269. mask: number;
  4270. /**
  4271. * Defines the current scope used to restore the JS context
  4272. */
  4273. scope: any;
  4274. /** @hidden */
  4275. _willBeUnregistered: boolean;
  4276. /**
  4277. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4278. */
  4279. unregisterOnNextCall: boolean;
  4280. /**
  4281. * Creates a new observer
  4282. * @param callback defines the callback to call when the observer is notified
  4283. * @param mask defines the mask of the observer (used to filter notifications)
  4284. * @param scope defines the current scope used to restore the JS context
  4285. */
  4286. constructor(
  4287. /**
  4288. * Defines the callback to call when the observer is notified
  4289. */
  4290. callback: (eventData: T, eventState: EventState) => void,
  4291. /**
  4292. * Defines the mask of the observer (used to filter notifications)
  4293. */
  4294. mask: number,
  4295. /**
  4296. * Defines the current scope used to restore the JS context
  4297. */
  4298. scope?: any);
  4299. }
  4300. /**
  4301. * Represent a list of observers registered to multiple Observables object.
  4302. */
  4303. export class MultiObserver<T> {
  4304. private _observers;
  4305. private _observables;
  4306. /**
  4307. * Release associated resources
  4308. */
  4309. dispose(): void;
  4310. /**
  4311. * Raise a callback when one of the observable will notify
  4312. * @param observables defines a list of observables to watch
  4313. * @param callback defines the callback to call on notification
  4314. * @param mask defines the mask used to filter notifications
  4315. * @param scope defines the current scope used to restore the JS context
  4316. * @returns the new MultiObserver
  4317. */
  4318. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4319. }
  4320. /**
  4321. * The Observable class is a simple implementation of the Observable pattern.
  4322. *
  4323. * 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.
  4324. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4325. * 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).
  4326. * 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.
  4327. */
  4328. export class Observable<T> {
  4329. private _observers;
  4330. private _eventState;
  4331. private _onObserverAdded;
  4332. /**
  4333. * Creates a new observable
  4334. * @param onObserverAdded defines a callback to call when a new observer is added
  4335. */
  4336. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4337. /**
  4338. * Create a new Observer with the specified callback
  4339. * @param callback the callback that will be executed for that Observer
  4340. * @param mask the mask used to filter observers
  4341. * @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.
  4342. * @param scope optional scope for the callback to be called from
  4343. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4344. * @returns the new observer created for the callback
  4345. */
  4346. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4347. /**
  4348. * Create a new Observer with the specified callback and unregisters after the next notification
  4349. * @param callback the callback that will be executed for that Observer
  4350. * @returns the new observer created for the callback
  4351. */
  4352. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4353. /**
  4354. * Remove an Observer from the Observable object
  4355. * @param observer the instance of the Observer to remove
  4356. * @returns false if it doesn't belong to this Observable
  4357. */
  4358. remove(observer: Nullable<Observer<T>>): boolean;
  4359. /**
  4360. * Remove a callback from the Observable object
  4361. * @param callback the callback to remove
  4362. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4363. * @returns false if it doesn't belong to this Observable
  4364. */
  4365. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4366. private _deferUnregister;
  4367. private _remove;
  4368. /**
  4369. * Moves the observable to the top of the observer list making it get called first when notified
  4370. * @param observer the observer to move
  4371. */
  4372. makeObserverTopPriority(observer: Observer<T>): void;
  4373. /**
  4374. * Moves the observable to the bottom of the observer list making it get called last when notified
  4375. * @param observer the observer to move
  4376. */
  4377. makeObserverBottomPriority(observer: Observer<T>): void;
  4378. /**
  4379. * Notify all Observers by calling their respective callback with the given data
  4380. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4381. * @param eventData defines the data to send to all observers
  4382. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4383. * @param target defines the original target of the state
  4384. * @param currentTarget defines the current target of the state
  4385. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4386. */
  4387. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4388. /**
  4389. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4390. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4391. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4392. * and it is crucial that all callbacks will be executed.
  4393. * The order of the callbacks is kept, callbacks are not executed parallel.
  4394. *
  4395. * @param eventData The data to be sent to each callback
  4396. * @param mask is used to filter observers defaults to -1
  4397. * @param target defines the callback target (see EventState)
  4398. * @param currentTarget defines he current object in the bubbling phase
  4399. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4400. */
  4401. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4402. /**
  4403. * Notify a specific observer
  4404. * @param observer defines the observer to notify
  4405. * @param eventData defines the data to be sent to each callback
  4406. * @param mask is used to filter observers defaults to -1
  4407. */
  4408. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4409. /**
  4410. * Gets a boolean indicating if the observable has at least one observer
  4411. * @returns true is the Observable has at least one Observer registered
  4412. */
  4413. hasObservers(): boolean;
  4414. /**
  4415. * Clear the list of observers
  4416. */
  4417. clear(): void;
  4418. /**
  4419. * Clone the current observable
  4420. * @returns a new observable
  4421. */
  4422. clone(): Observable<T>;
  4423. /**
  4424. * Does this observable handles observer registered with a given mask
  4425. * @param mask defines the mask to be tested
  4426. * @return whether or not one observer registered with the given mask is handeled
  4427. **/
  4428. hasSpecificMask(mask?: number): boolean;
  4429. }
  4430. }
  4431. declare module BABYLON {
  4432. /**
  4433. * Class used to help managing file picking and drag'n'drop
  4434. * File Storage
  4435. */
  4436. export class FilesInputStore {
  4437. /**
  4438. * List of files ready to be loaded
  4439. */
  4440. static FilesToLoad: {
  4441. [key: string]: File;
  4442. };
  4443. }
  4444. }
  4445. declare module BABYLON {
  4446. /** Defines the cross module used constants to avoid circular dependncies */
  4447. export class Constants {
  4448. /** Defines that alpha blending is disabled */
  4449. static readonly ALPHA_DISABLE: number;
  4450. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4451. static readonly ALPHA_ADD: number;
  4452. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4453. static readonly ALPHA_COMBINE: number;
  4454. /** Defines that alpha blending to DEST - SRC * DEST */
  4455. static readonly ALPHA_SUBTRACT: number;
  4456. /** Defines that alpha blending to SRC * DEST */
  4457. static readonly ALPHA_MULTIPLY: number;
  4458. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4459. static readonly ALPHA_MAXIMIZED: number;
  4460. /** Defines that alpha blending to SRC + DEST */
  4461. static readonly ALPHA_ONEONE: number;
  4462. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4463. static readonly ALPHA_PREMULTIPLIED: number;
  4464. /**
  4465. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4466. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4467. */
  4468. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4469. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4470. static readonly ALPHA_INTERPOLATE: number;
  4471. /**
  4472. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4473. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4474. */
  4475. static readonly ALPHA_SCREENMODE: number;
  4476. /** Defines that the ressource is not delayed*/
  4477. static readonly DELAYLOADSTATE_NONE: number;
  4478. /** Defines that the ressource was successfully delay loaded */
  4479. static readonly DELAYLOADSTATE_LOADED: number;
  4480. /** Defines that the ressource is currently delay loading */
  4481. static readonly DELAYLOADSTATE_LOADING: number;
  4482. /** Defines that the ressource is delayed and has not started loading */
  4483. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4485. static readonly NEVER: number;
  4486. /** 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 */
  4487. static readonly ALWAYS: number;
  4488. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4489. static readonly LESS: number;
  4490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4491. static readonly EQUAL: number;
  4492. /** 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 */
  4493. static readonly LEQUAL: number;
  4494. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4495. static readonly GREATER: number;
  4496. /** 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 */
  4497. static readonly GEQUAL: number;
  4498. /** 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 */
  4499. static readonly NOTEQUAL: number;
  4500. /** Passed to stencilOperation to specify that stencil value must be kept */
  4501. static readonly KEEP: number;
  4502. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4503. static readonly REPLACE: number;
  4504. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4505. static readonly INCR: number;
  4506. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4507. static readonly DECR: number;
  4508. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4509. static readonly INVERT: number;
  4510. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4511. static readonly INCR_WRAP: number;
  4512. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4513. static readonly DECR_WRAP: number;
  4514. /** Texture is not repeating outside of 0..1 UVs */
  4515. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4516. /** Texture is repeating outside of 0..1 UVs */
  4517. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4518. /** Texture is repeating and mirrored */
  4519. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4520. /** ALPHA */
  4521. static readonly TEXTUREFORMAT_ALPHA: number;
  4522. /** LUMINANCE */
  4523. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4524. /** LUMINANCE_ALPHA */
  4525. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4526. /** RGB */
  4527. static readonly TEXTUREFORMAT_RGB: number;
  4528. /** RGBA */
  4529. static readonly TEXTUREFORMAT_RGBA: number;
  4530. /** RED */
  4531. static readonly TEXTUREFORMAT_RED: number;
  4532. /** RED (2nd reference) */
  4533. static readonly TEXTUREFORMAT_R: number;
  4534. /** RG */
  4535. static readonly TEXTUREFORMAT_RG: number;
  4536. /** RED_INTEGER */
  4537. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4538. /** RED_INTEGER (2nd reference) */
  4539. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4540. /** RG_INTEGER */
  4541. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4542. /** RGB_INTEGER */
  4543. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4544. /** RGBA_INTEGER */
  4545. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4546. /** UNSIGNED_BYTE */
  4547. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4548. /** UNSIGNED_BYTE (2nd reference) */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4550. /** FLOAT */
  4551. static readonly TEXTURETYPE_FLOAT: number;
  4552. /** HALF_FLOAT */
  4553. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4554. /** BYTE */
  4555. static readonly TEXTURETYPE_BYTE: number;
  4556. /** SHORT */
  4557. static readonly TEXTURETYPE_SHORT: number;
  4558. /** UNSIGNED_SHORT */
  4559. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4560. /** INT */
  4561. static readonly TEXTURETYPE_INT: number;
  4562. /** UNSIGNED_INT */
  4563. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4564. /** UNSIGNED_SHORT_4_4_4_4 */
  4565. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4566. /** UNSIGNED_SHORT_5_5_5_1 */
  4567. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4568. /** UNSIGNED_SHORT_5_6_5 */
  4569. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4570. /** UNSIGNED_INT_2_10_10_10_REV */
  4571. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4572. /** UNSIGNED_INT_24_8 */
  4573. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4574. /** UNSIGNED_INT_10F_11F_11F_REV */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4576. /** UNSIGNED_INT_5_9_9_9_REV */
  4577. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4578. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4579. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4580. /** nearest is mag = nearest and min = nearest and mip = linear */
  4581. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4582. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4583. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4584. /** Trilinear is mag = linear and min = linear and mip = linear */
  4585. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4586. /** nearest is mag = nearest and min = nearest and mip = linear */
  4587. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4588. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4590. /** Trilinear is mag = linear and min = linear and mip = linear */
  4591. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4592. /** mag = nearest and min = nearest and mip = nearest */
  4593. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4594. /** mag = nearest and min = linear and mip = nearest */
  4595. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4596. /** mag = nearest and min = linear and mip = linear */
  4597. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4598. /** mag = nearest and min = linear and mip = none */
  4599. static readonly TEXTURE_NEAREST_LINEAR: number;
  4600. /** mag = nearest and min = nearest and mip = none */
  4601. static readonly TEXTURE_NEAREST_NEAREST: number;
  4602. /** mag = linear and min = nearest and mip = nearest */
  4603. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4604. /** mag = linear and min = nearest and mip = linear */
  4605. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4606. /** mag = linear and min = linear and mip = none */
  4607. static readonly TEXTURE_LINEAR_LINEAR: number;
  4608. /** mag = linear and min = nearest and mip = none */
  4609. static readonly TEXTURE_LINEAR_NEAREST: number;
  4610. /** Explicit coordinates mode */
  4611. static readonly TEXTURE_EXPLICIT_MODE: number;
  4612. /** Spherical coordinates mode */
  4613. static readonly TEXTURE_SPHERICAL_MODE: number;
  4614. /** Planar coordinates mode */
  4615. static readonly TEXTURE_PLANAR_MODE: number;
  4616. /** Cubic coordinates mode */
  4617. static readonly TEXTURE_CUBIC_MODE: number;
  4618. /** Projection coordinates mode */
  4619. static readonly TEXTURE_PROJECTION_MODE: number;
  4620. /** Skybox coordinates mode */
  4621. static readonly TEXTURE_SKYBOX_MODE: number;
  4622. /** Inverse Cubic coordinates mode */
  4623. static readonly TEXTURE_INVCUBIC_MODE: number;
  4624. /** Equirectangular coordinates mode */
  4625. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4626. /** Equirectangular Fixed coordinates mode */
  4627. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4628. /** Equirectangular Fixed Mirrored coordinates mode */
  4629. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4630. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4631. static readonly SCALEMODE_FLOOR: number;
  4632. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4633. static readonly SCALEMODE_NEAREST: number;
  4634. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4635. static readonly SCALEMODE_CEILING: number;
  4636. /**
  4637. * The dirty texture flag value
  4638. */
  4639. static readonly MATERIAL_TextureDirtyFlag: number;
  4640. /**
  4641. * The dirty light flag value
  4642. */
  4643. static readonly MATERIAL_LightDirtyFlag: number;
  4644. /**
  4645. * The dirty fresnel flag value
  4646. */
  4647. static readonly MATERIAL_FresnelDirtyFlag: number;
  4648. /**
  4649. * The dirty attribute flag value
  4650. */
  4651. static readonly MATERIAL_AttributesDirtyFlag: number;
  4652. /**
  4653. * The dirty misc flag value
  4654. */
  4655. static readonly MATERIAL_MiscDirtyFlag: number;
  4656. /**
  4657. * The all dirty flag value
  4658. */
  4659. static readonly MATERIAL_AllDirtyFlag: number;
  4660. /**
  4661. * Returns the triangle fill mode
  4662. */
  4663. static readonly MATERIAL_TriangleFillMode: number;
  4664. /**
  4665. * Returns the wireframe mode
  4666. */
  4667. static readonly MATERIAL_WireFrameFillMode: number;
  4668. /**
  4669. * Returns the point fill mode
  4670. */
  4671. static readonly MATERIAL_PointFillMode: number;
  4672. /**
  4673. * Returns the point list draw mode
  4674. */
  4675. static readonly MATERIAL_PointListDrawMode: number;
  4676. /**
  4677. * Returns the line list draw mode
  4678. */
  4679. static readonly MATERIAL_LineListDrawMode: number;
  4680. /**
  4681. * Returns the line loop draw mode
  4682. */
  4683. static readonly MATERIAL_LineLoopDrawMode: number;
  4684. /**
  4685. * Returns the line strip draw mode
  4686. */
  4687. static readonly MATERIAL_LineStripDrawMode: number;
  4688. /**
  4689. * Returns the triangle strip draw mode
  4690. */
  4691. static readonly MATERIAL_TriangleStripDrawMode: number;
  4692. /**
  4693. * Returns the triangle fan draw mode
  4694. */
  4695. static readonly MATERIAL_TriangleFanDrawMode: number;
  4696. /**
  4697. * Stores the clock-wise side orientation
  4698. */
  4699. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4700. /**
  4701. * Stores the counter clock-wise side orientation
  4702. */
  4703. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4704. /**
  4705. * Nothing
  4706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4707. */
  4708. static readonly ACTION_NothingTrigger: number;
  4709. /**
  4710. * On pick
  4711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4712. */
  4713. static readonly ACTION_OnPickTrigger: number;
  4714. /**
  4715. * On left pick
  4716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4717. */
  4718. static readonly ACTION_OnLeftPickTrigger: number;
  4719. /**
  4720. * On right pick
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnRightPickTrigger: number;
  4724. /**
  4725. * On center pick
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnCenterPickTrigger: number;
  4729. /**
  4730. * On pick down
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickDownTrigger: number;
  4734. /**
  4735. * On double pick
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnDoublePickTrigger: number;
  4739. /**
  4740. * On pick up
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickUpTrigger: number;
  4744. /**
  4745. * On pick out.
  4746. * This trigger will only be raised if you also declared a OnPickDown
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnPickOutTrigger: number;
  4750. /**
  4751. * On long press
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnLongPressTrigger: number;
  4755. /**
  4756. * On pointer over
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPointerOverTrigger: number;
  4760. /**
  4761. * On pointer out
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnPointerOutTrigger: number;
  4765. /**
  4766. * On every frame
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnEveryFrameTrigger: number;
  4770. /**
  4771. * On intersection enter
  4772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4773. */
  4774. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4775. /**
  4776. * On intersection exit
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnIntersectionExitTrigger: number;
  4780. /**
  4781. * On key down
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnKeyDownTrigger: number;
  4785. /**
  4786. * On key up
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnKeyUpTrigger: number;
  4790. /**
  4791. * Billboard mode will only apply to Y axis
  4792. */
  4793. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4794. /**
  4795. * Billboard mode will apply to all axes
  4796. */
  4797. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4798. /**
  4799. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4800. */
  4801. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4802. /**
  4803. * Gets or sets base Assets URL
  4804. */
  4805. static readonly PARTICLES_BaseAssetsUrl: string;
  4806. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4807. * Test order :
  4808. * Is the bounding sphere outside the frustum ?
  4809. * If not, are the bounding box vertices outside the frustum ?
  4810. * It not, then the cullable object is in the frustum.
  4811. */
  4812. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4813. /** Culling strategy : Bounding Sphere Only.
  4814. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4815. * It's also less accurate than the standard because some not visible objects can still be selected.
  4816. * Test : is the bounding sphere outside the frustum ?
  4817. * If not, then the cullable object is in the frustum.
  4818. */
  4819. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4820. /** Culling strategy : Optimistic Inclusion.
  4821. * This in an inclusion test first, then the standard exclusion test.
  4822. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4823. * 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.
  4824. * Anyway, it's as accurate as the standard strategy.
  4825. * Test :
  4826. * Is the cullable object bounding sphere center in the frustum ?
  4827. * If not, apply the default culling strategy.
  4828. */
  4829. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4830. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4831. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4832. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4833. * 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.
  4834. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4835. * Test :
  4836. * Is the cullable object bounding sphere center in the frustum ?
  4837. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4840. /**
  4841. * No logging while loading
  4842. */
  4843. static readonly SCENELOADER_NO_LOGGING: number;
  4844. /**
  4845. * Minimal logging while loading
  4846. */
  4847. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4848. /**
  4849. * Summary logging while loading
  4850. */
  4851. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4852. /**
  4853. * Detailled logging while loading
  4854. */
  4855. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4856. }
  4857. }
  4858. declare module BABYLON {
  4859. /**
  4860. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4861. * Babylon.js
  4862. */
  4863. export class DomManagement {
  4864. /**
  4865. * Checks if the window object exists
  4866. * @returns true if the window object exists
  4867. */
  4868. static IsWindowObjectExist(): boolean;
  4869. /**
  4870. * Extracts text content from a DOM element hierarchy
  4871. * @param element defines the root element
  4872. * @returns a string
  4873. */
  4874. static GetDOMTextContent(element: HTMLElement): string;
  4875. }
  4876. }
  4877. declare module BABYLON {
  4878. /**
  4879. * Logger used througouht the application to allow configuration of
  4880. * the log level required for the messages.
  4881. */
  4882. export class Logger {
  4883. /**
  4884. * No log
  4885. */
  4886. static readonly NoneLogLevel: number;
  4887. /**
  4888. * Only message logs
  4889. */
  4890. static readonly MessageLogLevel: number;
  4891. /**
  4892. * Only warning logs
  4893. */
  4894. static readonly WarningLogLevel: number;
  4895. /**
  4896. * Only error logs
  4897. */
  4898. static readonly ErrorLogLevel: number;
  4899. /**
  4900. * All logs
  4901. */
  4902. static readonly AllLogLevel: number;
  4903. private static _LogCache;
  4904. /**
  4905. * Gets a value indicating the number of loading errors
  4906. * @ignorenaming
  4907. */
  4908. static errorsCount: number;
  4909. /**
  4910. * Callback called when a new log is added
  4911. */
  4912. static OnNewCacheEntry: (entry: string) => void;
  4913. private static _AddLogEntry;
  4914. private static _FormatMessage;
  4915. private static _LogDisabled;
  4916. private static _LogEnabled;
  4917. private static _WarnDisabled;
  4918. private static _WarnEnabled;
  4919. private static _ErrorDisabled;
  4920. private static _ErrorEnabled;
  4921. /**
  4922. * Log a message to the console
  4923. */
  4924. static Log: (message: string) => void;
  4925. /**
  4926. * Write a warning message to the console
  4927. */
  4928. static Warn: (message: string) => void;
  4929. /**
  4930. * Write an error message to the console
  4931. */
  4932. static Error: (message: string) => void;
  4933. /**
  4934. * Gets current log cache (list of logs)
  4935. */
  4936. static readonly LogCache: string;
  4937. /**
  4938. * Clears the log cache
  4939. */
  4940. static ClearLogCache(): void;
  4941. /**
  4942. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4943. */
  4944. static LogLevels: number;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /** @hidden */
  4949. export class _TypeStore {
  4950. /** @hidden */
  4951. static RegisteredTypes: {
  4952. [key: string]: Object;
  4953. };
  4954. /** @hidden */
  4955. static GetClass(fqdn: string): any;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /**
  4960. * Class containing a set of static utilities functions for deep copy.
  4961. */
  4962. export class DeepCopier {
  4963. /**
  4964. * Tries to copy an object by duplicating every property
  4965. * @param source defines the source object
  4966. * @param destination defines the target object
  4967. * @param doNotCopyList defines a list of properties to avoid
  4968. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4969. */
  4970. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4971. }
  4972. }
  4973. declare module BABYLON {
  4974. /**
  4975. * Class containing a set of static utilities functions for precision date
  4976. */
  4977. export class PrecisionDate {
  4978. /**
  4979. * Gets either window.performance.now() if supported or Date.now() else
  4980. */
  4981. static readonly Now: number;
  4982. }
  4983. }
  4984. declare module BABYLON {
  4985. /** @hidden */
  4986. export class _DevTools {
  4987. static WarnImport(name: string): string;
  4988. }
  4989. }
  4990. declare module BABYLON {
  4991. /**
  4992. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4993. */
  4994. export class WebRequest {
  4995. private _xhr;
  4996. /**
  4997. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4998. * i.e. when loading files, where the server/service expects an Authorization header
  4999. */
  5000. static CustomRequestHeaders: {
  5001. [key: string]: string;
  5002. };
  5003. /**
  5004. * Add callback functions in this array to update all the requests before they get sent to the network
  5005. */
  5006. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5007. private _injectCustomRequestHeaders;
  5008. /**
  5009. * Gets or sets a function to be called when loading progress changes
  5010. */
  5011. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5012. /**
  5013. * Returns client's state
  5014. */
  5015. readonly readyState: number;
  5016. /**
  5017. * Returns client's status
  5018. */
  5019. readonly status: number;
  5020. /**
  5021. * Returns client's status as a text
  5022. */
  5023. readonly statusText: string;
  5024. /**
  5025. * Returns client's response
  5026. */
  5027. readonly response: any;
  5028. /**
  5029. * Returns client's response url
  5030. */
  5031. readonly responseURL: string;
  5032. /**
  5033. * Returns client's response as text
  5034. */
  5035. readonly responseText: string;
  5036. /**
  5037. * Gets or sets the expected response type
  5038. */
  5039. responseType: XMLHttpRequestResponseType;
  5040. /** @hidden */
  5041. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5042. /** @hidden */
  5043. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5044. /**
  5045. * Cancels any network activity
  5046. */
  5047. abort(): void;
  5048. /**
  5049. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5050. * @param body defines an optional request body
  5051. */
  5052. send(body?: Document | BodyInit | null): void;
  5053. /**
  5054. * Sets the request method, request URL
  5055. * @param method defines the method to use (GET, POST, etc..)
  5056. * @param url defines the url to connect with
  5057. */
  5058. open(method: string, url: string): void;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to evalaute queries containing `and` and `or` operators
  5064. */
  5065. export class AndOrNotEvaluator {
  5066. /**
  5067. * Evaluate a query
  5068. * @param query defines the query to evaluate
  5069. * @param evaluateCallback defines the callback used to filter result
  5070. * @returns true if the query matches
  5071. */
  5072. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5073. private static _HandleParenthesisContent;
  5074. private static _SimplifyNegation;
  5075. }
  5076. }
  5077. declare module BABYLON {
  5078. /**
  5079. * Class used to store custom tags
  5080. */
  5081. export class Tags {
  5082. /**
  5083. * Adds support for tags on the given object
  5084. * @param obj defines the object to use
  5085. */
  5086. static EnableFor(obj: any): void;
  5087. /**
  5088. * Removes tags support
  5089. * @param obj defines the object to use
  5090. */
  5091. static DisableFor(obj: any): void;
  5092. /**
  5093. * Gets a boolean indicating if the given object has tags
  5094. * @param obj defines the object to use
  5095. * @returns a boolean
  5096. */
  5097. static HasTags(obj: any): boolean;
  5098. /**
  5099. * Gets the tags available on a given object
  5100. * @param obj defines the object to use
  5101. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5102. * @returns the tags
  5103. */
  5104. static GetTags(obj: any, asString?: boolean): any;
  5105. /**
  5106. * Adds tags to an object
  5107. * @param obj defines the object to use
  5108. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5109. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5110. */
  5111. static AddTagsTo(obj: any, tagsString: string): void;
  5112. /**
  5113. * @hidden
  5114. */
  5115. static _AddTagTo(obj: any, tag: string): void;
  5116. /**
  5117. * Removes specific tags from a specific object
  5118. * @param obj defines the object to use
  5119. * @param tagsString defines the tags to remove
  5120. */
  5121. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5122. /**
  5123. * @hidden
  5124. */
  5125. static _RemoveTagFrom(obj: any, tag: string): void;
  5126. /**
  5127. * Defines if tags hosted on an object match a given query
  5128. * @param obj defines the object to use
  5129. * @param tagsQuery defines the tag query
  5130. * @returns a boolean
  5131. */
  5132. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /**
  5137. * Manages the defines for the Material
  5138. */
  5139. export class MaterialDefines {
  5140. private _keys;
  5141. private _isDirty;
  5142. /** @hidden */
  5143. _renderId: number;
  5144. /** @hidden */
  5145. _areLightsDirty: boolean;
  5146. /** @hidden */
  5147. _areAttributesDirty: boolean;
  5148. /** @hidden */
  5149. _areTexturesDirty: boolean;
  5150. /** @hidden */
  5151. _areFresnelDirty: boolean;
  5152. /** @hidden */
  5153. _areMiscDirty: boolean;
  5154. /** @hidden */
  5155. _areImageProcessingDirty: boolean;
  5156. /** @hidden */
  5157. _normals: boolean;
  5158. /** @hidden */
  5159. _uvs: boolean;
  5160. /** @hidden */
  5161. _needNormals: boolean;
  5162. /** @hidden */
  5163. _needUVs: boolean;
  5164. /**
  5165. * Specifies if the material needs to be re-calculated
  5166. */
  5167. readonly isDirty: boolean;
  5168. /**
  5169. * Marks the material to indicate that it has been re-calculated
  5170. */
  5171. markAsProcessed(): void;
  5172. /**
  5173. * Marks the material to indicate that it needs to be re-calculated
  5174. */
  5175. markAsUnprocessed(): void;
  5176. /**
  5177. * Marks the material to indicate all of its defines need to be re-calculated
  5178. */
  5179. markAllAsDirty(): void;
  5180. /**
  5181. * Marks the material to indicate that image processing needs to be re-calculated
  5182. */
  5183. markAsImageProcessingDirty(): void;
  5184. /**
  5185. * Marks the material to indicate the lights need to be re-calculated
  5186. */
  5187. markAsLightDirty(): void;
  5188. /**
  5189. * Marks the attribute state as changed
  5190. */
  5191. markAsAttributesDirty(): void;
  5192. /**
  5193. * Marks the texture state as changed
  5194. */
  5195. markAsTexturesDirty(): void;
  5196. /**
  5197. * Marks the fresnel state as changed
  5198. */
  5199. markAsFresnelDirty(): void;
  5200. /**
  5201. * Marks the misc state as changed
  5202. */
  5203. markAsMiscDirty(): void;
  5204. /**
  5205. * Rebuilds the material defines
  5206. */
  5207. rebuild(): void;
  5208. /**
  5209. * Specifies if two material defines are equal
  5210. * @param other - A material define instance to compare to
  5211. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5212. */
  5213. isEqual(other: MaterialDefines): boolean;
  5214. /**
  5215. * Clones this instance's defines to another instance
  5216. * @param other - material defines to clone values to
  5217. */
  5218. cloneTo(other: MaterialDefines): void;
  5219. /**
  5220. * Resets the material define values
  5221. */
  5222. reset(): void;
  5223. /**
  5224. * Converts the material define values to a string
  5225. * @returns - String of material define information
  5226. */
  5227. toString(): string;
  5228. }
  5229. }
  5230. declare module BABYLON {
  5231. /**
  5232. * Class used to store and describe the pipeline context associated with an effect
  5233. */
  5234. export interface IPipelineContext {
  5235. /**
  5236. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5237. */
  5238. isAsync: boolean;
  5239. /**
  5240. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5241. */
  5242. isReady: boolean;
  5243. /** @hidden */
  5244. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5245. }
  5246. }
  5247. declare module BABYLON {
  5248. /**
  5249. * Class used to store gfx data (like WebGLBuffer)
  5250. */
  5251. export class DataBuffer {
  5252. /**
  5253. * Gets or sets the number of objects referencing this buffer
  5254. */
  5255. references: number;
  5256. /** Gets or sets the size of the underlying buffer */
  5257. capacity: number;
  5258. /**
  5259. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5260. */
  5261. is32Bits: boolean;
  5262. /**
  5263. * Gets the underlying buffer
  5264. */
  5265. readonly underlyingResource: any;
  5266. }
  5267. }
  5268. declare module BABYLON {
  5269. /**
  5270. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5271. */
  5272. export class PerformanceMonitor {
  5273. private _enabled;
  5274. private _rollingFrameTime;
  5275. private _lastFrameTimeMs;
  5276. /**
  5277. * constructor
  5278. * @param frameSampleSize The number of samples required to saturate the sliding window
  5279. */
  5280. constructor(frameSampleSize?: number);
  5281. /**
  5282. * Samples current frame
  5283. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5284. */
  5285. sampleFrame(timeMs?: number): void;
  5286. /**
  5287. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5288. */
  5289. readonly averageFrameTime: number;
  5290. /**
  5291. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5292. */
  5293. readonly averageFrameTimeVariance: number;
  5294. /**
  5295. * Returns the frame time of the most recent frame
  5296. */
  5297. readonly instantaneousFrameTime: number;
  5298. /**
  5299. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5300. */
  5301. readonly averageFPS: number;
  5302. /**
  5303. * Returns the average framerate in frames per second using the most recent frame time
  5304. */
  5305. readonly instantaneousFPS: number;
  5306. /**
  5307. * Returns true if enough samples have been taken to completely fill the sliding window
  5308. */
  5309. readonly isSaturated: boolean;
  5310. /**
  5311. * Enables contributions to the sliding window sample set
  5312. */
  5313. enable(): void;
  5314. /**
  5315. * Disables contributions to the sliding window sample set
  5316. * Samples will not be interpolated over the disabled period
  5317. */
  5318. disable(): void;
  5319. /**
  5320. * Returns true if sampling is enabled
  5321. */
  5322. readonly isEnabled: boolean;
  5323. /**
  5324. * Resets performance monitor
  5325. */
  5326. reset(): void;
  5327. }
  5328. /**
  5329. * RollingAverage
  5330. *
  5331. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5332. */
  5333. export class RollingAverage {
  5334. /**
  5335. * Current average
  5336. */
  5337. average: number;
  5338. /**
  5339. * Current variance
  5340. */
  5341. variance: number;
  5342. protected _samples: Array<number>;
  5343. protected _sampleCount: number;
  5344. protected _pos: number;
  5345. protected _m2: number;
  5346. /**
  5347. * constructor
  5348. * @param length The number of samples required to saturate the sliding window
  5349. */
  5350. constructor(length: number);
  5351. /**
  5352. * Adds a sample to the sample set
  5353. * @param v The sample value
  5354. */
  5355. add(v: number): void;
  5356. /**
  5357. * Returns previously added values or null if outside of history or outside the sliding window domain
  5358. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5359. * @return Value previously recorded with add() or null if outside of range
  5360. */
  5361. history(i: number): number;
  5362. /**
  5363. * Returns true if enough samples have been taken to completely fill the sliding window
  5364. * @return true if sample-set saturated
  5365. */
  5366. isSaturated(): boolean;
  5367. /**
  5368. * Resets the rolling average (equivalent to 0 samples taken so far)
  5369. */
  5370. reset(): void;
  5371. /**
  5372. * Wraps a value around the sample range boundaries
  5373. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5374. * @return Wrapped position in sample range
  5375. */
  5376. protected _wrapPosition(i: number): number;
  5377. }
  5378. }
  5379. declare module BABYLON {
  5380. /**
  5381. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5382. * The underlying implementation relies on an associative array to ensure the best performances.
  5383. * The value can be anything including 'null' but except 'undefined'
  5384. */
  5385. export class StringDictionary<T> {
  5386. /**
  5387. * This will clear this dictionary and copy the content from the 'source' one.
  5388. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5389. * @param source the dictionary to take the content from and copy to this dictionary
  5390. */
  5391. copyFrom(source: StringDictionary<T>): void;
  5392. /**
  5393. * Get a value based from its key
  5394. * @param key the given key to get the matching value from
  5395. * @return the value if found, otherwise undefined is returned
  5396. */
  5397. get(key: string): T | undefined;
  5398. /**
  5399. * Get a value from its key or add it if it doesn't exist.
  5400. * This method will ensure you that a given key/data will be present in the dictionary.
  5401. * @param key the given key to get the matching value from
  5402. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5403. * The factory will only be invoked if there's no data for the given key.
  5404. * @return the value corresponding to the key.
  5405. */
  5406. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5407. /**
  5408. * Get a value from its key if present in the dictionary otherwise add it
  5409. * @param key the key to get the value from
  5410. * @param val if there's no such key/value pair in the dictionary add it with this value
  5411. * @return the value corresponding to the key
  5412. */
  5413. getOrAdd(key: string, val: T): T;
  5414. /**
  5415. * Check if there's a given key in the dictionary
  5416. * @param key the key to check for
  5417. * @return true if the key is present, false otherwise
  5418. */
  5419. contains(key: string): boolean;
  5420. /**
  5421. * Add a new key and its corresponding value
  5422. * @param key the key to add
  5423. * @param value the value corresponding to the key
  5424. * @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
  5425. */
  5426. add(key: string, value: T): boolean;
  5427. /**
  5428. * Update a specific value associated to a key
  5429. * @param key defines the key to use
  5430. * @param value defines the value to store
  5431. * @returns true if the value was updated (or false if the key was not found)
  5432. */
  5433. set(key: string, value: T): boolean;
  5434. /**
  5435. * Get the element of the given key and remove it from the dictionary
  5436. * @param key defines the key to search
  5437. * @returns the value associated with the key or null if not found
  5438. */
  5439. getAndRemove(key: string): Nullable<T>;
  5440. /**
  5441. * Remove a key/value from the dictionary.
  5442. * @param key the key to remove
  5443. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5444. */
  5445. remove(key: string): boolean;
  5446. /**
  5447. * Clear the whole content of the dictionary
  5448. */
  5449. clear(): void;
  5450. /**
  5451. * Gets the current count
  5452. */
  5453. readonly count: number;
  5454. /**
  5455. * Execute a callback on each key/val of the dictionary.
  5456. * Note that you can remove any element in this dictionary in the callback implementation
  5457. * @param callback the callback to execute on a given key/value pair
  5458. */
  5459. forEach(callback: (key: string, val: T) => void): void;
  5460. /**
  5461. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5462. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5463. * Note that you can remove any element in this dictionary in the callback implementation
  5464. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5465. * @returns the first item
  5466. */
  5467. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5468. private _count;
  5469. private _data;
  5470. }
  5471. }
  5472. declare module BABYLON {
  5473. /**
  5474. * Helper class that provides a small promise polyfill
  5475. */
  5476. export class PromisePolyfill {
  5477. /**
  5478. * Static function used to check if the polyfill is required
  5479. * If this is the case then the function will inject the polyfill to window.Promise
  5480. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5481. */
  5482. static Apply(force?: boolean): void;
  5483. }
  5484. }
  5485. declare module BABYLON {
  5486. /**
  5487. * Class used to store data that will be store in GPU memory
  5488. */
  5489. export class Buffer {
  5490. private _engine;
  5491. private _buffer;
  5492. /** @hidden */
  5493. _data: Nullable<DataArray>;
  5494. private _updatable;
  5495. private _instanced;
  5496. /**
  5497. * Gets the byte stride.
  5498. */
  5499. readonly byteStride: number;
  5500. /**
  5501. * Constructor
  5502. * @param engine the engine
  5503. * @param data the data to use for this buffer
  5504. * @param updatable whether the data is updatable
  5505. * @param stride the stride (optional)
  5506. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5507. * @param instanced whether the buffer is instanced (optional)
  5508. * @param useBytes set to true if the stride in in bytes (optional)
  5509. */
  5510. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5511. /**
  5512. * Create a new VertexBuffer based on the current buffer
  5513. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5514. * @param offset defines offset in the buffer (0 by default)
  5515. * @param size defines the size in floats of attributes (position is 3 for instance)
  5516. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5517. * @param instanced defines if the vertex buffer contains indexed data
  5518. * @param useBytes defines if the offset and stride are in bytes
  5519. * @returns the new vertex buffer
  5520. */
  5521. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5522. /**
  5523. * Gets a boolean indicating if the Buffer is updatable?
  5524. * @returns true if the buffer is updatable
  5525. */
  5526. isUpdatable(): boolean;
  5527. /**
  5528. * Gets current buffer's data
  5529. * @returns a DataArray or null
  5530. */
  5531. getData(): Nullable<DataArray>;
  5532. /**
  5533. * Gets underlying native buffer
  5534. * @returns underlying native buffer
  5535. */
  5536. getBuffer(): Nullable<DataBuffer>;
  5537. /**
  5538. * Gets the stride in float32 units (i.e. byte stride / 4).
  5539. * May not be an integer if the byte stride is not divisible by 4.
  5540. * DEPRECATED. Use byteStride instead.
  5541. * @returns the stride in float32 units
  5542. */
  5543. getStrideSize(): number;
  5544. /**
  5545. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5546. * @param data defines the data to store
  5547. */
  5548. create(data?: Nullable<DataArray>): void;
  5549. /** @hidden */
  5550. _rebuild(): void;
  5551. /**
  5552. * Update current buffer data
  5553. * @param data defines the data to store
  5554. */
  5555. update(data: DataArray): void;
  5556. /**
  5557. * Updates the data directly.
  5558. * @param data the new data
  5559. * @param offset the new offset
  5560. * @param vertexCount the vertex count (optional)
  5561. * @param useBytes set to true if the offset is in bytes
  5562. */
  5563. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5564. /**
  5565. * Release all resources
  5566. */
  5567. dispose(): void;
  5568. }
  5569. /**
  5570. * Specialized buffer used to store vertex data
  5571. */
  5572. export class VertexBuffer {
  5573. /** @hidden */
  5574. _buffer: Buffer;
  5575. private _kind;
  5576. private _size;
  5577. private _ownsBuffer;
  5578. private _instanced;
  5579. private _instanceDivisor;
  5580. /**
  5581. * The byte type.
  5582. */
  5583. static readonly BYTE: number;
  5584. /**
  5585. * The unsigned byte type.
  5586. */
  5587. static readonly UNSIGNED_BYTE: number;
  5588. /**
  5589. * The short type.
  5590. */
  5591. static readonly SHORT: number;
  5592. /**
  5593. * The unsigned short type.
  5594. */
  5595. static readonly UNSIGNED_SHORT: number;
  5596. /**
  5597. * The integer type.
  5598. */
  5599. static readonly INT: number;
  5600. /**
  5601. * The unsigned integer type.
  5602. */
  5603. static readonly UNSIGNED_INT: number;
  5604. /**
  5605. * The float type.
  5606. */
  5607. static readonly FLOAT: number;
  5608. /**
  5609. * Gets or sets the instance divisor when in instanced mode
  5610. */
  5611. instanceDivisor: number;
  5612. /**
  5613. * Gets the byte stride.
  5614. */
  5615. readonly byteStride: number;
  5616. /**
  5617. * Gets the byte offset.
  5618. */
  5619. readonly byteOffset: number;
  5620. /**
  5621. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5622. */
  5623. readonly normalized: boolean;
  5624. /**
  5625. * Gets the data type of each component in the array.
  5626. */
  5627. readonly type: number;
  5628. /**
  5629. * Constructor
  5630. * @param engine the engine
  5631. * @param data the data to use for this vertex buffer
  5632. * @param kind the vertex buffer kind
  5633. * @param updatable whether the data is updatable
  5634. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5635. * @param stride the stride (optional)
  5636. * @param instanced whether the buffer is instanced (optional)
  5637. * @param offset the offset of the data (optional)
  5638. * @param size the number of components (optional)
  5639. * @param type the type of the component (optional)
  5640. * @param normalized whether the data contains normalized data (optional)
  5641. * @param useBytes set to true if stride and offset are in bytes (optional)
  5642. */
  5643. 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);
  5644. /** @hidden */
  5645. _rebuild(): void;
  5646. /**
  5647. * Returns the kind of the VertexBuffer (string)
  5648. * @returns a string
  5649. */
  5650. getKind(): string;
  5651. /**
  5652. * Gets a boolean indicating if the VertexBuffer is updatable?
  5653. * @returns true if the buffer is updatable
  5654. */
  5655. isUpdatable(): boolean;
  5656. /**
  5657. * Gets current buffer's data
  5658. * @returns a DataArray or null
  5659. */
  5660. getData(): Nullable<DataArray>;
  5661. /**
  5662. * Gets underlying native buffer
  5663. * @returns underlying native buffer
  5664. */
  5665. getBuffer(): Nullable<DataBuffer>;
  5666. /**
  5667. * Gets the stride in float32 units (i.e. byte stride / 4).
  5668. * May not be an integer if the byte stride is not divisible by 4.
  5669. * DEPRECATED. Use byteStride instead.
  5670. * @returns the stride in float32 units
  5671. */
  5672. getStrideSize(): number;
  5673. /**
  5674. * Returns the offset as a multiple of the type byte length.
  5675. * DEPRECATED. Use byteOffset instead.
  5676. * @returns the offset in bytes
  5677. */
  5678. getOffset(): number;
  5679. /**
  5680. * Returns the number of components per vertex attribute (integer)
  5681. * @returns the size in float
  5682. */
  5683. getSize(): number;
  5684. /**
  5685. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5686. * @returns true if this buffer is instanced
  5687. */
  5688. getIsInstanced(): boolean;
  5689. /**
  5690. * Returns the instancing divisor, zero for non-instanced (integer).
  5691. * @returns a number
  5692. */
  5693. getInstanceDivisor(): number;
  5694. /**
  5695. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5696. * @param data defines the data to store
  5697. */
  5698. create(data?: DataArray): void;
  5699. /**
  5700. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5701. * This function will create a new buffer if the current one is not updatable
  5702. * @param data defines the data to store
  5703. */
  5704. update(data: DataArray): void;
  5705. /**
  5706. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5707. * Returns the directly updated WebGLBuffer.
  5708. * @param data the new data
  5709. * @param offset the new offset
  5710. * @param useBytes set to true if the offset is in bytes
  5711. */
  5712. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5713. /**
  5714. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5715. */
  5716. dispose(): void;
  5717. /**
  5718. * Enumerates each value of this vertex buffer as numbers.
  5719. * @param count the number of values to enumerate
  5720. * @param callback the callback function called for each value
  5721. */
  5722. forEach(count: number, callback: (value: number, index: number) => void): void;
  5723. /**
  5724. * Positions
  5725. */
  5726. static readonly PositionKind: string;
  5727. /**
  5728. * Normals
  5729. */
  5730. static readonly NormalKind: string;
  5731. /**
  5732. * Tangents
  5733. */
  5734. static readonly TangentKind: string;
  5735. /**
  5736. * Texture coordinates
  5737. */
  5738. static readonly UVKind: string;
  5739. /**
  5740. * Texture coordinates 2
  5741. */
  5742. static readonly UV2Kind: string;
  5743. /**
  5744. * Texture coordinates 3
  5745. */
  5746. static readonly UV3Kind: string;
  5747. /**
  5748. * Texture coordinates 4
  5749. */
  5750. static readonly UV4Kind: string;
  5751. /**
  5752. * Texture coordinates 5
  5753. */
  5754. static readonly UV5Kind: string;
  5755. /**
  5756. * Texture coordinates 6
  5757. */
  5758. static readonly UV6Kind: string;
  5759. /**
  5760. * Colors
  5761. */
  5762. static readonly ColorKind: string;
  5763. /**
  5764. * Matrix indices (for bones)
  5765. */
  5766. static readonly MatricesIndicesKind: string;
  5767. /**
  5768. * Matrix weights (for bones)
  5769. */
  5770. static readonly MatricesWeightsKind: string;
  5771. /**
  5772. * Additional matrix indices (for bones)
  5773. */
  5774. static readonly MatricesIndicesExtraKind: string;
  5775. /**
  5776. * Additional matrix weights (for bones)
  5777. */
  5778. static readonly MatricesWeightsExtraKind: string;
  5779. /**
  5780. * Deduces the stride given a kind.
  5781. * @param kind The kind string to deduce
  5782. * @returns The deduced stride
  5783. */
  5784. static DeduceStride(kind: string): number;
  5785. /**
  5786. * Gets the byte length of the given type.
  5787. * @param type the type
  5788. * @returns the number of bytes
  5789. */
  5790. static GetTypeByteLength(type: number): number;
  5791. /**
  5792. * Enumerates each value of the given parameters as numbers.
  5793. * @param data the data to enumerate
  5794. * @param byteOffset the byte offset of the data
  5795. * @param byteStride the byte stride of the data
  5796. * @param componentCount the number of components per element
  5797. * @param componentType the type of the component
  5798. * @param count the total number of components
  5799. * @param normalized whether the data is normalized
  5800. * @param callback the callback function called for each value
  5801. */
  5802. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5803. private static _GetFloatValue;
  5804. }
  5805. }
  5806. declare module BABYLON {
  5807. /**
  5808. * Class representing spherical harmonics coefficients to the 3rd degree
  5809. */
  5810. export class SphericalHarmonics {
  5811. /**
  5812. * Defines whether or not the harmonics have been prescaled for rendering.
  5813. */
  5814. preScaled: boolean;
  5815. /**
  5816. * The l0,0 coefficients of the spherical harmonics
  5817. */
  5818. l00: Vector3;
  5819. /**
  5820. * The l1,-1 coefficients of the spherical harmonics
  5821. */
  5822. l1_1: Vector3;
  5823. /**
  5824. * The l1,0 coefficients of the spherical harmonics
  5825. */
  5826. l10: Vector3;
  5827. /**
  5828. * The l1,1 coefficients of the spherical harmonics
  5829. */
  5830. l11: Vector3;
  5831. /**
  5832. * The l2,-2 coefficients of the spherical harmonics
  5833. */
  5834. l2_2: Vector3;
  5835. /**
  5836. * The l2,-1 coefficients of the spherical harmonics
  5837. */
  5838. l2_1: Vector3;
  5839. /**
  5840. * The l2,0 coefficients of the spherical harmonics
  5841. */
  5842. l20: Vector3;
  5843. /**
  5844. * The l2,1 coefficients of the spherical harmonics
  5845. */
  5846. l21: Vector3;
  5847. /**
  5848. * The l2,2 coefficients of the spherical harmonics
  5849. */
  5850. l22: Vector3;
  5851. /**
  5852. * Adds a light to the spherical harmonics
  5853. * @param direction the direction of the light
  5854. * @param color the color of the light
  5855. * @param deltaSolidAngle the delta solid angle of the light
  5856. */
  5857. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5858. /**
  5859. * Scales the spherical harmonics by the given amount
  5860. * @param scale the amount to scale
  5861. */
  5862. scaleInPlace(scale: number): void;
  5863. /**
  5864. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5865. *
  5866. * ```
  5867. * E_lm = A_l * L_lm
  5868. * ```
  5869. *
  5870. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5871. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5872. * the scaling factors are given in equation 9.
  5873. */
  5874. convertIncidentRadianceToIrradiance(): void;
  5875. /**
  5876. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5877. *
  5878. * ```
  5879. * L = (1/pi) * E * rho
  5880. * ```
  5881. *
  5882. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5883. */
  5884. convertIrradianceToLambertianRadiance(): void;
  5885. /**
  5886. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5887. * required operations at run time.
  5888. *
  5889. * This is simply done by scaling back the SH with Ylm constants parameter.
  5890. * The trigonometric part being applied by the shader at run time.
  5891. */
  5892. preScaleForRendering(): void;
  5893. /**
  5894. * Constructs a spherical harmonics from an array.
  5895. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5896. * @returns the spherical harmonics
  5897. */
  5898. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5899. /**
  5900. * Gets the spherical harmonics from polynomial
  5901. * @param polynomial the spherical polynomial
  5902. * @returns the spherical harmonics
  5903. */
  5904. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5905. }
  5906. /**
  5907. * Class representing spherical polynomial coefficients to the 3rd degree
  5908. */
  5909. export class SphericalPolynomial {
  5910. private _harmonics;
  5911. /**
  5912. * The spherical harmonics used to create the polynomials.
  5913. */
  5914. readonly preScaledHarmonics: SphericalHarmonics;
  5915. /**
  5916. * The x coefficients of the spherical polynomial
  5917. */
  5918. x: Vector3;
  5919. /**
  5920. * The y coefficients of the spherical polynomial
  5921. */
  5922. y: Vector3;
  5923. /**
  5924. * The z coefficients of the spherical polynomial
  5925. */
  5926. z: Vector3;
  5927. /**
  5928. * The xx coefficients of the spherical polynomial
  5929. */
  5930. xx: Vector3;
  5931. /**
  5932. * The yy coefficients of the spherical polynomial
  5933. */
  5934. yy: Vector3;
  5935. /**
  5936. * The zz coefficients of the spherical polynomial
  5937. */
  5938. zz: Vector3;
  5939. /**
  5940. * The xy coefficients of the spherical polynomial
  5941. */
  5942. xy: Vector3;
  5943. /**
  5944. * The yz coefficients of the spherical polynomial
  5945. */
  5946. yz: Vector3;
  5947. /**
  5948. * The zx coefficients of the spherical polynomial
  5949. */
  5950. zx: Vector3;
  5951. /**
  5952. * Adds an ambient color to the spherical polynomial
  5953. * @param color the color to add
  5954. */
  5955. addAmbient(color: Color3): void;
  5956. /**
  5957. * Scales the spherical polynomial by the given amount
  5958. * @param scale the amount to scale
  5959. */
  5960. scaleInPlace(scale: number): void;
  5961. /**
  5962. * Gets the spherical polynomial from harmonics
  5963. * @param harmonics the spherical harmonics
  5964. * @returns the spherical polynomial
  5965. */
  5966. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5967. /**
  5968. * Constructs a spherical polynomial from an array.
  5969. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5970. * @returns the spherical polynomial
  5971. */
  5972. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5978. */
  5979. export interface CubeMapInfo {
  5980. /**
  5981. * The pixel array for the front face.
  5982. * This is stored in format, left to right, up to down format.
  5983. */
  5984. front: Nullable<ArrayBufferView>;
  5985. /**
  5986. * The pixel array for the back face.
  5987. * This is stored in format, left to right, up to down format.
  5988. */
  5989. back: Nullable<ArrayBufferView>;
  5990. /**
  5991. * The pixel array for the left face.
  5992. * This is stored in format, left to right, up to down format.
  5993. */
  5994. left: Nullable<ArrayBufferView>;
  5995. /**
  5996. * The pixel array for the right face.
  5997. * This is stored in format, left to right, up to down format.
  5998. */
  5999. right: Nullable<ArrayBufferView>;
  6000. /**
  6001. * The pixel array for the up face.
  6002. * This is stored in format, left to right, up to down format.
  6003. */
  6004. up: Nullable<ArrayBufferView>;
  6005. /**
  6006. * The pixel array for the down face.
  6007. * This is stored in format, left to right, up to down format.
  6008. */
  6009. down: Nullable<ArrayBufferView>;
  6010. /**
  6011. * The size of the cubemap stored.
  6012. *
  6013. * Each faces will be size * size pixels.
  6014. */
  6015. size: number;
  6016. /**
  6017. * The format of the texture.
  6018. *
  6019. * RGBA, RGB.
  6020. */
  6021. format: number;
  6022. /**
  6023. * The type of the texture data.
  6024. *
  6025. * UNSIGNED_INT, FLOAT.
  6026. */
  6027. type: number;
  6028. /**
  6029. * Specifies whether the texture is in gamma space.
  6030. */
  6031. gammaSpace: boolean;
  6032. }
  6033. /**
  6034. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6035. */
  6036. export class PanoramaToCubeMapTools {
  6037. private static FACE_FRONT;
  6038. private static FACE_BACK;
  6039. private static FACE_RIGHT;
  6040. private static FACE_LEFT;
  6041. private static FACE_DOWN;
  6042. private static FACE_UP;
  6043. /**
  6044. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6045. *
  6046. * @param float32Array The source data.
  6047. * @param inputWidth The width of the input panorama.
  6048. * @param inputHeight The height of the input panorama.
  6049. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6050. * @return The cubemap data
  6051. */
  6052. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6053. private static CreateCubemapTexture;
  6054. private static CalcProjectionSpherical;
  6055. }
  6056. }
  6057. declare module BABYLON {
  6058. /**
  6059. * Helper class dealing with the extraction of spherical polynomial dataArray
  6060. * from a cube map.
  6061. */
  6062. export class CubeMapToSphericalPolynomialTools {
  6063. private static FileFaces;
  6064. /**
  6065. * Converts a texture to the according Spherical Polynomial data.
  6066. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6067. *
  6068. * @param texture The texture to extract the information from.
  6069. * @return The Spherical Polynomial data.
  6070. */
  6071. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6072. /**
  6073. * Converts a cubemap to the according Spherical Polynomial data.
  6074. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6075. *
  6076. * @param cubeInfo The Cube map to extract the information from.
  6077. * @return The Spherical Polynomial data.
  6078. */
  6079. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6085. * during the life time of the application.
  6086. */
  6087. export class EngineStore {
  6088. /** Gets the list of created engines */
  6089. static Instances: Engine[];
  6090. /** @hidden */
  6091. static _LastCreatedScene: Nullable<Scene>;
  6092. /**
  6093. * Gets the latest created engine
  6094. */
  6095. static readonly LastCreatedEngine: Nullable<Engine>;
  6096. /**
  6097. * Gets the latest created scene
  6098. */
  6099. static readonly LastCreatedScene: Nullable<Scene>;
  6100. }
  6101. }
  6102. declare module BABYLON {
  6103. /**
  6104. * Define options used to create a render target texture
  6105. */
  6106. export class RenderTargetCreationOptions {
  6107. /**
  6108. * Specifies is mipmaps must be generated
  6109. */
  6110. generateMipMaps?: boolean;
  6111. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6112. generateDepthBuffer?: boolean;
  6113. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6114. generateStencilBuffer?: boolean;
  6115. /** Defines texture type (int by default) */
  6116. type?: number;
  6117. /** Defines sampling mode (trilinear by default) */
  6118. samplingMode?: number;
  6119. /** Defines format (RGBA by default) */
  6120. format?: number;
  6121. }
  6122. }
  6123. declare module BABYLON {
  6124. /**
  6125. * @hidden
  6126. **/
  6127. export class _AlphaState {
  6128. private _isAlphaBlendDirty;
  6129. private _isBlendFunctionParametersDirty;
  6130. private _isBlendEquationParametersDirty;
  6131. private _isBlendConstantsDirty;
  6132. private _alphaBlend;
  6133. private _blendFunctionParameters;
  6134. private _blendEquationParameters;
  6135. private _blendConstants;
  6136. /**
  6137. * Initializes the state.
  6138. */
  6139. constructor();
  6140. readonly isDirty: boolean;
  6141. alphaBlend: boolean;
  6142. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6143. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6144. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6145. reset(): void;
  6146. apply(gl: WebGLRenderingContext): void;
  6147. }
  6148. }
  6149. declare module BABYLON {
  6150. /**
  6151. * @hidden
  6152. **/
  6153. export class _DepthCullingState {
  6154. private _isDepthTestDirty;
  6155. private _isDepthMaskDirty;
  6156. private _isDepthFuncDirty;
  6157. private _isCullFaceDirty;
  6158. private _isCullDirty;
  6159. private _isZOffsetDirty;
  6160. private _isFrontFaceDirty;
  6161. private _depthTest;
  6162. private _depthMask;
  6163. private _depthFunc;
  6164. private _cull;
  6165. private _cullFace;
  6166. private _zOffset;
  6167. private _frontFace;
  6168. /**
  6169. * Initializes the state.
  6170. */
  6171. constructor();
  6172. readonly isDirty: boolean;
  6173. zOffset: number;
  6174. cullFace: Nullable<number>;
  6175. cull: Nullable<boolean>;
  6176. depthFunc: Nullable<number>;
  6177. depthMask: boolean;
  6178. depthTest: boolean;
  6179. frontFace: Nullable<number>;
  6180. reset(): void;
  6181. apply(gl: WebGLRenderingContext): void;
  6182. }
  6183. }
  6184. declare module BABYLON {
  6185. /**
  6186. * @hidden
  6187. **/
  6188. export class _StencilState {
  6189. /** 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 */
  6190. static readonly ALWAYS: number;
  6191. /** Passed to stencilOperation to specify that stencil value must be kept */
  6192. static readonly KEEP: number;
  6193. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6194. static readonly REPLACE: number;
  6195. private _isStencilTestDirty;
  6196. private _isStencilMaskDirty;
  6197. private _isStencilFuncDirty;
  6198. private _isStencilOpDirty;
  6199. private _stencilTest;
  6200. private _stencilMask;
  6201. private _stencilFunc;
  6202. private _stencilFuncRef;
  6203. private _stencilFuncMask;
  6204. private _stencilOpStencilFail;
  6205. private _stencilOpDepthFail;
  6206. private _stencilOpStencilDepthPass;
  6207. readonly isDirty: boolean;
  6208. stencilFunc: number;
  6209. stencilFuncRef: number;
  6210. stencilFuncMask: number;
  6211. stencilOpStencilFail: number;
  6212. stencilOpDepthFail: number;
  6213. stencilOpStencilDepthPass: number;
  6214. stencilMask: number;
  6215. stencilTest: boolean;
  6216. constructor();
  6217. reset(): void;
  6218. apply(gl: WebGLRenderingContext): void;
  6219. }
  6220. }
  6221. declare module BABYLON {
  6222. /**
  6223. * @hidden
  6224. **/
  6225. export class _TimeToken {
  6226. _startTimeQuery: Nullable<WebGLQuery>;
  6227. _endTimeQuery: Nullable<WebGLQuery>;
  6228. _timeElapsedQuery: Nullable<WebGLQuery>;
  6229. _timeElapsedQueryEnded: boolean;
  6230. }
  6231. }
  6232. declare module BABYLON {
  6233. /**
  6234. * Class used to store data associated with WebGL texture data for the engine
  6235. * This class should not be used directly
  6236. */
  6237. export class InternalTexture {
  6238. /** hidden */
  6239. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6240. /**
  6241. * The source of the texture data is unknown
  6242. */
  6243. static DATASOURCE_UNKNOWN: number;
  6244. /**
  6245. * Texture data comes from an URL
  6246. */
  6247. static DATASOURCE_URL: number;
  6248. /**
  6249. * Texture data is only used for temporary storage
  6250. */
  6251. static DATASOURCE_TEMP: number;
  6252. /**
  6253. * Texture data comes from raw data (ArrayBuffer)
  6254. */
  6255. static DATASOURCE_RAW: number;
  6256. /**
  6257. * Texture content is dynamic (video or dynamic texture)
  6258. */
  6259. static DATASOURCE_DYNAMIC: number;
  6260. /**
  6261. * Texture content is generated by rendering to it
  6262. */
  6263. static DATASOURCE_RENDERTARGET: number;
  6264. /**
  6265. * Texture content is part of a multi render target process
  6266. */
  6267. static DATASOURCE_MULTIRENDERTARGET: number;
  6268. /**
  6269. * Texture data comes from a cube data file
  6270. */
  6271. static DATASOURCE_CUBE: number;
  6272. /**
  6273. * Texture data comes from a raw cube data
  6274. */
  6275. static DATASOURCE_CUBERAW: number;
  6276. /**
  6277. * Texture data come from a prefiltered cube data file
  6278. */
  6279. static DATASOURCE_CUBEPREFILTERED: number;
  6280. /**
  6281. * Texture content is raw 3D data
  6282. */
  6283. static DATASOURCE_RAW3D: number;
  6284. /**
  6285. * Texture content is a depth texture
  6286. */
  6287. static DATASOURCE_DEPTHTEXTURE: number;
  6288. /**
  6289. * Texture data comes from a raw cube data encoded with RGBD
  6290. */
  6291. static DATASOURCE_CUBERAW_RGBD: number;
  6292. /**
  6293. * Defines if the texture is ready
  6294. */
  6295. isReady: boolean;
  6296. /**
  6297. * Defines if the texture is a cube texture
  6298. */
  6299. isCube: boolean;
  6300. /**
  6301. * Defines if the texture contains 3D data
  6302. */
  6303. is3D: boolean;
  6304. /**
  6305. * Defines if the texture contains multiview data
  6306. */
  6307. isMultiview: boolean;
  6308. /**
  6309. * Gets the URL used to load this texture
  6310. */
  6311. url: string;
  6312. /**
  6313. * Gets the sampling mode of the texture
  6314. */
  6315. samplingMode: number;
  6316. /**
  6317. * Gets a boolean indicating if the texture needs mipmaps generation
  6318. */
  6319. generateMipMaps: boolean;
  6320. /**
  6321. * Gets the number of samples used by the texture (WebGL2+ only)
  6322. */
  6323. samples: number;
  6324. /**
  6325. * Gets the type of the texture (int, float...)
  6326. */
  6327. type: number;
  6328. /**
  6329. * Gets the format of the texture (RGB, RGBA...)
  6330. */
  6331. format: number;
  6332. /**
  6333. * Observable called when the texture is loaded
  6334. */
  6335. onLoadedObservable: Observable<InternalTexture>;
  6336. /**
  6337. * Gets the width of the texture
  6338. */
  6339. width: number;
  6340. /**
  6341. * Gets the height of the texture
  6342. */
  6343. height: number;
  6344. /**
  6345. * Gets the depth of the texture
  6346. */
  6347. depth: number;
  6348. /**
  6349. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6350. */
  6351. baseWidth: number;
  6352. /**
  6353. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6354. */
  6355. baseHeight: number;
  6356. /**
  6357. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6358. */
  6359. baseDepth: number;
  6360. /**
  6361. * Gets a boolean indicating if the texture is inverted on Y axis
  6362. */
  6363. invertY: boolean;
  6364. /** @hidden */
  6365. _invertVScale: boolean;
  6366. /** @hidden */
  6367. _associatedChannel: number;
  6368. /** @hidden */
  6369. _dataSource: number;
  6370. /** @hidden */
  6371. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6372. /** @hidden */
  6373. _bufferView: Nullable<ArrayBufferView>;
  6374. /** @hidden */
  6375. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6376. /** @hidden */
  6377. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6378. /** @hidden */
  6379. _size: number;
  6380. /** @hidden */
  6381. _extension: string;
  6382. /** @hidden */
  6383. _files: Nullable<string[]>;
  6384. /** @hidden */
  6385. _workingCanvas: Nullable<HTMLCanvasElement>;
  6386. /** @hidden */
  6387. _workingContext: Nullable<CanvasRenderingContext2D>;
  6388. /** @hidden */
  6389. _framebuffer: Nullable<WebGLFramebuffer>;
  6390. /** @hidden */
  6391. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6392. /** @hidden */
  6393. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6394. /** @hidden */
  6395. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6396. /** @hidden */
  6397. _attachments: Nullable<number[]>;
  6398. /** @hidden */
  6399. _cachedCoordinatesMode: Nullable<number>;
  6400. /** @hidden */
  6401. _cachedWrapU: Nullable<number>;
  6402. /** @hidden */
  6403. _cachedWrapV: Nullable<number>;
  6404. /** @hidden */
  6405. _cachedWrapR: Nullable<number>;
  6406. /** @hidden */
  6407. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6408. /** @hidden */
  6409. _isDisabled: boolean;
  6410. /** @hidden */
  6411. _compression: Nullable<string>;
  6412. /** @hidden */
  6413. _generateStencilBuffer: boolean;
  6414. /** @hidden */
  6415. _generateDepthBuffer: boolean;
  6416. /** @hidden */
  6417. _comparisonFunction: number;
  6418. /** @hidden */
  6419. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6420. /** @hidden */
  6421. _lodGenerationScale: number;
  6422. /** @hidden */
  6423. _lodGenerationOffset: number;
  6424. /** @hidden */
  6425. _colorTextureArray: Nullable<WebGLTexture>;
  6426. /** @hidden */
  6427. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6428. /** @hidden */
  6429. _lodTextureHigh: Nullable<BaseTexture>;
  6430. /** @hidden */
  6431. _lodTextureMid: Nullable<BaseTexture>;
  6432. /** @hidden */
  6433. _lodTextureLow: Nullable<BaseTexture>;
  6434. /** @hidden */
  6435. _isRGBD: boolean;
  6436. /** @hidden */
  6437. _webGLTexture: Nullable<WebGLTexture>;
  6438. /** @hidden */
  6439. _references: number;
  6440. private _engine;
  6441. /**
  6442. * Gets the Engine the texture belongs to.
  6443. * @returns The babylon engine
  6444. */
  6445. getEngine(): Engine;
  6446. /**
  6447. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6448. */
  6449. readonly dataSource: number;
  6450. /**
  6451. * Creates a new InternalTexture
  6452. * @param engine defines the engine to use
  6453. * @param dataSource defines the type of data that will be used
  6454. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6455. */
  6456. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6457. /**
  6458. * Increments the number of references (ie. the number of Texture that point to it)
  6459. */
  6460. incrementReferences(): void;
  6461. /**
  6462. * Change the size of the texture (not the size of the content)
  6463. * @param width defines the new width
  6464. * @param height defines the new height
  6465. * @param depth defines the new depth (1 by default)
  6466. */
  6467. updateSize(width: int, height: int, depth?: int): void;
  6468. /** @hidden */
  6469. _rebuild(): void;
  6470. /** @hidden */
  6471. _swapAndDie(target: InternalTexture): void;
  6472. /**
  6473. * Dispose the current allocated resources
  6474. */
  6475. dispose(): void;
  6476. }
  6477. }
  6478. declare module BABYLON {
  6479. /**
  6480. * This represents the main contract an easing function should follow.
  6481. * Easing functions are used throughout the animation system.
  6482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6483. */
  6484. export interface IEasingFunction {
  6485. /**
  6486. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6487. * of the easing function.
  6488. * The link below provides some of the most common examples of easing functions.
  6489. * @see https://easings.net/
  6490. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6491. * @returns the corresponding value on the curve defined by the easing function
  6492. */
  6493. ease(gradient: number): number;
  6494. }
  6495. /**
  6496. * Base class used for every default easing function.
  6497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6498. */
  6499. export class EasingFunction implements IEasingFunction {
  6500. /**
  6501. * Interpolation follows the mathematical formula associated with the easing function.
  6502. */
  6503. static readonly EASINGMODE_EASEIN: number;
  6504. /**
  6505. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6506. */
  6507. static readonly EASINGMODE_EASEOUT: number;
  6508. /**
  6509. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6510. */
  6511. static readonly EASINGMODE_EASEINOUT: number;
  6512. private _easingMode;
  6513. /**
  6514. * Sets the easing mode of the current function.
  6515. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6516. */
  6517. setEasingMode(easingMode: number): void;
  6518. /**
  6519. * Gets the current easing mode.
  6520. * @returns the easing mode
  6521. */
  6522. getEasingMode(): number;
  6523. /**
  6524. * @hidden
  6525. */
  6526. easeInCore(gradient: number): number;
  6527. /**
  6528. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6529. * of the easing function.
  6530. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6531. * @returns the corresponding value on the curve defined by the easing function
  6532. */
  6533. ease(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a circle shape (see link below).
  6537. * @see https://easings.net/#easeInCirc
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class CircleEase extends EasingFunction implements IEasingFunction {
  6541. /** @hidden */
  6542. easeInCore(gradient: number): number;
  6543. }
  6544. /**
  6545. * Easing function with a ease back shape (see link below).
  6546. * @see https://easings.net/#easeInBack
  6547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6548. */
  6549. export class BackEase extends EasingFunction implements IEasingFunction {
  6550. /** Defines the amplitude of the function */
  6551. amplitude: number;
  6552. /**
  6553. * Instantiates a back ease easing
  6554. * @see https://easings.net/#easeInBack
  6555. * @param amplitude Defines the amplitude of the function
  6556. */
  6557. constructor(
  6558. /** Defines the amplitude of the function */
  6559. amplitude?: number);
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with a bouncing shape (see link below).
  6565. * @see https://easings.net/#easeInBounce
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class BounceEase extends EasingFunction implements IEasingFunction {
  6569. /** Defines the number of bounces */
  6570. bounces: number;
  6571. /** Defines the amplitude of the bounce */
  6572. bounciness: number;
  6573. /**
  6574. * Instantiates a bounce easing
  6575. * @see https://easings.net/#easeInBounce
  6576. * @param bounces Defines the number of bounces
  6577. * @param bounciness Defines the amplitude of the bounce
  6578. */
  6579. constructor(
  6580. /** Defines the number of bounces */
  6581. bounces?: number,
  6582. /** Defines the amplitude of the bounce */
  6583. bounciness?: number);
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a power of 3 shape (see link below).
  6589. * @see https://easings.net/#easeInCubic
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class CubicEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with an elastic shape (see link below).
  6598. * @see https://easings.net/#easeInElastic
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the number of oscillations*/
  6603. oscillations: number;
  6604. /** Defines the amplitude of the oscillations*/
  6605. springiness: number;
  6606. /**
  6607. * Instantiates an elastic easing function
  6608. * @see https://easings.net/#easeInElastic
  6609. * @param oscillations Defines the number of oscillations
  6610. * @param springiness Defines the amplitude of the oscillations
  6611. */
  6612. constructor(
  6613. /** Defines the number of oscillations*/
  6614. oscillations?: number,
  6615. /** Defines the amplitude of the oscillations*/
  6616. springiness?: number);
  6617. /** @hidden */
  6618. easeInCore(gradient: number): number;
  6619. }
  6620. /**
  6621. * Easing function with an exponential shape (see link below).
  6622. * @see https://easings.net/#easeInExpo
  6623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6624. */
  6625. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6626. /** Defines the exponent of the function */
  6627. exponent: number;
  6628. /**
  6629. * Instantiates an exponential easing function
  6630. * @see https://easings.net/#easeInExpo
  6631. * @param exponent Defines the exponent of the function
  6632. */
  6633. constructor(
  6634. /** Defines the exponent of the function */
  6635. exponent?: number);
  6636. /** @hidden */
  6637. easeInCore(gradient: number): number;
  6638. }
  6639. /**
  6640. * Easing function with a power shape (see link below).
  6641. * @see https://easings.net/#easeInQuad
  6642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6643. */
  6644. export class PowerEase extends EasingFunction implements IEasingFunction {
  6645. /** Defines the power of the function */
  6646. power: number;
  6647. /**
  6648. * Instantiates an power base easing function
  6649. * @see https://easings.net/#easeInQuad
  6650. * @param power Defines the power of the function
  6651. */
  6652. constructor(
  6653. /** Defines the power of the function */
  6654. power?: number);
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a power of 2 shape (see link below).
  6660. * @see https://easings.net/#easeInQuad
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a power of 4 shape (see link below).
  6669. * @see https://easings.net/#easeInQuart
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a power of 5 shape (see link below).
  6678. * @see https://easings.net/#easeInQuint
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a sin shape (see link below).
  6687. * @see https://easings.net/#easeInSine
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class SineEase extends EasingFunction implements IEasingFunction {
  6691. /** @hidden */
  6692. easeInCore(gradient: number): number;
  6693. }
  6694. /**
  6695. * Easing function with a bezier shape (see link below).
  6696. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6698. */
  6699. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6700. /** Defines the x component of the start tangent in the bezier curve */
  6701. x1: number;
  6702. /** Defines the y component of the start tangent in the bezier curve */
  6703. y1: number;
  6704. /** Defines the x component of the end tangent in the bezier curve */
  6705. x2: number;
  6706. /** Defines the y component of the end tangent in the bezier curve */
  6707. y2: number;
  6708. /**
  6709. * Instantiates a bezier function
  6710. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6711. * @param x1 Defines the x component of the start tangent in the bezier curve
  6712. * @param y1 Defines the y component of the start tangent in the bezier curve
  6713. * @param x2 Defines the x component of the end tangent in the bezier curve
  6714. * @param y2 Defines the y component of the end tangent in the bezier curve
  6715. */
  6716. constructor(
  6717. /** Defines the x component of the start tangent in the bezier curve */
  6718. x1?: number,
  6719. /** Defines the y component of the start tangent in the bezier curve */
  6720. y1?: number,
  6721. /** Defines the x component of the end tangent in the bezier curve */
  6722. x2?: number,
  6723. /** Defines the y component of the end tangent in the bezier curve */
  6724. y2?: number);
  6725. /** @hidden */
  6726. easeInCore(gradient: number): number;
  6727. }
  6728. }
  6729. declare module BABYLON {
  6730. /**
  6731. * Defines an interface which represents an animation key frame
  6732. */
  6733. export interface IAnimationKey {
  6734. /**
  6735. * Frame of the key frame
  6736. */
  6737. frame: number;
  6738. /**
  6739. * Value at the specifies key frame
  6740. */
  6741. value: any;
  6742. /**
  6743. * The input tangent for the cubic hermite spline
  6744. */
  6745. inTangent?: any;
  6746. /**
  6747. * The output tangent for the cubic hermite spline
  6748. */
  6749. outTangent?: any;
  6750. /**
  6751. * The animation interpolation type
  6752. */
  6753. interpolation?: AnimationKeyInterpolation;
  6754. }
  6755. /**
  6756. * Enum for the animation key frame interpolation type
  6757. */
  6758. export enum AnimationKeyInterpolation {
  6759. /**
  6760. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6761. */
  6762. STEP = 1
  6763. }
  6764. }
  6765. declare module BABYLON {
  6766. /**
  6767. * Represents the range of an animation
  6768. */
  6769. export class AnimationRange {
  6770. /**The name of the animation range**/
  6771. name: string;
  6772. /**The starting frame of the animation */
  6773. from: number;
  6774. /**The ending frame of the animation*/
  6775. to: number;
  6776. /**
  6777. * Initializes the range of an animation
  6778. * @param name The name of the animation range
  6779. * @param from The starting frame of the animation
  6780. * @param to The ending frame of the animation
  6781. */
  6782. constructor(
  6783. /**The name of the animation range**/
  6784. name: string,
  6785. /**The starting frame of the animation */
  6786. from: number,
  6787. /**The ending frame of the animation*/
  6788. to: number);
  6789. /**
  6790. * Makes a copy of the animation range
  6791. * @returns A copy of the animation range
  6792. */
  6793. clone(): AnimationRange;
  6794. }
  6795. }
  6796. declare module BABYLON {
  6797. /**
  6798. * Composed of a frame, and an action function
  6799. */
  6800. export class AnimationEvent {
  6801. /** The frame for which the event is triggered **/
  6802. frame: number;
  6803. /** The event to perform when triggered **/
  6804. action: (currentFrame: number) => void;
  6805. /** Specifies if the event should be triggered only once**/
  6806. onlyOnce?: boolean | undefined;
  6807. /**
  6808. * Specifies if the animation event is done
  6809. */
  6810. isDone: boolean;
  6811. /**
  6812. * Initializes the animation event
  6813. * @param frame The frame for which the event is triggered
  6814. * @param action The event to perform when triggered
  6815. * @param onlyOnce Specifies if the event should be triggered only once
  6816. */
  6817. constructor(
  6818. /** The frame for which the event is triggered **/
  6819. frame: number,
  6820. /** The event to perform when triggered **/
  6821. action: (currentFrame: number) => void,
  6822. /** Specifies if the event should be triggered only once**/
  6823. onlyOnce?: boolean | undefined);
  6824. /** @hidden */
  6825. _clone(): AnimationEvent;
  6826. }
  6827. }
  6828. declare module BABYLON {
  6829. /**
  6830. * Interface used to define a behavior
  6831. */
  6832. export interface Behavior<T> {
  6833. /** gets or sets behavior's name */
  6834. name: string;
  6835. /**
  6836. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6837. */
  6838. init(): void;
  6839. /**
  6840. * Called when the behavior is attached to a target
  6841. * @param target defines the target where the behavior is attached to
  6842. */
  6843. attach(target: T): void;
  6844. /**
  6845. * Called when the behavior is detached from its target
  6846. */
  6847. detach(): void;
  6848. }
  6849. /**
  6850. * Interface implemented by classes supporting behaviors
  6851. */
  6852. export interface IBehaviorAware<T> {
  6853. /**
  6854. * Attach a behavior
  6855. * @param behavior defines the behavior to attach
  6856. * @returns the current host
  6857. */
  6858. addBehavior(behavior: Behavior<T>): T;
  6859. /**
  6860. * Remove a behavior from the current object
  6861. * @param behavior defines the behavior to detach
  6862. * @returns the current host
  6863. */
  6864. removeBehavior(behavior: Behavior<T>): T;
  6865. /**
  6866. * Gets a behavior using its name to search
  6867. * @param name defines the name to search
  6868. * @returns the behavior or null if not found
  6869. */
  6870. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6871. }
  6872. }
  6873. declare module BABYLON {
  6874. /**
  6875. * @hidden
  6876. */
  6877. export class IntersectionInfo {
  6878. bu: Nullable<number>;
  6879. bv: Nullable<number>;
  6880. distance: number;
  6881. faceId: number;
  6882. subMeshId: number;
  6883. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6884. }
  6885. }
  6886. declare module BABYLON {
  6887. /**
  6888. * Class used to store bounding sphere information
  6889. */
  6890. export class BoundingSphere {
  6891. /**
  6892. * Gets the center of the bounding sphere in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in local space
  6897. */
  6898. radius: number;
  6899. /**
  6900. * Gets the center of the bounding sphere in world space
  6901. */
  6902. readonly centerWorld: Vector3;
  6903. /**
  6904. * Radius of the bounding sphere in world space
  6905. */
  6906. radiusWorld: number;
  6907. /**
  6908. * Gets the minimum vector in local space
  6909. */
  6910. readonly minimum: Vector3;
  6911. /**
  6912. * Gets the maximum vector in local space
  6913. */
  6914. readonly maximum: Vector3;
  6915. private _worldMatrix;
  6916. private static readonly TmpVector3;
  6917. /**
  6918. * Creates a new bounding sphere
  6919. * @param min defines the minimum vector (in local space)
  6920. * @param max defines the maximum vector (in local space)
  6921. * @param worldMatrix defines the new world matrix
  6922. */
  6923. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6924. /**
  6925. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6926. * @param min defines the new minimum vector (in local space)
  6927. * @param max defines the new maximum vector (in local space)
  6928. * @param worldMatrix defines the new world matrix
  6929. */
  6930. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Scale the current bounding sphere by applying a scale factor
  6933. * @param factor defines the scale factor to apply
  6934. * @returns the current bounding box
  6935. */
  6936. scale(factor: number): BoundingSphere;
  6937. /**
  6938. * Gets the world matrix of the bounding box
  6939. * @returns a matrix
  6940. */
  6941. getWorldMatrix(): DeepImmutable<Matrix>;
  6942. /** @hidden */
  6943. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6944. /**
  6945. * Tests if the bounding sphere is intersecting the frustum planes
  6946. * @param frustumPlanes defines the frustum planes to test
  6947. * @returns true if there is an intersection
  6948. */
  6949. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6950. /**
  6951. * Tests if the bounding sphere center is in between the frustum planes.
  6952. * Used for optimistic fast inclusion.
  6953. * @param frustumPlanes defines the frustum planes to test
  6954. * @returns true if the sphere center is in between the frustum planes
  6955. */
  6956. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6957. /**
  6958. * Tests if a point is inside the bounding sphere
  6959. * @param point defines the point to test
  6960. * @returns true if the point is inside the bounding sphere
  6961. */
  6962. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Checks if two sphere intersct
  6965. * @param sphere0 sphere 0
  6966. * @param sphere1 sphere 1
  6967. * @returns true if the speres intersect
  6968. */
  6969. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6970. }
  6971. }
  6972. declare module BABYLON {
  6973. /**
  6974. * Class used to store bounding box information
  6975. */
  6976. export class BoundingBox implements ICullable {
  6977. /**
  6978. * Gets the 8 vectors representing the bounding box in local space
  6979. */
  6980. readonly vectors: Vector3[];
  6981. /**
  6982. * Gets the center of the bounding box in local space
  6983. */
  6984. readonly center: Vector3;
  6985. /**
  6986. * Gets the center of the bounding box in world space
  6987. */
  6988. readonly centerWorld: Vector3;
  6989. /**
  6990. * Gets the extend size in local space
  6991. */
  6992. readonly extendSize: Vector3;
  6993. /**
  6994. * Gets the extend size in world space
  6995. */
  6996. readonly extendSizeWorld: Vector3;
  6997. /**
  6998. * Gets the OBB (object bounding box) directions
  6999. */
  7000. readonly directions: Vector3[];
  7001. /**
  7002. * Gets the 8 vectors representing the bounding box in world space
  7003. */
  7004. readonly vectorsWorld: Vector3[];
  7005. /**
  7006. * Gets the minimum vector in world space
  7007. */
  7008. readonly minimumWorld: Vector3;
  7009. /**
  7010. * Gets the maximum vector in world space
  7011. */
  7012. readonly maximumWorld: Vector3;
  7013. /**
  7014. * Gets the minimum vector in local space
  7015. */
  7016. readonly minimum: Vector3;
  7017. /**
  7018. * Gets the maximum vector in local space
  7019. */
  7020. readonly maximum: Vector3;
  7021. private _worldMatrix;
  7022. private static readonly TmpVector3;
  7023. /**
  7024. * @hidden
  7025. */
  7026. _tag: number;
  7027. /**
  7028. * Creates a new bounding box
  7029. * @param min defines the minimum vector (in local space)
  7030. * @param max defines the maximum vector (in local space)
  7031. * @param worldMatrix defines the new world matrix
  7032. */
  7033. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7034. /**
  7035. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7036. * @param min defines the new minimum vector (in local space)
  7037. * @param max defines the new maximum vector (in local space)
  7038. * @param worldMatrix defines the new world matrix
  7039. */
  7040. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7041. /**
  7042. * Scale the current bounding box by applying a scale factor
  7043. * @param factor defines the scale factor to apply
  7044. * @returns the current bounding box
  7045. */
  7046. scale(factor: number): BoundingBox;
  7047. /**
  7048. * Gets the world matrix of the bounding box
  7049. * @returns a matrix
  7050. */
  7051. getWorldMatrix(): DeepImmutable<Matrix>;
  7052. /** @hidden */
  7053. _update(world: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * Tests if the bounding box is intersecting the frustum planes
  7056. * @param frustumPlanes defines the frustum planes to test
  7057. * @returns true if there is an intersection
  7058. */
  7059. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7060. /**
  7061. * Tests if the bounding box is entirely inside the frustum planes
  7062. * @param frustumPlanes defines the frustum planes to test
  7063. * @returns true if there is an inclusion
  7064. */
  7065. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7066. /**
  7067. * Tests if a point is inside the bounding box
  7068. * @param point defines the point to test
  7069. * @returns true if the point is inside the bounding box
  7070. */
  7071. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7072. /**
  7073. * Tests if the bounding box intersects with a bounding sphere
  7074. * @param sphere defines the sphere to test
  7075. * @returns true if there is an intersection
  7076. */
  7077. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7078. /**
  7079. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7080. * @param min defines the min vector to use
  7081. * @param max defines the max vector to use
  7082. * @returns true if there is an intersection
  7083. */
  7084. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7085. /**
  7086. * Tests if two bounding boxes are intersections
  7087. * @param box0 defines the first box to test
  7088. * @param box1 defines the second box to test
  7089. * @returns true if there is an intersection
  7090. */
  7091. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7092. /**
  7093. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7094. * @param minPoint defines the minimum vector of the bounding box
  7095. * @param maxPoint defines the maximum vector of the bounding box
  7096. * @param sphereCenter defines the sphere center
  7097. * @param sphereRadius defines the sphere radius
  7098. * @returns true if there is an intersection
  7099. */
  7100. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7101. /**
  7102. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7103. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7104. * @param frustumPlanes defines the frustum planes to test
  7105. * @return true if there is an inclusion
  7106. */
  7107. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7108. /**
  7109. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7110. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7111. * @param frustumPlanes defines the frustum planes to test
  7112. * @return true if there is an intersection
  7113. */
  7114. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7115. }
  7116. }
  7117. declare module BABYLON {
  7118. /** @hidden */
  7119. export class Collider {
  7120. /** Define if a collision was found */
  7121. collisionFound: boolean;
  7122. /**
  7123. * Define last intersection point in local space
  7124. */
  7125. intersectionPoint: Vector3;
  7126. /**
  7127. * Define last collided mesh
  7128. */
  7129. collidedMesh: Nullable<AbstractMesh>;
  7130. private _collisionPoint;
  7131. private _planeIntersectionPoint;
  7132. private _tempVector;
  7133. private _tempVector2;
  7134. private _tempVector3;
  7135. private _tempVector4;
  7136. private _edge;
  7137. private _baseToVertex;
  7138. private _destinationPoint;
  7139. private _slidePlaneNormal;
  7140. private _displacementVector;
  7141. /** @hidden */
  7142. _radius: Vector3;
  7143. /** @hidden */
  7144. _retry: number;
  7145. private _velocity;
  7146. private _basePoint;
  7147. private _epsilon;
  7148. /** @hidden */
  7149. _velocityWorldLength: number;
  7150. /** @hidden */
  7151. _basePointWorld: Vector3;
  7152. private _velocityWorld;
  7153. private _normalizedVelocity;
  7154. /** @hidden */
  7155. _initialVelocity: Vector3;
  7156. /** @hidden */
  7157. _initialPosition: Vector3;
  7158. private _nearestDistance;
  7159. private _collisionMask;
  7160. collisionMask: number;
  7161. /**
  7162. * Gets the plane normal used to compute the sliding response (in local space)
  7163. */
  7164. readonly slidePlaneNormal: Vector3;
  7165. /** @hidden */
  7166. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7167. /** @hidden */
  7168. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7169. /** @hidden */
  7170. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7171. /** @hidden */
  7172. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7173. /** @hidden */
  7174. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7175. /** @hidden */
  7176. _getResponse(pos: Vector3, vel: Vector3): void;
  7177. }
  7178. }
  7179. declare module BABYLON {
  7180. /**
  7181. * Interface for cullable objects
  7182. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7183. */
  7184. export interface ICullable {
  7185. /**
  7186. * Checks if the object or part of the object is in the frustum
  7187. * @param frustumPlanes Camera near/planes
  7188. * @returns true if the object is in frustum otherwise false
  7189. */
  7190. isInFrustum(frustumPlanes: Plane[]): boolean;
  7191. /**
  7192. * Checks if a cullable object (mesh...) is in the camera frustum
  7193. * Unlike isInFrustum this cheks the full bounding box
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7198. }
  7199. /**
  7200. * Info for a bounding data of a mesh
  7201. */
  7202. export class BoundingInfo implements ICullable {
  7203. /**
  7204. * Bounding box for the mesh
  7205. */
  7206. readonly boundingBox: BoundingBox;
  7207. /**
  7208. * Bounding sphere for the mesh
  7209. */
  7210. readonly boundingSphere: BoundingSphere;
  7211. private _isLocked;
  7212. private static readonly TmpVector3;
  7213. /**
  7214. * Constructs bounding info
  7215. * @param minimum min vector of the bounding box/sphere
  7216. * @param maximum max vector of the bounding box/sphere
  7217. * @param worldMatrix defines the new world matrix
  7218. */
  7219. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7220. /**
  7221. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7222. * @param min defines the new minimum vector (in local space)
  7223. * @param max defines the new maximum vector (in local space)
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7227. /**
  7228. * min vector of the bounding box/sphere
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * max vector of the bounding box/sphere
  7233. */
  7234. readonly maximum: Vector3;
  7235. /**
  7236. * If the info is locked and won't be updated to avoid perf overhead
  7237. */
  7238. isLocked: boolean;
  7239. /**
  7240. * Updates the bounding sphere and box
  7241. * @param world world matrix to be used to update
  7242. */
  7243. update(world: DeepImmutable<Matrix>): void;
  7244. /**
  7245. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7246. * @param center New center of the bounding info
  7247. * @param extend New extend of the bounding info
  7248. * @returns the current bounding info
  7249. */
  7250. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7251. /**
  7252. * Scale the current bounding info by applying a scale factor
  7253. * @param factor defines the scale factor to apply
  7254. * @returns the current bounding info
  7255. */
  7256. scale(factor: number): BoundingInfo;
  7257. /**
  7258. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7259. * @param frustumPlanes defines the frustum to test
  7260. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7261. * @returns true if the bounding info is in the frustum planes
  7262. */
  7263. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7264. /**
  7265. * Gets the world distance between the min and max points of the bounding box
  7266. */
  7267. readonly diagonalLength: number;
  7268. /**
  7269. * Checks if a cullable object (mesh...) is in the camera frustum
  7270. * Unlike isInFrustum this cheks the full bounding box
  7271. * @param frustumPlanes Camera near/planes
  7272. * @returns true if the object is in frustum otherwise false
  7273. */
  7274. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7275. /** @hidden */
  7276. _checkCollision(collider: Collider): boolean;
  7277. /**
  7278. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7279. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7280. * @param point the point to check intersection with
  7281. * @returns if the point intersects
  7282. */
  7283. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7284. /**
  7285. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7287. * @param boundingInfo the bounding info to check intersection with
  7288. * @param precise if the intersection should be done using OBB
  7289. * @returns if the bounding info intersects
  7290. */
  7291. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7292. }
  7293. }
  7294. declare module BABYLON {
  7295. /**
  7296. * Defines an array and its length.
  7297. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7298. */
  7299. export interface ISmartArrayLike<T> {
  7300. /**
  7301. * The data of the array.
  7302. */
  7303. data: Array<T>;
  7304. /**
  7305. * The active length of the array.
  7306. */
  7307. length: number;
  7308. }
  7309. /**
  7310. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7311. */
  7312. export class SmartArray<T> implements ISmartArrayLike<T> {
  7313. /**
  7314. * The full set of data from the array.
  7315. */
  7316. data: Array<T>;
  7317. /**
  7318. * The active length of the array.
  7319. */
  7320. length: number;
  7321. protected _id: number;
  7322. /**
  7323. * Instantiates a Smart Array.
  7324. * @param capacity defines the default capacity of the array.
  7325. */
  7326. constructor(capacity: number);
  7327. /**
  7328. * Pushes a value at the end of the active data.
  7329. * @param value defines the object to push in the array.
  7330. */
  7331. push(value: T): void;
  7332. /**
  7333. * Iterates over the active data and apply the lambda to them.
  7334. * @param func defines the action to apply on each value.
  7335. */
  7336. forEach(func: (content: T) => void): void;
  7337. /**
  7338. * Sorts the full sets of data.
  7339. * @param compareFn defines the comparison function to apply.
  7340. */
  7341. sort(compareFn: (a: T, b: T) => number): void;
  7342. /**
  7343. * Resets the active data to an empty array.
  7344. */
  7345. reset(): void;
  7346. /**
  7347. * Releases all the data from the array as well as the array.
  7348. */
  7349. dispose(): void;
  7350. /**
  7351. * Concats the active data with a given array.
  7352. * @param array defines the data to concatenate with.
  7353. */
  7354. concat(array: any): void;
  7355. /**
  7356. * Returns the position of a value in the active data.
  7357. * @param value defines the value to find the index for
  7358. * @returns the index if found in the active data otherwise -1
  7359. */
  7360. indexOf(value: T): number;
  7361. /**
  7362. * Returns whether an element is part of the active data.
  7363. * @param value defines the value to look for
  7364. * @returns true if found in the active data otherwise false
  7365. */
  7366. contains(value: T): boolean;
  7367. private static _GlobalId;
  7368. }
  7369. /**
  7370. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7371. * The data in this array can only be present once
  7372. */
  7373. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7374. private _duplicateId;
  7375. /**
  7376. * Pushes a value at the end of the active data.
  7377. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7378. * @param value defines the object to push in the array.
  7379. */
  7380. push(value: T): void;
  7381. /**
  7382. * Pushes a value at the end of the active data.
  7383. * If the data is already present, it won t be added again
  7384. * @param value defines the object to push in the array.
  7385. * @returns true if added false if it was already present
  7386. */
  7387. pushNoDuplicate(value: T): boolean;
  7388. /**
  7389. * Resets the active data to an empty array.
  7390. */
  7391. reset(): void;
  7392. /**
  7393. * Concats the active data with a given array.
  7394. * This ensures no dupplicate will be present in the result.
  7395. * @param array defines the data to concatenate with.
  7396. */
  7397. concatWithNoDuplicate(array: any): void;
  7398. }
  7399. }
  7400. declare module BABYLON {
  7401. /**
  7402. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7403. * separate meshes. This can be use to improve performances.
  7404. * @see http://doc.babylonjs.com/how_to/multi_materials
  7405. */
  7406. export class MultiMaterial extends Material {
  7407. private _subMaterials;
  7408. /**
  7409. * Gets or Sets the list of Materials used within the multi material.
  7410. * They need to be ordered according to the submeshes order in the associated mesh
  7411. */
  7412. subMaterials: Nullable<Material>[];
  7413. /**
  7414. * Function used to align with Node.getChildren()
  7415. * @returns the list of Materials used within the multi material
  7416. */
  7417. getChildren(): Nullable<Material>[];
  7418. /**
  7419. * Instantiates a new Multi Material
  7420. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7421. * separate meshes. This can be use to improve performances.
  7422. * @see http://doc.babylonjs.com/how_to/multi_materials
  7423. * @param name Define the name in the scene
  7424. * @param scene Define the scene the material belongs to
  7425. */
  7426. constructor(name: string, scene: Scene);
  7427. private _hookArray;
  7428. /**
  7429. * Get one of the submaterial by its index in the submaterials array
  7430. * @param index The index to look the sub material at
  7431. * @returns The Material if the index has been defined
  7432. */
  7433. getSubMaterial(index: number): Nullable<Material>;
  7434. /**
  7435. * Get the list of active textures for the whole sub materials list.
  7436. * @returns All the textures that will be used during the rendering
  7437. */
  7438. getActiveTextures(): BaseTexture[];
  7439. /**
  7440. * Gets the current class name of the material e.g. "MultiMaterial"
  7441. * Mainly use in serialization.
  7442. * @returns the class name
  7443. */
  7444. getClassName(): string;
  7445. /**
  7446. * Checks if the material is ready to render the requested sub mesh
  7447. * @param mesh Define the mesh the submesh belongs to
  7448. * @param subMesh Define the sub mesh to look readyness for
  7449. * @param useInstances Define whether or not the material is used with instances
  7450. * @returns true if ready, otherwise false
  7451. */
  7452. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7453. /**
  7454. * Clones the current material and its related sub materials
  7455. * @param name Define the name of the newly cloned material
  7456. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7457. * @returns the cloned material
  7458. */
  7459. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7460. /**
  7461. * Serializes the materials into a JSON representation.
  7462. * @returns the JSON representation
  7463. */
  7464. serialize(): any;
  7465. /**
  7466. * Dispose the material and release its associated resources
  7467. * @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)
  7468. * @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)
  7469. * @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)
  7470. */
  7471. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7472. /**
  7473. * Creates a MultiMaterial from parsed MultiMaterial data.
  7474. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7475. * @param scene defines the hosting scene
  7476. * @returns a new MultiMaterial
  7477. */
  7478. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7479. }
  7480. }
  7481. declare module BABYLON {
  7482. /**
  7483. * Class used to represent data loading progression
  7484. */
  7485. export class SceneLoaderFlags {
  7486. private static _ForceFullSceneLoadingForIncremental;
  7487. private static _ShowLoadingScreen;
  7488. private static _CleanBoneMatrixWeights;
  7489. private static _loggingLevel;
  7490. /**
  7491. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7492. */
  7493. static ForceFullSceneLoadingForIncremental: boolean;
  7494. /**
  7495. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7496. */
  7497. static ShowLoadingScreen: boolean;
  7498. /**
  7499. * Defines the current logging level (while loading the scene)
  7500. * @ignorenaming
  7501. */
  7502. static loggingLevel: number;
  7503. /**
  7504. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7505. */
  7506. static CleanBoneMatrixWeights: boolean;
  7507. }
  7508. }
  7509. declare module BABYLON {
  7510. /**
  7511. * 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.
  7512. * @see https://doc.babylonjs.com/how_to/transformnode
  7513. */
  7514. export class TransformNode extends Node {
  7515. /**
  7516. * Object will not rotate to face the camera
  7517. */
  7518. static BILLBOARDMODE_NONE: number;
  7519. /**
  7520. * Object will rotate to face the camera but only on the x axis
  7521. */
  7522. static BILLBOARDMODE_X: number;
  7523. /**
  7524. * Object will rotate to face the camera but only on the y axis
  7525. */
  7526. static BILLBOARDMODE_Y: number;
  7527. /**
  7528. * Object will rotate to face the camera but only on the z axis
  7529. */
  7530. static BILLBOARDMODE_Z: number;
  7531. /**
  7532. * Object will rotate to face the camera
  7533. */
  7534. static BILLBOARDMODE_ALL: number;
  7535. private _forward;
  7536. private _forwardInverted;
  7537. private _up;
  7538. private _right;
  7539. private _rightInverted;
  7540. private _position;
  7541. private _rotation;
  7542. private _rotationQuaternion;
  7543. protected _scaling: Vector3;
  7544. protected _isDirty: boolean;
  7545. private _transformToBoneReferal;
  7546. private _billboardMode;
  7547. /**
  7548. * Gets or sets the billboard mode. Default is 0.
  7549. *
  7550. * | Value | Type | Description |
  7551. * | --- | --- | --- |
  7552. * | 0 | BILLBOARDMODE_NONE | |
  7553. * | 1 | BILLBOARDMODE_X | |
  7554. * | 2 | BILLBOARDMODE_Y | |
  7555. * | 4 | BILLBOARDMODE_Z | |
  7556. * | 7 | BILLBOARDMODE_ALL | |
  7557. *
  7558. */
  7559. billboardMode: number;
  7560. private _preserveParentRotationForBillboard;
  7561. /**
  7562. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7563. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7564. */
  7565. preserveParentRotationForBillboard: boolean;
  7566. /**
  7567. * 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
  7568. */
  7569. scalingDeterminant: number;
  7570. private _infiniteDistance;
  7571. /**
  7572. * Gets or sets the distance of the object to max, often used by skybox
  7573. */
  7574. infiniteDistance: boolean;
  7575. /**
  7576. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7577. * By default the system will update normals to compensate
  7578. */
  7579. ignoreNonUniformScaling: boolean;
  7580. /**
  7581. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7582. */
  7583. reIntegrateRotationIntoRotationQuaternion: boolean;
  7584. /** @hidden */
  7585. _poseMatrix: Nullable<Matrix>;
  7586. /** @hidden */
  7587. _localMatrix: Matrix;
  7588. private _usePivotMatrix;
  7589. private _absolutePosition;
  7590. private _pivotMatrix;
  7591. private _pivotMatrixInverse;
  7592. protected _postMultiplyPivotMatrix: boolean;
  7593. protected _isWorldMatrixFrozen: boolean;
  7594. /** @hidden */
  7595. _indexInSceneTransformNodesArray: number;
  7596. /**
  7597. * An event triggered after the world matrix is updated
  7598. */
  7599. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7600. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7601. /**
  7602. * Gets a string identifying the name of the class
  7603. * @returns "TransformNode" string
  7604. */
  7605. getClassName(): string;
  7606. /**
  7607. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7608. */
  7609. position: Vector3;
  7610. /**
  7611. * 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)).
  7612. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7613. */
  7614. rotation: Vector3;
  7615. /**
  7616. * 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)).
  7617. */
  7618. scaling: Vector3;
  7619. /**
  7620. * 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).
  7621. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7622. */
  7623. rotationQuaternion: Nullable<Quaternion>;
  7624. /**
  7625. * The forward direction of that transform in world space.
  7626. */
  7627. readonly forward: Vector3;
  7628. /**
  7629. * The up direction of that transform in world space.
  7630. */
  7631. readonly up: Vector3;
  7632. /**
  7633. * The right direction of that transform in world space.
  7634. */
  7635. readonly right: Vector3;
  7636. /**
  7637. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7638. * @param matrix the matrix to copy the pose from
  7639. * @returns this TransformNode.
  7640. */
  7641. updatePoseMatrix(matrix: Matrix): TransformNode;
  7642. /**
  7643. * Returns the mesh Pose matrix.
  7644. * @returns the pose matrix
  7645. */
  7646. getPoseMatrix(): Matrix;
  7647. /** @hidden */
  7648. _isSynchronized(): boolean;
  7649. /** @hidden */
  7650. _initCache(): void;
  7651. /**
  7652. * Flag the transform node as dirty (Forcing it to update everything)
  7653. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7654. * @returns this transform node
  7655. */
  7656. markAsDirty(property: string): TransformNode;
  7657. /**
  7658. * Returns the current mesh absolute position.
  7659. * Returns a Vector3.
  7660. */
  7661. readonly absolutePosition: Vector3;
  7662. /**
  7663. * Sets a new matrix to apply before all other transformation
  7664. * @param matrix defines the transform matrix
  7665. * @returns the current TransformNode
  7666. */
  7667. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7668. /**
  7669. * Sets a new pivot matrix to the current node
  7670. * @param matrix defines the new pivot matrix to use
  7671. * @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
  7672. * @returns the current TransformNode
  7673. */
  7674. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7675. /**
  7676. * Returns the mesh pivot matrix.
  7677. * Default : Identity.
  7678. * @returns the matrix
  7679. */
  7680. getPivotMatrix(): Matrix;
  7681. /**
  7682. * Prevents the World matrix to be computed any longer.
  7683. * @returns the TransformNode.
  7684. */
  7685. freezeWorldMatrix(): TransformNode;
  7686. /**
  7687. * Allows back the World matrix computation.
  7688. * @returns the TransformNode.
  7689. */
  7690. unfreezeWorldMatrix(): this;
  7691. /**
  7692. * True if the World matrix has been frozen.
  7693. */
  7694. readonly isWorldMatrixFrozen: boolean;
  7695. /**
  7696. * Retuns the mesh absolute position in the World.
  7697. * @returns a Vector3.
  7698. */
  7699. getAbsolutePosition(): Vector3;
  7700. /**
  7701. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7702. * @param absolutePosition the absolute position to set
  7703. * @returns the TransformNode.
  7704. */
  7705. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7706. /**
  7707. * Sets the mesh position in its local space.
  7708. * @param vector3 the position to set in localspace
  7709. * @returns the TransformNode.
  7710. */
  7711. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7712. /**
  7713. * Returns the mesh position in the local space from the current World matrix values.
  7714. * @returns a new Vector3.
  7715. */
  7716. getPositionExpressedInLocalSpace(): Vector3;
  7717. /**
  7718. * Translates the mesh along the passed Vector3 in its local space.
  7719. * @param vector3 the distance to translate in localspace
  7720. * @returns the TransformNode.
  7721. */
  7722. locallyTranslate(vector3: Vector3): TransformNode;
  7723. private static _lookAtVectorCache;
  7724. /**
  7725. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7726. * @param targetPoint the position (must be in same space as current mesh) to look at
  7727. * @param yawCor optional yaw (y-axis) correction in radians
  7728. * @param pitchCor optional pitch (x-axis) correction in radians
  7729. * @param rollCor optional roll (z-axis) correction in radians
  7730. * @param space the choosen space of the target
  7731. * @returns the TransformNode.
  7732. */
  7733. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7734. /**
  7735. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7736. * This Vector3 is expressed in the World space.
  7737. * @param localAxis axis to rotate
  7738. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7739. */
  7740. getDirection(localAxis: Vector3): Vector3;
  7741. /**
  7742. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7743. * localAxis is expressed in the mesh local space.
  7744. * result is computed in the Wordl space from the mesh World matrix.
  7745. * @param localAxis axis to rotate
  7746. * @param result the resulting transformnode
  7747. * @returns this TransformNode.
  7748. */
  7749. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7750. /**
  7751. * Sets this transform node rotation to the given local axis.
  7752. * @param localAxis the axis in local space
  7753. * @param yawCor optional yaw (y-axis) correction in radians
  7754. * @param pitchCor optional pitch (x-axis) correction in radians
  7755. * @param rollCor optional roll (z-axis) correction in radians
  7756. * @returns this TransformNode
  7757. */
  7758. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7759. /**
  7760. * Sets a new pivot point to the current node
  7761. * @param point defines the new pivot point to use
  7762. * @param space defines if the point is in world or local space (local by default)
  7763. * @returns the current TransformNode
  7764. */
  7765. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7766. /**
  7767. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7768. * @returns the pivot point
  7769. */
  7770. getPivotPoint(): Vector3;
  7771. /**
  7772. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7773. * @param result the vector3 to store the result
  7774. * @returns this TransformNode.
  7775. */
  7776. getPivotPointToRef(result: Vector3): TransformNode;
  7777. /**
  7778. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7779. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7780. */
  7781. getAbsolutePivotPoint(): Vector3;
  7782. /**
  7783. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7784. * @param result vector3 to store the result
  7785. * @returns this TransformNode.
  7786. */
  7787. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7788. /**
  7789. * Defines the passed node as the parent of the current node.
  7790. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7791. * @see https://doc.babylonjs.com/how_to/parenting
  7792. * @param node the node ot set as the parent
  7793. * @returns this TransformNode.
  7794. */
  7795. setParent(node: Nullable<Node>): TransformNode;
  7796. private _nonUniformScaling;
  7797. /**
  7798. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7799. */
  7800. readonly nonUniformScaling: boolean;
  7801. /** @hidden */
  7802. _updateNonUniformScalingState(value: boolean): boolean;
  7803. /**
  7804. * Attach the current TransformNode to another TransformNode associated with a bone
  7805. * @param bone Bone affecting the TransformNode
  7806. * @param affectedTransformNode TransformNode associated with the bone
  7807. * @returns this object
  7808. */
  7809. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7810. /**
  7811. * Detach the transform node if its associated with a bone
  7812. * @returns this object
  7813. */
  7814. detachFromBone(): TransformNode;
  7815. private static _rotationAxisCache;
  7816. /**
  7817. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7818. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7819. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7820. * The passed axis is also normalized.
  7821. * @param axis the axis to rotate around
  7822. * @param amount the amount to rotate in radians
  7823. * @param space Space to rotate in (Default: local)
  7824. * @returns the TransformNode.
  7825. */
  7826. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7827. /**
  7828. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7830. * The passed axis is also normalized. .
  7831. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7832. * @param point the point to rotate around
  7833. * @param axis the axis to rotate around
  7834. * @param amount the amount to rotate in radians
  7835. * @returns the TransformNode
  7836. */
  7837. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7838. /**
  7839. * Translates the mesh along the axis vector for the passed distance in the given space.
  7840. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7841. * @param axis the axis to translate in
  7842. * @param distance the distance to translate
  7843. * @param space Space to rotate in (Default: local)
  7844. * @returns the TransformNode.
  7845. */
  7846. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7847. /**
  7848. * Adds a rotation step to the mesh current rotation.
  7849. * x, y, z are Euler angles expressed in radians.
  7850. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7851. * This means this rotation is made in the mesh local space only.
  7852. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7853. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7854. * ```javascript
  7855. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7856. * ```
  7857. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7858. * 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.
  7859. * @param x Rotation to add
  7860. * @param y Rotation to add
  7861. * @param z Rotation to add
  7862. * @returns the TransformNode.
  7863. */
  7864. addRotation(x: number, y: number, z: number): TransformNode;
  7865. /**
  7866. * @hidden
  7867. */
  7868. protected _getEffectiveParent(): Nullable<Node>;
  7869. /**
  7870. * Computes the world matrix of the node
  7871. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7872. * @returns the world matrix
  7873. */
  7874. computeWorldMatrix(force?: boolean): Matrix;
  7875. protected _afterComputeWorldMatrix(): void;
  7876. /**
  7877. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7878. * @param func callback function to add
  7879. *
  7880. * @returns the TransformNode.
  7881. */
  7882. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7883. /**
  7884. * Removes a registered callback function.
  7885. * @param func callback function to remove
  7886. * @returns the TransformNode.
  7887. */
  7888. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7889. /**
  7890. * Gets the position of the current mesh in camera space
  7891. * @param camera defines the camera to use
  7892. * @returns a position
  7893. */
  7894. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7895. /**
  7896. * Returns the distance from the mesh to the active camera
  7897. * @param camera defines the camera to use
  7898. * @returns the distance
  7899. */
  7900. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7901. /**
  7902. * Clone the current transform node
  7903. * @param name Name of the new clone
  7904. * @param newParent New parent for the clone
  7905. * @param doNotCloneChildren Do not clone children hierarchy
  7906. * @returns the new transform node
  7907. */
  7908. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7909. /**
  7910. * Serializes the objects information.
  7911. * @param currentSerializationObject defines the object to serialize in
  7912. * @returns the serialized object
  7913. */
  7914. serialize(currentSerializationObject?: any): any;
  7915. /**
  7916. * Returns a new TransformNode object parsed from the source provided.
  7917. * @param parsedTransformNode is the source.
  7918. * @param scene the scne the object belongs to
  7919. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7920. * @returns a new TransformNode object parsed from the source provided.
  7921. */
  7922. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7923. /**
  7924. * Get all child-transformNodes of this node
  7925. * @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
  7926. * @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
  7927. * @returns an array of TransformNode
  7928. */
  7929. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7930. /**
  7931. * Releases resources associated with this transform node.
  7932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7934. */
  7935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7936. }
  7937. }
  7938. declare module BABYLON {
  7939. /**
  7940. * Class used to override all child animations of a given target
  7941. */
  7942. export class AnimationPropertiesOverride {
  7943. /**
  7944. * Gets or sets a value indicating if animation blending must be used
  7945. */
  7946. enableBlending: boolean;
  7947. /**
  7948. * Gets or sets the blending speed to use when enableBlending is true
  7949. */
  7950. blendingSpeed: number;
  7951. /**
  7952. * Gets or sets the default loop mode to use
  7953. */
  7954. loopMode: number;
  7955. }
  7956. }
  7957. declare module BABYLON {
  7958. /**
  7959. * Class used to store bone information
  7960. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7961. */
  7962. export class Bone extends Node {
  7963. /**
  7964. * defines the bone name
  7965. */
  7966. name: string;
  7967. private static _tmpVecs;
  7968. private static _tmpQuat;
  7969. private static _tmpMats;
  7970. /**
  7971. * Gets the list of child bones
  7972. */
  7973. children: Bone[];
  7974. /** Gets the animations associated with this bone */
  7975. animations: Animation[];
  7976. /**
  7977. * Gets or sets bone length
  7978. */
  7979. length: number;
  7980. /**
  7981. * @hidden Internal only
  7982. * Set this value to map this bone to a different index in the transform matrices
  7983. * Set this value to -1 to exclude the bone from the transform matrices
  7984. */
  7985. _index: Nullable<number>;
  7986. private _skeleton;
  7987. private _localMatrix;
  7988. private _restPose;
  7989. private _baseMatrix;
  7990. private _absoluteTransform;
  7991. private _invertedAbsoluteTransform;
  7992. private _parent;
  7993. private _scalingDeterminant;
  7994. private _worldTransform;
  7995. private _localScaling;
  7996. private _localRotation;
  7997. private _localPosition;
  7998. private _needToDecompose;
  7999. private _needToCompose;
  8000. /** @hidden */
  8001. _linkedTransformNode: Nullable<TransformNode>;
  8002. /** @hidden */
  8003. _waitingTransformNodeId: Nullable<string>;
  8004. /** @hidden */
  8005. /** @hidden */
  8006. _matrix: Matrix;
  8007. /**
  8008. * Create a new bone
  8009. * @param name defines the bone name
  8010. * @param skeleton defines the parent skeleton
  8011. * @param parentBone defines the parent (can be null if the bone is the root)
  8012. * @param localMatrix defines the local matrix
  8013. * @param restPose defines the rest pose matrix
  8014. * @param baseMatrix defines the base matrix
  8015. * @param index defines index of the bone in the hiearchy
  8016. */
  8017. constructor(
  8018. /**
  8019. * defines the bone name
  8020. */
  8021. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8022. /**
  8023. * Gets the current object class name.
  8024. * @return the class name
  8025. */
  8026. getClassName(): string;
  8027. /**
  8028. * Gets the parent skeleton
  8029. * @returns a skeleton
  8030. */
  8031. getSkeleton(): Skeleton;
  8032. /**
  8033. * Gets parent bone
  8034. * @returns a bone or null if the bone is the root of the bone hierarchy
  8035. */
  8036. getParent(): Nullable<Bone>;
  8037. /**
  8038. * Returns an array containing the root bones
  8039. * @returns an array containing the root bones
  8040. */
  8041. getChildren(): Array<Bone>;
  8042. /**
  8043. * Sets the parent bone
  8044. * @param parent defines the parent (can be null if the bone is the root)
  8045. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8046. */
  8047. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8048. /**
  8049. * Gets the local matrix
  8050. * @returns a matrix
  8051. */
  8052. getLocalMatrix(): Matrix;
  8053. /**
  8054. * Gets the base matrix (initial matrix which remains unchanged)
  8055. * @returns a matrix
  8056. */
  8057. getBaseMatrix(): Matrix;
  8058. /**
  8059. * Gets the rest pose matrix
  8060. * @returns a matrix
  8061. */
  8062. getRestPose(): Matrix;
  8063. /**
  8064. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8065. */
  8066. getWorldMatrix(): Matrix;
  8067. /**
  8068. * Sets the local matrix to rest pose matrix
  8069. */
  8070. returnToRest(): void;
  8071. /**
  8072. * Gets the inverse of the absolute transform matrix.
  8073. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8074. * @returns a matrix
  8075. */
  8076. getInvertedAbsoluteTransform(): Matrix;
  8077. /**
  8078. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8079. * @returns a matrix
  8080. */
  8081. getAbsoluteTransform(): Matrix;
  8082. /**
  8083. * Links with the given transform node.
  8084. * The local matrix of this bone is copied from the transform node every frame.
  8085. * @param transformNode defines the transform node to link to
  8086. */
  8087. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8088. /** Gets or sets current position (in local space) */
  8089. position: Vector3;
  8090. /** Gets or sets current rotation (in local space) */
  8091. rotation: Vector3;
  8092. /** Gets or sets current rotation quaternion (in local space) */
  8093. rotationQuaternion: Quaternion;
  8094. /** Gets or sets current scaling (in local space) */
  8095. scaling: Vector3;
  8096. /**
  8097. * Gets the animation properties override
  8098. */
  8099. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8100. private _decompose;
  8101. private _compose;
  8102. /**
  8103. * Update the base and local matrices
  8104. * @param matrix defines the new base or local matrix
  8105. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8106. * @param updateLocalMatrix defines if the local matrix should be updated
  8107. */
  8108. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8109. /** @hidden */
  8110. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8111. /**
  8112. * Flag the bone as dirty (Forcing it to update everything)
  8113. */
  8114. markAsDirty(): void;
  8115. private _markAsDirtyAndCompose;
  8116. private _markAsDirtyAndDecompose;
  8117. /**
  8118. * Translate the bone in local or world space
  8119. * @param vec The amount to translate the bone
  8120. * @param space The space that the translation is in
  8121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8122. */
  8123. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8124. /**
  8125. * Set the postion of the bone in local or world space
  8126. * @param position The position to set the bone
  8127. * @param space The space that the position is in
  8128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8129. */
  8130. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8131. /**
  8132. * Set the absolute position of the bone (world space)
  8133. * @param position The position to set the bone
  8134. * @param mesh The mesh that this bone is attached to
  8135. */
  8136. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8137. /**
  8138. * Scale the bone on the x, y and z axes (in local space)
  8139. * @param x The amount to scale the bone on the x axis
  8140. * @param y The amount to scale the bone on the y axis
  8141. * @param z The amount to scale the bone on the z axis
  8142. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8143. */
  8144. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8145. /**
  8146. * Set the bone scaling in local space
  8147. * @param scale defines the scaling vector
  8148. */
  8149. setScale(scale: Vector3): void;
  8150. /**
  8151. * Gets the current scaling in local space
  8152. * @returns the current scaling vector
  8153. */
  8154. getScale(): Vector3;
  8155. /**
  8156. * Gets the current scaling in local space and stores it in a target vector
  8157. * @param result defines the target vector
  8158. */
  8159. getScaleToRef(result: Vector3): void;
  8160. /**
  8161. * Set the yaw, pitch, and roll of the bone in local or world space
  8162. * @param yaw The rotation of the bone on the y axis
  8163. * @param pitch The rotation of the bone on the x axis
  8164. * @param roll The rotation of the bone on the z axis
  8165. * @param space The space that the axes of rotation are in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. */
  8168. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8169. /**
  8170. * Add a rotation to the bone on an axis in local or world space
  8171. * @param axis The axis to rotate the bone on
  8172. * @param amount The amount to rotate the bone
  8173. * @param space The space that the axis is in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. */
  8176. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8177. /**
  8178. * Set the rotation of the bone to a particular axis angle in local or world space
  8179. * @param axis The axis to rotate the bone on
  8180. * @param angle The angle that the bone should be rotated to
  8181. * @param space The space that the axis is in
  8182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8183. */
  8184. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8185. /**
  8186. * Set the euler rotation of the bone in local of world space
  8187. * @param rotation The euler rotation that the bone should be set to
  8188. * @param space The space that the rotation is in
  8189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8190. */
  8191. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8192. /**
  8193. * Set the quaternion rotation of the bone in local of world space
  8194. * @param quat The quaternion rotation that the bone should be set to
  8195. * @param space The space that the rotation is in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. */
  8198. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8199. /**
  8200. * Set the rotation matrix of the bone in local of world space
  8201. * @param rotMat The rotation matrix that the bone should be set to
  8202. * @param space The space that the rotation is in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. */
  8205. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8206. private _rotateWithMatrix;
  8207. private _getNegativeRotationToRef;
  8208. /**
  8209. * Get the position of the bone in local or world space
  8210. * @param space The space that the returned position is in
  8211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8212. * @returns The position of the bone
  8213. */
  8214. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8215. /**
  8216. * Copy the position of the bone to a vector3 in local or world space
  8217. * @param space The space that the returned position is in
  8218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8219. * @param result The vector3 to copy the position to
  8220. */
  8221. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8222. /**
  8223. * Get the absolute position of the bone (world space)
  8224. * @param mesh The mesh that this bone is attached to
  8225. * @returns The absolute position of the bone
  8226. */
  8227. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8228. /**
  8229. * Copy the absolute position of the bone (world space) to the result param
  8230. * @param mesh The mesh that this bone is attached to
  8231. * @param result The vector3 to copy the absolute position to
  8232. */
  8233. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8234. /**
  8235. * Compute the absolute transforms of this bone and its children
  8236. */
  8237. computeAbsoluteTransforms(): void;
  8238. /**
  8239. * Get the world direction from an axis that is in the local space of the bone
  8240. * @param localAxis The local direction that is used to compute the world direction
  8241. * @param mesh The mesh that this bone is attached to
  8242. * @returns The world direction
  8243. */
  8244. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8245. /**
  8246. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8247. * @param localAxis The local direction that is used to compute the world direction
  8248. * @param mesh The mesh that this bone is attached to
  8249. * @param result The vector3 that the world direction will be copied to
  8250. */
  8251. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8252. /**
  8253. * Get the euler rotation of the bone in local or world space
  8254. * @param space The space that the rotation should be in
  8255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8256. * @returns The euler rotation
  8257. */
  8258. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8259. /**
  8260. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8261. * @param space The space that the rotation should be in
  8262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8263. * @param result The vector3 that the rotation should be copied to
  8264. */
  8265. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8266. /**
  8267. * Get the quaternion rotation of the bone in either local or world space
  8268. * @param space The space that the rotation should be in
  8269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8270. * @returns The quaternion rotation
  8271. */
  8272. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8273. /**
  8274. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8275. * @param space The space that the rotation should be in
  8276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8277. * @param result The quaternion that the rotation should be copied to
  8278. */
  8279. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8280. /**
  8281. * Get the rotation matrix of the bone in local or world space
  8282. * @param space The space that the rotation should be in
  8283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8284. * @returns The rotation matrix
  8285. */
  8286. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8287. /**
  8288. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8289. * @param space The space that the rotation should be in
  8290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8291. * @param result The quaternion that the rotation should be copied to
  8292. */
  8293. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8294. /**
  8295. * Get the world position of a point that is in the local space of the bone
  8296. * @param position The local position
  8297. * @param mesh The mesh that this bone is attached to
  8298. * @returns The world position
  8299. */
  8300. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8301. /**
  8302. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8303. * @param position The local position
  8304. * @param mesh The mesh that this bone is attached to
  8305. * @param result The vector3 that the world position should be copied to
  8306. */
  8307. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8308. /**
  8309. * Get the local position of a point that is in world space
  8310. * @param position The world position
  8311. * @param mesh The mesh that this bone is attached to
  8312. * @returns The local position
  8313. */
  8314. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8315. /**
  8316. * Get the local position of a point that is in world space and copy it to the result param
  8317. * @param position The world position
  8318. * @param mesh The mesh that this bone is attached to
  8319. * @param result The vector3 that the local position should be copied to
  8320. */
  8321. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8322. }
  8323. }
  8324. declare module BABYLON {
  8325. /**
  8326. * Enum that determines the text-wrapping mode to use.
  8327. */
  8328. export enum InspectableType {
  8329. /**
  8330. * Checkbox for booleans
  8331. */
  8332. Checkbox = 0,
  8333. /**
  8334. * Sliders for numbers
  8335. */
  8336. Slider = 1,
  8337. /**
  8338. * Vector3
  8339. */
  8340. Vector3 = 2,
  8341. /**
  8342. * Quaternions
  8343. */
  8344. Quaternion = 3,
  8345. /**
  8346. * Color3
  8347. */
  8348. Color3 = 4
  8349. }
  8350. /**
  8351. * Interface used to define custom inspectable properties.
  8352. * This interface is used by the inspector to display custom property grids
  8353. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8354. */
  8355. export interface IInspectable {
  8356. /**
  8357. * Gets the label to display
  8358. */
  8359. label: string;
  8360. /**
  8361. * Gets the name of the property to edit
  8362. */
  8363. propertyName: string;
  8364. /**
  8365. * Gets the type of the editor to use
  8366. */
  8367. type: InspectableType;
  8368. /**
  8369. * Gets the minimum value of the property when using in "slider" mode
  8370. */
  8371. min?: number;
  8372. /**
  8373. * Gets the maximum value of the property when using in "slider" mode
  8374. */
  8375. max?: number;
  8376. /**
  8377. * Gets the setp to use when using in "slider" mode
  8378. */
  8379. step?: number;
  8380. }
  8381. }
  8382. declare module BABYLON {
  8383. /**
  8384. * This represents the required contract to create a new type of texture loader.
  8385. */
  8386. export interface IInternalTextureLoader {
  8387. /**
  8388. * Defines wether the loader supports cascade loading the different faces.
  8389. */
  8390. supportCascades: boolean;
  8391. /**
  8392. * This returns if the loader support the current file information.
  8393. * @param extension defines the file extension of the file being loaded
  8394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8395. * @param fallback defines the fallback internal texture if any
  8396. * @param isBase64 defines whether the texture is encoded as a base64
  8397. * @param isBuffer defines whether the texture data are stored as a buffer
  8398. * @returns true if the loader can load the specified file
  8399. */
  8400. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8401. /**
  8402. * Transform the url before loading if required.
  8403. * @param rootUrl the url of the texture
  8404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8405. * @returns the transformed texture
  8406. */
  8407. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8408. /**
  8409. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8410. * @param rootUrl the url of the texture
  8411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8412. * @returns the fallback texture
  8413. */
  8414. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8415. /**
  8416. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8417. * @param data contains the texture data
  8418. * @param texture defines the BabylonJS internal texture
  8419. * @param createPolynomials will be true if polynomials have been requested
  8420. * @param onLoad defines the callback to trigger once the texture is ready
  8421. * @param onError defines the callback to trigger in case of error
  8422. */
  8423. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8424. /**
  8425. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8426. * @param data contains the texture data
  8427. * @param texture defines the BabylonJS internal texture
  8428. * @param callback defines the method to call once ready to upload
  8429. */
  8430. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8431. }
  8432. }
  8433. declare module BABYLON {
  8434. interface Engine {
  8435. /**
  8436. * Creates a depth stencil cube texture.
  8437. * This is only available in WebGL 2.
  8438. * @param size The size of face edge in the cube texture.
  8439. * @param options The options defining the cube texture.
  8440. * @returns The cube texture
  8441. */
  8442. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8443. /**
  8444. * Creates a cube texture
  8445. * @param rootUrl defines the url where the files to load is located
  8446. * @param scene defines the current scene
  8447. * @param files defines the list of files to load (1 per face)
  8448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8449. * @param onLoad defines an optional callback raised when the texture is loaded
  8450. * @param onError defines an optional callback raised if there is an issue to load the texture
  8451. * @param format defines the format of the data
  8452. * @param forcedExtension defines the extension to use to pick the right loader
  8453. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8454. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8455. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8456. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8457. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8458. * @returns the cube texture as an InternalTexture
  8459. */
  8460. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8461. /**
  8462. * Creates a cube texture
  8463. * @param rootUrl defines the url where the files to load is located
  8464. * @param scene defines the current scene
  8465. * @param files defines the list of files to load (1 per face)
  8466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8467. * @param onLoad defines an optional callback raised when the texture is loaded
  8468. * @param onError defines an optional callback raised if there is an issue to load the texture
  8469. * @param format defines the format of the data
  8470. * @param forcedExtension defines the extension to use to pick the right loader
  8471. * @returns the cube texture as an InternalTexture
  8472. */
  8473. 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 | undefined, forcedExtension: any): InternalTexture;
  8474. /**
  8475. * Creates a cube texture
  8476. * @param rootUrl defines the url where the files to load is located
  8477. * @param scene defines the current scene
  8478. * @param files defines the list of files to load (1 per face)
  8479. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8480. * @param onLoad defines an optional callback raised when the texture is loaded
  8481. * @param onError defines an optional callback raised if there is an issue to load the texture
  8482. * @param format defines the format of the data
  8483. * @param forcedExtension defines the extension to use to pick the right loader
  8484. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8485. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8486. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8487. * @returns the cube texture as an InternalTexture
  8488. */
  8489. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8490. /** @hidden */
  8491. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8492. /** @hidden */
  8493. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8494. /** @hidden */
  8495. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8496. /** @hidden */
  8497. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8498. }
  8499. }
  8500. declare module BABYLON {
  8501. /**
  8502. * Class for creating a cube texture
  8503. */
  8504. export class CubeTexture extends BaseTexture {
  8505. private _delayedOnLoad;
  8506. /**
  8507. * The url of the texture
  8508. */
  8509. url: string;
  8510. /**
  8511. * Gets or sets the center of the bounding box associated with the cube texture.
  8512. * It must define where the camera used to render the texture was set
  8513. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8514. */
  8515. boundingBoxPosition: Vector3;
  8516. private _boundingBoxSize;
  8517. /**
  8518. * Gets or sets the size of the bounding box associated with the cube texture
  8519. * When defined, the cubemap will switch to local mode
  8520. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8521. * @example https://www.babylonjs-playground.com/#RNASML
  8522. */
  8523. /**
  8524. * Returns the bounding box size
  8525. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8526. */
  8527. boundingBoxSize: Vector3;
  8528. protected _rotationY: number;
  8529. /**
  8530. * Sets texture matrix rotation angle around Y axis in radians.
  8531. */
  8532. /**
  8533. * Gets texture matrix rotation angle around Y axis radians.
  8534. */
  8535. rotationY: number;
  8536. /**
  8537. * Are mip maps generated for this texture or not.
  8538. */
  8539. readonly noMipmap: boolean;
  8540. private _noMipmap;
  8541. private _files;
  8542. private _extensions;
  8543. private _textureMatrix;
  8544. private _format;
  8545. private _createPolynomials;
  8546. /** @hidden */
  8547. _prefiltered: boolean;
  8548. /**
  8549. * Creates a cube texture from an array of image urls
  8550. * @param files defines an array of image urls
  8551. * @param scene defines the hosting scene
  8552. * @param noMipmap specifies if mip maps are not used
  8553. * @returns a cube texture
  8554. */
  8555. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8556. /**
  8557. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8558. * @param url defines the url of the prefiltered texture
  8559. * @param scene defines the scene the texture is attached to
  8560. * @param forcedExtension defines the extension of the file if different from the url
  8561. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8562. * @return the prefiltered texture
  8563. */
  8564. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8565. /**
  8566. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8567. * as prefiltered data.
  8568. * @param rootUrl defines the url of the texture or the root name of the six images
  8569. * @param scene defines the scene the texture is attached to
  8570. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8571. * @param noMipmap defines if mipmaps should be created or not
  8572. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8573. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8574. * @param onError defines a callback triggered in case of error during load
  8575. * @param format defines the internal format to use for the texture once loaded
  8576. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8577. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8578. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8579. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8580. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8581. * @return the cube texture
  8582. */
  8583. 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);
  8584. /**
  8585. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8586. */
  8587. readonly isPrefiltered: boolean;
  8588. /**
  8589. * Get the current class name of the texture useful for serialization or dynamic coding.
  8590. * @returns "CubeTexture"
  8591. */
  8592. getClassName(): string;
  8593. /**
  8594. * Update the url (and optional buffer) of this texture if url was null during construction.
  8595. * @param url the url of the texture
  8596. * @param forcedExtension defines the extension to use
  8597. * @param onLoad callback called when the texture is loaded (defaults to null)
  8598. */
  8599. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8600. /**
  8601. * Delays loading of the cube texture
  8602. * @param forcedExtension defines the extension to use
  8603. */
  8604. delayLoad(forcedExtension?: string): void;
  8605. /**
  8606. * Returns the reflection texture matrix
  8607. * @returns the reflection texture matrix
  8608. */
  8609. getReflectionTextureMatrix(): Matrix;
  8610. /**
  8611. * Sets the reflection texture matrix
  8612. * @param value Reflection texture matrix
  8613. */
  8614. setReflectionTextureMatrix(value: Matrix): void;
  8615. /**
  8616. * Parses text to create a cube texture
  8617. * @param parsedTexture define the serialized text to read from
  8618. * @param scene defines the hosting scene
  8619. * @param rootUrl defines the root url of the cube texture
  8620. * @returns a cube texture
  8621. */
  8622. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8623. /**
  8624. * Makes a clone, or deep copy, of the cube texture
  8625. * @returns a new cube texture
  8626. */
  8627. clone(): CubeTexture;
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /** @hidden */
  8632. export var postprocessVertexShader: {
  8633. name: string;
  8634. shader: string;
  8635. };
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8640. * This is the base of the follow, arc rotate cameras and Free camera
  8641. * @see http://doc.babylonjs.com/features/cameras
  8642. */
  8643. export class TargetCamera extends Camera {
  8644. private static _RigCamTransformMatrix;
  8645. private static _TargetTransformMatrix;
  8646. private static _TargetFocalPoint;
  8647. /**
  8648. * Define the current direction the camera is moving to
  8649. */
  8650. cameraDirection: Vector3;
  8651. /**
  8652. * Define the current rotation the camera is rotating to
  8653. */
  8654. cameraRotation: Vector2;
  8655. /**
  8656. * When set, the up vector of the camera will be updated by the rotation of the camera
  8657. */
  8658. updateUpVectorFromRotation: boolean;
  8659. private _tmpQuaternion;
  8660. /**
  8661. * Define the current rotation of the camera
  8662. */
  8663. rotation: Vector3;
  8664. /**
  8665. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8666. */
  8667. rotationQuaternion: Quaternion;
  8668. /**
  8669. * Define the current speed of the camera
  8670. */
  8671. speed: number;
  8672. /**
  8673. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8674. * around all axis.
  8675. */
  8676. noRotationConstraint: boolean;
  8677. /**
  8678. * Define the current target of the camera as an object or a position.
  8679. */
  8680. lockedTarget: any;
  8681. /** @hidden */
  8682. _currentTarget: Vector3;
  8683. /** @hidden */
  8684. _initialFocalDistance: number;
  8685. /** @hidden */
  8686. _viewMatrix: Matrix;
  8687. /** @hidden */
  8688. _camMatrix: Matrix;
  8689. /** @hidden */
  8690. _cameraTransformMatrix: Matrix;
  8691. /** @hidden */
  8692. _cameraRotationMatrix: Matrix;
  8693. /** @hidden */
  8694. _referencePoint: Vector3;
  8695. /** @hidden */
  8696. _transformedReferencePoint: Vector3;
  8697. protected _globalCurrentTarget: Vector3;
  8698. protected _globalCurrentUpVector: Vector3;
  8699. /** @hidden */
  8700. _reset: () => void;
  8701. private _defaultUp;
  8702. /**
  8703. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8704. * This is the base of the follow, arc rotate cameras and Free camera
  8705. * @see http://doc.babylonjs.com/features/cameras
  8706. * @param name Defines the name of the camera in the scene
  8707. * @param position Defines the start position of the camera in the scene
  8708. * @param scene Defines the scene the camera belongs to
  8709. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8710. */
  8711. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8712. /**
  8713. * Gets the position in front of the camera at a given distance.
  8714. * @param distance The distance from the camera we want the position to be
  8715. * @returns the position
  8716. */
  8717. getFrontPosition(distance: number): Vector3;
  8718. /** @hidden */
  8719. _getLockedTargetPosition(): Nullable<Vector3>;
  8720. private _storedPosition;
  8721. private _storedRotation;
  8722. private _storedRotationQuaternion;
  8723. /**
  8724. * Store current camera state of the camera (fov, position, rotation, etc..)
  8725. * @returns the camera
  8726. */
  8727. storeState(): Camera;
  8728. /**
  8729. * Restored camera state. You must call storeState() first
  8730. * @returns whether it was successful or not
  8731. * @hidden
  8732. */
  8733. _restoreStateValues(): boolean;
  8734. /** @hidden */
  8735. _initCache(): void;
  8736. /** @hidden */
  8737. _updateCache(ignoreParentClass?: boolean): void;
  8738. /** @hidden */
  8739. _isSynchronizedViewMatrix(): boolean;
  8740. /** @hidden */
  8741. _computeLocalCameraSpeed(): number;
  8742. /**
  8743. * Defines the target the camera should look at.
  8744. * This will automatically adapt alpha beta and radius to fit within the new target.
  8745. * @param target Defines the new target as a Vector or a mesh
  8746. */
  8747. setTarget(target: Vector3): void;
  8748. /**
  8749. * Return the current target position of the camera. This value is expressed in local space.
  8750. * @returns the target position
  8751. */
  8752. getTarget(): Vector3;
  8753. /** @hidden */
  8754. _decideIfNeedsToMove(): boolean;
  8755. /** @hidden */
  8756. _updatePosition(): void;
  8757. /** @hidden */
  8758. _checkInputs(): void;
  8759. protected _updateCameraRotationMatrix(): void;
  8760. /**
  8761. * 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)
  8762. * @returns the current camera
  8763. */
  8764. private _rotateUpVectorWithCameraRotationMatrix;
  8765. private _cachedRotationZ;
  8766. private _cachedQuaternionRotationZ;
  8767. /** @hidden */
  8768. _getViewMatrix(): Matrix;
  8769. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8770. /**
  8771. * @hidden
  8772. */
  8773. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8774. /**
  8775. * @hidden
  8776. */
  8777. _updateRigCameras(): void;
  8778. private _getRigCamPositionAndTarget;
  8779. /**
  8780. * Gets the current object class name.
  8781. * @return the class name
  8782. */
  8783. getClassName(): string;
  8784. }
  8785. }
  8786. declare module BABYLON {
  8787. /**
  8788. * @ignore
  8789. * This is a list of all the different input types that are available in the application.
  8790. * Fo instance: ArcRotateCameraGamepadInput...
  8791. */
  8792. export var CameraInputTypes: {};
  8793. /**
  8794. * This is the contract to implement in order to create a new input class.
  8795. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8796. */
  8797. export interface ICameraInput<TCamera extends Camera> {
  8798. /**
  8799. * Defines the camera the input is attached to.
  8800. */
  8801. camera: Nullable<TCamera>;
  8802. /**
  8803. * Gets the class name of the current intput.
  8804. * @returns the class name
  8805. */
  8806. getClassName(): string;
  8807. /**
  8808. * Get the friendly name associated with the input class.
  8809. * @returns the input friendly name
  8810. */
  8811. getSimpleName(): string;
  8812. /**
  8813. * Attach the input controls to a specific dom element to get the input from.
  8814. * @param element Defines the element the controls should be listened from
  8815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8816. */
  8817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8818. /**
  8819. * Detach the current controls from the specified dom element.
  8820. * @param element Defines the element to stop listening the inputs from
  8821. */
  8822. detachControl(element: Nullable<HTMLElement>): void;
  8823. /**
  8824. * Update the current camera state depending on the inputs that have been used this frame.
  8825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8826. */
  8827. checkInputs?: () => void;
  8828. }
  8829. /**
  8830. * Represents a map of input types to input instance or input index to input instance.
  8831. */
  8832. export interface CameraInputsMap<TCamera extends Camera> {
  8833. /**
  8834. * Accessor to the input by input type.
  8835. */
  8836. [name: string]: ICameraInput<TCamera>;
  8837. /**
  8838. * Accessor to the input by input index.
  8839. */
  8840. [idx: number]: ICameraInput<TCamera>;
  8841. }
  8842. /**
  8843. * This represents the input manager used within a camera.
  8844. * It helps dealing with all the different kind of input attached to a camera.
  8845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8846. */
  8847. export class CameraInputsManager<TCamera extends Camera> {
  8848. /**
  8849. * Defines the list of inputs attahed to the camera.
  8850. */
  8851. attached: CameraInputsMap<TCamera>;
  8852. /**
  8853. * Defines the dom element the camera is collecting inputs from.
  8854. * This is null if the controls have not been attached.
  8855. */
  8856. attachedElement: Nullable<HTMLElement>;
  8857. /**
  8858. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8859. */
  8860. noPreventDefault: boolean;
  8861. /**
  8862. * Defined the camera the input manager belongs to.
  8863. */
  8864. camera: TCamera;
  8865. /**
  8866. * Update the current camera state depending on the inputs that have been used this frame.
  8867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8868. */
  8869. checkInputs: () => void;
  8870. /**
  8871. * Instantiate a new Camera Input Manager.
  8872. * @param camera Defines the camera the input manager blongs to
  8873. */
  8874. constructor(camera: TCamera);
  8875. /**
  8876. * Add an input method to a camera
  8877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8878. * @param input camera input method
  8879. */
  8880. add(input: ICameraInput<TCamera>): void;
  8881. /**
  8882. * Remove a specific input method from a camera
  8883. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8884. * @param inputToRemove camera input method
  8885. */
  8886. remove(inputToRemove: ICameraInput<TCamera>): void;
  8887. /**
  8888. * Remove a specific input type from a camera
  8889. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8890. * @param inputType the type of the input to remove
  8891. */
  8892. removeByType(inputType: string): void;
  8893. private _addCheckInputs;
  8894. /**
  8895. * Attach the input controls to the currently attached dom element to listen the events from.
  8896. * @param input Defines the input to attach
  8897. */
  8898. attachInput(input: ICameraInput<TCamera>): void;
  8899. /**
  8900. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8901. * @param element Defines the dom element to collect the events from
  8902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8903. */
  8904. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8905. /**
  8906. * Detach the current manager inputs controls from a specific dom element.
  8907. * @param element Defines the dom element to collect the events from
  8908. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8909. */
  8910. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8911. /**
  8912. * Rebuild the dynamic inputCheck function from the current list of
  8913. * defined inputs in the manager.
  8914. */
  8915. rebuildInputCheck(): void;
  8916. /**
  8917. * Remove all attached input methods from a camera
  8918. */
  8919. clear(): void;
  8920. /**
  8921. * Serialize the current input manager attached to a camera.
  8922. * This ensures than once parsed,
  8923. * the input associated to the camera will be identical to the current ones
  8924. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8925. */
  8926. serialize(serializedCamera: any): void;
  8927. /**
  8928. * Parses an input manager serialized JSON to restore the previous list of inputs
  8929. * and states associated to a camera.
  8930. * @param parsedCamera Defines the JSON to parse
  8931. */
  8932. parse(parsedCamera: any): void;
  8933. }
  8934. }
  8935. declare module BABYLON {
  8936. /**
  8937. * Gather the list of keyboard event types as constants.
  8938. */
  8939. export class KeyboardEventTypes {
  8940. /**
  8941. * The keydown event is fired when a key becomes active (pressed).
  8942. */
  8943. static readonly KEYDOWN: number;
  8944. /**
  8945. * The keyup event is fired when a key has been released.
  8946. */
  8947. static readonly KEYUP: number;
  8948. }
  8949. /**
  8950. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8951. */
  8952. export class KeyboardInfo {
  8953. /**
  8954. * Defines the type of event (KeyboardEventTypes)
  8955. */
  8956. type: number;
  8957. /**
  8958. * Defines the related dom event
  8959. */
  8960. event: KeyboardEvent;
  8961. /**
  8962. * Instantiates a new keyboard info.
  8963. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8964. * @param type Defines the type of event (KeyboardEventTypes)
  8965. * @param event Defines the related dom event
  8966. */
  8967. constructor(
  8968. /**
  8969. * Defines the type of event (KeyboardEventTypes)
  8970. */
  8971. type: number,
  8972. /**
  8973. * Defines the related dom event
  8974. */
  8975. event: KeyboardEvent);
  8976. }
  8977. /**
  8978. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8979. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8980. */
  8981. export class KeyboardInfoPre extends KeyboardInfo {
  8982. /**
  8983. * Defines the type of event (KeyboardEventTypes)
  8984. */
  8985. type: number;
  8986. /**
  8987. * Defines the related dom event
  8988. */
  8989. event: KeyboardEvent;
  8990. /**
  8991. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8992. */
  8993. skipOnPointerObservable: boolean;
  8994. /**
  8995. * Instantiates a new keyboard pre info.
  8996. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8997. * @param type Defines the type of event (KeyboardEventTypes)
  8998. * @param event Defines the related dom event
  8999. */
  9000. constructor(
  9001. /**
  9002. * Defines the type of event (KeyboardEventTypes)
  9003. */
  9004. type: number,
  9005. /**
  9006. * Defines the related dom event
  9007. */
  9008. event: KeyboardEvent);
  9009. }
  9010. }
  9011. declare module BABYLON {
  9012. /**
  9013. * Manage the keyboard inputs to control the movement of a free camera.
  9014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9015. */
  9016. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9017. /**
  9018. * Defines the camera the input is attached to.
  9019. */
  9020. camera: FreeCamera;
  9021. /**
  9022. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9023. */
  9024. keysUp: number[];
  9025. /**
  9026. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9027. */
  9028. keysDown: number[];
  9029. /**
  9030. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9031. */
  9032. keysLeft: number[];
  9033. /**
  9034. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9035. */
  9036. keysRight: number[];
  9037. private _keys;
  9038. private _onCanvasBlurObserver;
  9039. private _onKeyboardObserver;
  9040. private _engine;
  9041. private _scene;
  9042. /**
  9043. * Attach the input controls to a specific dom element to get the input from.
  9044. * @param element Defines the element the controls should be listened from
  9045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9046. */
  9047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9048. /**
  9049. * Detach the current controls from the specified dom element.
  9050. * @param element Defines the element to stop listening the inputs from
  9051. */
  9052. detachControl(element: Nullable<HTMLElement>): void;
  9053. /**
  9054. * Update the current camera state depending on the inputs that have been used this frame.
  9055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9056. */
  9057. checkInputs(): void;
  9058. /**
  9059. * Gets the class name of the current intput.
  9060. * @returns the class name
  9061. */
  9062. getClassName(): string;
  9063. /** @hidden */
  9064. _onLostFocus(): void;
  9065. /**
  9066. * Get the friendly name associated with the input class.
  9067. * @returns the input friendly name
  9068. */
  9069. getSimpleName(): string;
  9070. }
  9071. }
  9072. declare module BABYLON {
  9073. /**
  9074. * Interface describing all the common properties and methods a shadow light needs to implement.
  9075. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9076. * as well as binding the different shadow properties to the effects.
  9077. */
  9078. export interface IShadowLight extends Light {
  9079. /**
  9080. * The light id in the scene (used in scene.findLighById for instance)
  9081. */
  9082. id: string;
  9083. /**
  9084. * The position the shdow will be casted from.
  9085. */
  9086. position: Vector3;
  9087. /**
  9088. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9089. */
  9090. direction: Vector3;
  9091. /**
  9092. * The transformed position. Position of the light in world space taking parenting in account.
  9093. */
  9094. transformedPosition: Vector3;
  9095. /**
  9096. * The transformed direction. Direction of the light in world space taking parenting in account.
  9097. */
  9098. transformedDirection: Vector3;
  9099. /**
  9100. * The friendly name of the light in the scene.
  9101. */
  9102. name: string;
  9103. /**
  9104. * Defines the shadow projection clipping minimum z value.
  9105. */
  9106. shadowMinZ: number;
  9107. /**
  9108. * Defines the shadow projection clipping maximum z value.
  9109. */
  9110. shadowMaxZ: number;
  9111. /**
  9112. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9113. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9114. */
  9115. computeTransformedInformation(): boolean;
  9116. /**
  9117. * Gets the scene the light belongs to.
  9118. * @returns The scene
  9119. */
  9120. getScene(): Scene;
  9121. /**
  9122. * Callback defining a custom Projection Matrix Builder.
  9123. * This can be used to override the default projection matrix computation.
  9124. */
  9125. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9126. /**
  9127. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9128. * @param matrix The materix to updated with the projection information
  9129. * @param viewMatrix The transform matrix of the light
  9130. * @param renderList The list of mesh to render in the map
  9131. * @returns The current light
  9132. */
  9133. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9134. /**
  9135. * Gets the current depth scale used in ESM.
  9136. * @returns The scale
  9137. */
  9138. getDepthScale(): number;
  9139. /**
  9140. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9141. * @returns true if a cube texture needs to be use
  9142. */
  9143. needCube(): boolean;
  9144. /**
  9145. * Detects if the projection matrix requires to be recomputed this frame.
  9146. * @returns true if it requires to be recomputed otherwise, false.
  9147. */
  9148. needProjectionMatrixCompute(): boolean;
  9149. /**
  9150. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9151. */
  9152. forceProjectionMatrixCompute(): void;
  9153. /**
  9154. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9155. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9156. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9157. */
  9158. getShadowDirection(faceIndex?: number): Vector3;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. }
  9172. /**
  9173. * Base implementation IShadowLight
  9174. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9175. */
  9176. export abstract class ShadowLight extends Light implements IShadowLight {
  9177. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9178. protected _position: Vector3;
  9179. protected _setPosition(value: Vector3): void;
  9180. /**
  9181. * Sets the position the shadow will be casted from. Also use as the light position for both
  9182. * point and spot lights.
  9183. */
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. position: Vector3;
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. /**
  9196. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9197. * Also use as the light direction on spot and directional lights.
  9198. */
  9199. direction: Vector3;
  9200. private _shadowMinZ;
  9201. /**
  9202. * Gets the shadow projection clipping minimum z value.
  9203. */
  9204. /**
  9205. * Sets the shadow projection clipping minimum z value.
  9206. */
  9207. shadowMinZ: number;
  9208. private _shadowMaxZ;
  9209. /**
  9210. * Sets the shadow projection clipping maximum z value.
  9211. */
  9212. /**
  9213. * Gets the shadow projection clipping maximum z value.
  9214. */
  9215. shadowMaxZ: number;
  9216. /**
  9217. * Callback defining a custom Projection Matrix Builder.
  9218. * This can be used to override the default projection matrix computation.
  9219. */
  9220. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9221. /**
  9222. * The transformed position. Position of the light in world space taking parenting in account.
  9223. */
  9224. transformedPosition: Vector3;
  9225. /**
  9226. * The transformed direction. Direction of the light in world space taking parenting in account.
  9227. */
  9228. transformedDirection: Vector3;
  9229. private _needProjectionMatrixCompute;
  9230. /**
  9231. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9232. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9233. */
  9234. computeTransformedInformation(): boolean;
  9235. /**
  9236. * Return the depth scale used for the shadow map.
  9237. * @returns the depth scale.
  9238. */
  9239. getDepthScale(): number;
  9240. /**
  9241. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9242. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9243. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9244. */
  9245. getShadowDirection(faceIndex?: number): Vector3;
  9246. /**
  9247. * Returns the ShadowLight absolute position in the World.
  9248. * @returns the position vector in world space
  9249. */
  9250. getAbsolutePosition(): Vector3;
  9251. /**
  9252. * Sets the ShadowLight direction toward the passed target.
  9253. * @param target The point to target in local space
  9254. * @returns the updated ShadowLight direction
  9255. */
  9256. setDirectionToTarget(target: Vector3): Vector3;
  9257. /**
  9258. * Returns the light rotation in euler definition.
  9259. * @returns the x y z rotation in local space.
  9260. */
  9261. getRotation(): Vector3;
  9262. /**
  9263. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9264. * @returns true if a cube texture needs to be use
  9265. */
  9266. needCube(): boolean;
  9267. /**
  9268. * Detects if the projection matrix requires to be recomputed this frame.
  9269. * @returns true if it requires to be recomputed otherwise, false.
  9270. */
  9271. needProjectionMatrixCompute(): boolean;
  9272. /**
  9273. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9274. */
  9275. forceProjectionMatrixCompute(): void;
  9276. /** @hidden */
  9277. _initCache(): void;
  9278. /** @hidden */
  9279. _isSynchronized(): boolean;
  9280. /**
  9281. * Computes the world matrix of the node
  9282. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9283. * @returns the world matrix
  9284. */
  9285. computeWorldMatrix(force?: boolean): Matrix;
  9286. /**
  9287. * Gets the minZ used for shadow according to both the scene and the light.
  9288. * @param activeCamera The camera we are returning the min for
  9289. * @returns the depth min z
  9290. */
  9291. getDepthMinZ(activeCamera: Camera): number;
  9292. /**
  9293. * Gets the maxZ used for shadow according to both the scene and the light.
  9294. * @param activeCamera The camera we are returning the max for
  9295. * @returns the depth max z
  9296. */
  9297. getDepthMaxZ(activeCamera: Camera): number;
  9298. /**
  9299. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9300. * @param matrix The materix to updated with the projection information
  9301. * @param viewMatrix The transform matrix of the light
  9302. * @param renderList The list of mesh to render in the map
  9303. * @returns The current light
  9304. */
  9305. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9306. }
  9307. }
  9308. declare module BABYLON {
  9309. /**
  9310. * "Static Class" containing the most commonly used helper while dealing with material for
  9311. * rendering purpose.
  9312. *
  9313. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9314. *
  9315. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9316. */
  9317. export class MaterialHelper {
  9318. /**
  9319. * Bind the current view position to an effect.
  9320. * @param effect The effect to be bound
  9321. * @param scene The scene the eyes position is used from
  9322. */
  9323. static BindEyePosition(effect: Effect, scene: Scene): void;
  9324. /**
  9325. * Helps preparing the defines values about the UVs in used in the effect.
  9326. * UVs are shared as much as we can accross channels in the shaders.
  9327. * @param texture The texture we are preparing the UVs for
  9328. * @param defines The defines to update
  9329. * @param key The channel key "diffuse", "specular"... used in the shader
  9330. */
  9331. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9332. /**
  9333. * Binds a texture matrix value to its corrsponding uniform
  9334. * @param texture The texture to bind the matrix for
  9335. * @param uniformBuffer The uniform buffer receivin the data
  9336. * @param key The channel key "diffuse", "specular"... used in the shader
  9337. */
  9338. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9339. /**
  9340. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9341. * @param mesh defines the current mesh
  9342. * @param scene defines the current scene
  9343. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9344. * @param pointsCloud defines if point cloud rendering has to be turned on
  9345. * @param fogEnabled defines if fog has to be turned on
  9346. * @param alphaTest defines if alpha testing has to be turned on
  9347. * @param defines defines the current list of defines
  9348. */
  9349. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9350. /**
  9351. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9352. * @param scene defines the current scene
  9353. * @param engine defines the current engine
  9354. * @param defines specifies the list of active defines
  9355. * @param useInstances defines if instances have to be turned on
  9356. * @param useClipPlane defines if clip plane have to be turned on
  9357. */
  9358. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9359. /**
  9360. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9361. * @param mesh The mesh containing the geometry data we will draw
  9362. * @param defines The defines to update
  9363. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9364. * @param useBones Precise whether bones should be used or not (override mesh info)
  9365. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9366. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9367. * @returns false if defines are considered not dirty and have not been checked
  9368. */
  9369. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9370. /**
  9371. * Prepares the defines related to multiview
  9372. * @param scene The scene we are intending to draw
  9373. * @param defines The defines to update
  9374. */
  9375. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9376. /**
  9377. * Prepares the defines related to the light information passed in parameter
  9378. * @param scene The scene we are intending to draw
  9379. * @param mesh The mesh the effect is compiling for
  9380. * @param defines The defines to update
  9381. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9382. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9383. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9384. * @returns true if normals will be required for the rest of the effect
  9385. */
  9386. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9387. /**
  9388. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9389. * that won t be acctive due to defines being turned off.
  9390. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9391. * @param samplersList The samplers list
  9392. * @param defines The defines helping in the list generation
  9393. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9394. */
  9395. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9396. /**
  9397. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9398. * @param defines The defines to update while falling back
  9399. * @param fallbacks The authorized effect fallbacks
  9400. * @param maxSimultaneousLights The maximum number of lights allowed
  9401. * @param rank the current rank of the Effect
  9402. * @returns The newly affected rank
  9403. */
  9404. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9405. /**
  9406. * Prepares the list of attributes required for morph targets according to the effect defines.
  9407. * @param attribs The current list of supported attribs
  9408. * @param mesh The mesh to prepare the morph targets attributes for
  9409. * @param defines The current Defines of the effect
  9410. */
  9411. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9412. /**
  9413. * Prepares the list of attributes required for bones according to the effect defines.
  9414. * @param attribs The current list of supported attribs
  9415. * @param mesh The mesh to prepare the bones attributes for
  9416. * @param defines The current Defines of the effect
  9417. * @param fallbacks The current efffect fallback strategy
  9418. */
  9419. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9420. /**
  9421. * Prepares the list of attributes required for instances according to the effect defines.
  9422. * @param attribs The current list of supported attribs
  9423. * @param defines The current Defines of the effect
  9424. */
  9425. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9426. /**
  9427. * Binds the light shadow information to the effect for the given mesh.
  9428. * @param light The light containing the generator
  9429. * @param scene The scene the lights belongs to
  9430. * @param mesh The mesh we are binding the information to render
  9431. * @param lightIndex The light index in the effect used to render the mesh
  9432. * @param effect The effect we are binding the data to
  9433. */
  9434. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9435. /**
  9436. * Binds the light information to the effect.
  9437. * @param light The light containing the generator
  9438. * @param effect The effect we are binding the data to
  9439. * @param lightIndex The light index in the effect used to render
  9440. */
  9441. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9442. /**
  9443. * Binds the lights information from the scene to the effect for the given mesh.
  9444. * @param scene The scene the lights belongs to
  9445. * @param mesh The mesh we are binding the information to render
  9446. * @param effect The effect we are binding the data to
  9447. * @param defines The generated defines for the effect
  9448. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9449. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9450. */
  9451. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9452. private static _tempFogColor;
  9453. /**
  9454. * Binds the fog information from the scene to the effect for the given mesh.
  9455. * @param scene The scene the lights belongs to
  9456. * @param mesh The mesh we are binding the information to render
  9457. * @param effect The effect we are binding the data to
  9458. * @param linearSpace Defines if the fog effect is applied in linear space
  9459. */
  9460. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9461. /**
  9462. * Binds the bones information from the mesh to the effect.
  9463. * @param mesh The mesh we are binding the information to render
  9464. * @param effect The effect we are binding the data to
  9465. */
  9466. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9467. /**
  9468. * Binds the morph targets information from the mesh to the effect.
  9469. * @param abstractMesh The mesh we are binding the information to render
  9470. * @param effect The effect we are binding the data to
  9471. */
  9472. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9473. /**
  9474. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9475. * @param defines The generated defines used in the effect
  9476. * @param effect The effect we are binding the data to
  9477. * @param scene The scene we are willing to render with logarithmic scale for
  9478. */
  9479. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9480. /**
  9481. * Binds the clip plane information from the scene to the effect.
  9482. * @param scene The scene the clip plane information are extracted from
  9483. * @param effect The effect we are binding the data to
  9484. */
  9485. static BindClipPlane(effect: Effect, scene: Scene): void;
  9486. }
  9487. }
  9488. declare module BABYLON {
  9489. /** @hidden */
  9490. export var kernelBlurVaryingDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module BABYLON {
  9496. /** @hidden */
  9497. export var kernelBlurFragment: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module BABYLON {
  9503. /** @hidden */
  9504. export var kernelBlurFragment2: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module BABYLON {
  9510. /** @hidden */
  9511. export var kernelBlurPixelShader: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module BABYLON {
  9517. /** @hidden */
  9518. export var kernelBlurVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module BABYLON {
  9524. /** @hidden */
  9525. export var kernelBlurVertexShader: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module BABYLON {
  9531. /**
  9532. * The Blur Post Process which blurs an image based on a kernel and direction.
  9533. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9534. */
  9535. export class BlurPostProcess extends PostProcess {
  9536. /** The direction in which to blur the image. */
  9537. direction: Vector2;
  9538. private blockCompilation;
  9539. protected _kernel: number;
  9540. protected _idealKernel: number;
  9541. protected _packedFloat: boolean;
  9542. private _staticDefines;
  9543. /**
  9544. * Sets the length in pixels of the blur sample region
  9545. */
  9546. /**
  9547. * Gets the length in pixels of the blur sample region
  9548. */
  9549. kernel: number;
  9550. /**
  9551. * Sets wether or not the blur needs to unpack/repack floats
  9552. */
  9553. /**
  9554. * Gets wether or not the blur is unpacking/repacking floats
  9555. */
  9556. packedFloat: boolean;
  9557. /**
  9558. * Creates a new instance BlurPostProcess
  9559. * @param name The name of the effect.
  9560. * @param direction The direction in which to blur the image.
  9561. * @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.
  9562. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9563. * @param camera The camera to apply the render pass to.
  9564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9565. * @param engine The engine which the post process will be applied. (default: current engine)
  9566. * @param reusable If the post process can be reused on the same frame. (default: false)
  9567. * @param textureType Type of textures used when performing the post process. (default: 0)
  9568. * @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)
  9569. */
  9570. constructor(name: string,
  9571. /** The direction in which to blur the image. */
  9572. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9573. /**
  9574. * Updates the effect with the current post process compile time values and recompiles the shader.
  9575. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9576. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9577. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9578. * @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
  9579. * @param onCompiled Called when the shader has been compiled.
  9580. * @param onError Called if there is an error when compiling a shader.
  9581. */
  9582. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9583. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9584. /**
  9585. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9586. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9587. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9588. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9589. * The gaps between physical kernels are compensated for in the weighting of the samples
  9590. * @param idealKernel Ideal blur kernel.
  9591. * @return Nearest best kernel.
  9592. */
  9593. protected _nearestBestKernel(idealKernel: number): number;
  9594. /**
  9595. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9596. * @param x The point on the Gaussian distribution to sample.
  9597. * @return the value of the Gaussian function at x.
  9598. */
  9599. protected _gaussianWeight(x: number): number;
  9600. /**
  9601. * Generates a string that can be used as a floating point number in GLSL.
  9602. * @param x Value to print.
  9603. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9604. * @return GLSL float string.
  9605. */
  9606. protected _glslFloat(x: number, decimalFigures?: number): string;
  9607. }
  9608. }
  9609. declare module BABYLON {
  9610. /** @hidden */
  9611. export var shadowMapPixelShader: {
  9612. name: string;
  9613. shader: string;
  9614. };
  9615. }
  9616. declare module BABYLON {
  9617. /** @hidden */
  9618. export var bonesDeclaration: {
  9619. name: string;
  9620. shader: string;
  9621. };
  9622. }
  9623. declare module BABYLON {
  9624. /** @hidden */
  9625. export var morphTargetsVertexGlobalDeclaration: {
  9626. name: string;
  9627. shader: string;
  9628. };
  9629. }
  9630. declare module BABYLON {
  9631. /** @hidden */
  9632. export var morphTargetsVertexDeclaration: {
  9633. name: string;
  9634. shader: string;
  9635. };
  9636. }
  9637. declare module BABYLON {
  9638. /** @hidden */
  9639. export var instancesDeclaration: {
  9640. name: string;
  9641. shader: string;
  9642. };
  9643. }
  9644. declare module BABYLON {
  9645. /** @hidden */
  9646. export var helperFunctions: {
  9647. name: string;
  9648. shader: string;
  9649. };
  9650. }
  9651. declare module BABYLON {
  9652. /** @hidden */
  9653. export var morphTargetsVertex: {
  9654. name: string;
  9655. shader: string;
  9656. };
  9657. }
  9658. declare module BABYLON {
  9659. /** @hidden */
  9660. export var instancesVertex: {
  9661. name: string;
  9662. shader: string;
  9663. };
  9664. }
  9665. declare module BABYLON {
  9666. /** @hidden */
  9667. export var bonesVertex: {
  9668. name: string;
  9669. shader: string;
  9670. };
  9671. }
  9672. declare module BABYLON {
  9673. /** @hidden */
  9674. export var shadowMapVertexShader: {
  9675. name: string;
  9676. shader: string;
  9677. };
  9678. }
  9679. declare module BABYLON {
  9680. /** @hidden */
  9681. export var depthBoxBlurPixelShader: {
  9682. name: string;
  9683. shader: string;
  9684. };
  9685. }
  9686. declare module BABYLON {
  9687. /**
  9688. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9689. */
  9690. export interface ICustomShaderOptions {
  9691. /**
  9692. * Gets or sets the custom shader name to use
  9693. */
  9694. shaderName: string;
  9695. /**
  9696. * The list of attribute names used in the shader
  9697. */
  9698. attributes?: string[];
  9699. /**
  9700. * The list of unifrom names used in the shader
  9701. */
  9702. uniforms?: string[];
  9703. /**
  9704. * The list of sampler names used in the shader
  9705. */
  9706. samplers?: string[];
  9707. /**
  9708. * The list of defines used in the shader
  9709. */
  9710. defines?: string[];
  9711. }
  9712. /**
  9713. * Interface to implement to create a shadow generator compatible with BJS.
  9714. */
  9715. export interface IShadowGenerator {
  9716. /**
  9717. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9718. * @returns The render target texture if present otherwise, null
  9719. */
  9720. getShadowMap(): Nullable<RenderTargetTexture>;
  9721. /**
  9722. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9723. * @returns The render target texture if the shadow map is present otherwise, null
  9724. */
  9725. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9726. /**
  9727. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9728. * @param subMesh The submesh we want to render in the shadow map
  9729. * @param useInstances Defines wether will draw in the map using instances
  9730. * @returns true if ready otherwise, false
  9731. */
  9732. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9733. /**
  9734. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9735. * @param defines Defines of the material we want to update
  9736. * @param lightIndex Index of the light in the enabled light list of the material
  9737. */
  9738. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9739. /**
  9740. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9741. * defined in the generator but impacting the effect).
  9742. * It implies the unifroms available on the materials are the standard BJS ones.
  9743. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9744. * @param effect The effect we are binfing the information for
  9745. */
  9746. bindShadowLight(lightIndex: string, effect: Effect): void;
  9747. /**
  9748. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9749. * (eq to shadow prjection matrix * light transform matrix)
  9750. * @returns The transform matrix used to create the shadow map
  9751. */
  9752. getTransformMatrix(): Matrix;
  9753. /**
  9754. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9755. * Cube and 2D textures for instance.
  9756. */
  9757. recreateShadowMap(): void;
  9758. /**
  9759. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9760. * @param onCompiled Callback triggered at the and of the effects compilation
  9761. * @param options Sets of optional options forcing the compilation with different modes
  9762. */
  9763. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9764. useInstances: boolean;
  9765. }>): void;
  9766. /**
  9767. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9768. * @param options Sets of optional options forcing the compilation with different modes
  9769. * @returns A promise that resolves when the compilation completes
  9770. */
  9771. forceCompilationAsync(options?: Partial<{
  9772. useInstances: boolean;
  9773. }>): Promise<void>;
  9774. /**
  9775. * Serializes the shadow generator setup to a json object.
  9776. * @returns The serialized JSON object
  9777. */
  9778. serialize(): any;
  9779. /**
  9780. * Disposes the Shadow map and related Textures and effects.
  9781. */
  9782. dispose(): void;
  9783. }
  9784. /**
  9785. * Default implementation IShadowGenerator.
  9786. * This is the main object responsible of generating shadows in the framework.
  9787. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9788. */
  9789. export class ShadowGenerator implements IShadowGenerator {
  9790. /**
  9791. * Shadow generator mode None: no filtering applied.
  9792. */
  9793. static readonly FILTER_NONE: number;
  9794. /**
  9795. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9796. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9797. */
  9798. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9799. /**
  9800. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9801. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9802. */
  9803. static readonly FILTER_POISSONSAMPLING: number;
  9804. /**
  9805. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9806. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9807. */
  9808. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9809. /**
  9810. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9811. * edge artifacts on steep falloff.
  9812. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9813. */
  9814. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9815. /**
  9816. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9817. * edge artifacts on steep falloff.
  9818. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9819. */
  9820. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9821. /**
  9822. * Shadow generator mode PCF: Percentage Closer Filtering
  9823. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9824. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9825. */
  9826. static readonly FILTER_PCF: number;
  9827. /**
  9828. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9829. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9830. * Contact Hardening
  9831. */
  9832. static readonly FILTER_PCSS: number;
  9833. /**
  9834. * Reserved for PCF and PCSS
  9835. * Highest Quality.
  9836. *
  9837. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9838. *
  9839. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9840. */
  9841. static readonly QUALITY_HIGH: number;
  9842. /**
  9843. * Reserved for PCF and PCSS
  9844. * Good tradeoff for quality/perf cross devices
  9845. *
  9846. * Execute PCF on a 3*3 kernel.
  9847. *
  9848. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9849. */
  9850. static readonly QUALITY_MEDIUM: number;
  9851. /**
  9852. * Reserved for PCF and PCSS
  9853. * The lowest quality but the fastest.
  9854. *
  9855. * Execute PCF on a 1*1 kernel.
  9856. *
  9857. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9858. */
  9859. static readonly QUALITY_LOW: number;
  9860. /** Gets or sets the custom shader name to use */
  9861. customShaderOptions: ICustomShaderOptions;
  9862. /**
  9863. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9864. */
  9865. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9866. /**
  9867. * Observable triggered before a mesh is rendered in the shadow map.
  9868. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9869. */
  9870. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9871. private _bias;
  9872. /**
  9873. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9874. */
  9875. /**
  9876. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9877. */
  9878. bias: number;
  9879. private _normalBias;
  9880. /**
  9881. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9882. */
  9883. /**
  9884. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9885. */
  9886. normalBias: number;
  9887. private _blurBoxOffset;
  9888. /**
  9889. * Gets the blur box offset: offset applied during the blur pass.
  9890. * Only useful if useKernelBlur = false
  9891. */
  9892. /**
  9893. * Sets the blur box offset: offset applied during the blur pass.
  9894. * Only useful if useKernelBlur = false
  9895. */
  9896. blurBoxOffset: number;
  9897. private _blurScale;
  9898. /**
  9899. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9900. * 2 means half of the size.
  9901. */
  9902. /**
  9903. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9904. * 2 means half of the size.
  9905. */
  9906. blurScale: number;
  9907. private _blurKernel;
  9908. /**
  9909. * Gets the blur kernel: kernel size of the blur pass.
  9910. * Only useful if useKernelBlur = true
  9911. */
  9912. /**
  9913. * Sets the blur kernel: kernel size of the blur pass.
  9914. * Only useful if useKernelBlur = true
  9915. */
  9916. blurKernel: number;
  9917. private _useKernelBlur;
  9918. /**
  9919. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9920. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9921. */
  9922. /**
  9923. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9924. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9925. */
  9926. useKernelBlur: boolean;
  9927. private _depthScale;
  9928. /**
  9929. * Gets the depth scale used in ESM mode.
  9930. */
  9931. /**
  9932. * Sets the depth scale used in ESM mode.
  9933. * This can override the scale stored on the light.
  9934. */
  9935. depthScale: number;
  9936. private _filter;
  9937. /**
  9938. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9939. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9940. */
  9941. /**
  9942. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9943. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9944. */
  9945. filter: number;
  9946. /**
  9947. * Gets if the current filter is set to Poisson Sampling.
  9948. */
  9949. /**
  9950. * Sets the current filter to Poisson Sampling.
  9951. */
  9952. usePoissonSampling: boolean;
  9953. /**
  9954. * Gets if the current filter is set to ESM.
  9955. */
  9956. /**
  9957. * Sets the current filter is to ESM.
  9958. */
  9959. useExponentialShadowMap: boolean;
  9960. /**
  9961. * Gets if the current filter is set to filtered ESM.
  9962. */
  9963. /**
  9964. * Gets if the current filter is set to filtered ESM.
  9965. */
  9966. useBlurExponentialShadowMap: boolean;
  9967. /**
  9968. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9969. * exponential to prevent steep falloff artifacts).
  9970. */
  9971. /**
  9972. * Sets the current filter to "close ESM" (using the inverse of the
  9973. * exponential to prevent steep falloff artifacts).
  9974. */
  9975. useCloseExponentialShadowMap: boolean;
  9976. /**
  9977. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9978. * exponential to prevent steep falloff artifacts).
  9979. */
  9980. /**
  9981. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9982. * exponential to prevent steep falloff artifacts).
  9983. */
  9984. useBlurCloseExponentialShadowMap: boolean;
  9985. /**
  9986. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9987. */
  9988. /**
  9989. * Sets the current filter to "PCF" (percentage closer filtering).
  9990. */
  9991. usePercentageCloserFiltering: boolean;
  9992. private _filteringQuality;
  9993. /**
  9994. * Gets the PCF or PCSS Quality.
  9995. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9996. */
  9997. /**
  9998. * Sets the PCF or PCSS Quality.
  9999. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10000. */
  10001. filteringQuality: number;
  10002. /**
  10003. * Gets if the current filter is set to "PCSS" (contact hardening).
  10004. */
  10005. /**
  10006. * Sets the current filter to "PCSS" (contact hardening).
  10007. */
  10008. useContactHardeningShadow: boolean;
  10009. private _contactHardeningLightSizeUVRatio;
  10010. /**
  10011. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10012. * Using a ratio helps keeping shape stability independently of the map size.
  10013. *
  10014. * It does not account for the light projection as it was having too much
  10015. * instability during the light setup or during light position changes.
  10016. *
  10017. * Only valid if useContactHardeningShadow is true.
  10018. */
  10019. /**
  10020. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10021. * Using a ratio helps keeping shape stability independently of the map size.
  10022. *
  10023. * It does not account for the light projection as it was having too much
  10024. * instability during the light setup or during light position changes.
  10025. *
  10026. * Only valid if useContactHardeningShadow is true.
  10027. */
  10028. contactHardeningLightSizeUVRatio: number;
  10029. private _darkness;
  10030. /**
  10031. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10032. * 0 means strongest and 1 would means no shadow.
  10033. * @returns the darkness.
  10034. */
  10035. getDarkness(): number;
  10036. /**
  10037. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10038. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10039. * @returns the shadow generator allowing fluent coding.
  10040. */
  10041. setDarkness(darkness: number): ShadowGenerator;
  10042. private _transparencyShadow;
  10043. /**
  10044. * Sets the ability to have transparent shadow (boolean).
  10045. * @param transparent True if transparent else False
  10046. * @returns the shadow generator allowing fluent coding
  10047. */
  10048. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10049. private _shadowMap;
  10050. private _shadowMap2;
  10051. /**
  10052. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10053. * @returns The render target texture if present otherwise, null
  10054. */
  10055. getShadowMap(): Nullable<RenderTargetTexture>;
  10056. /**
  10057. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10058. * @returns The render target texture if the shadow map is present otherwise, null
  10059. */
  10060. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10061. /**
  10062. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10063. * @param mesh Mesh to add
  10064. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10065. * @returns the Shadow Generator itself
  10066. */
  10067. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10068. /**
  10069. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10070. * @param mesh Mesh to remove
  10071. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10072. * @returns the Shadow Generator itself
  10073. */
  10074. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10075. /**
  10076. * Controls the extent to which the shadows fade out at the edge of the frustum
  10077. * Used only by directionals and spots
  10078. */
  10079. frustumEdgeFalloff: number;
  10080. private _light;
  10081. /**
  10082. * Returns the associated light object.
  10083. * @returns the light generating the shadow
  10084. */
  10085. getLight(): IShadowLight;
  10086. /**
  10087. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10088. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10089. * It might on the other hand introduce peter panning.
  10090. */
  10091. forceBackFacesOnly: boolean;
  10092. private _scene;
  10093. private _lightDirection;
  10094. private _effect;
  10095. private _viewMatrix;
  10096. private _projectionMatrix;
  10097. private _transformMatrix;
  10098. private _cachedPosition;
  10099. private _cachedDirection;
  10100. private _cachedDefines;
  10101. private _currentRenderID;
  10102. private _boxBlurPostprocess;
  10103. private _kernelBlurXPostprocess;
  10104. private _kernelBlurYPostprocess;
  10105. private _blurPostProcesses;
  10106. private _mapSize;
  10107. private _currentFaceIndex;
  10108. private _currentFaceIndexCache;
  10109. private _textureType;
  10110. private _defaultTextureMatrix;
  10111. /** @hidden */
  10112. static _SceneComponentInitialization: (scene: Scene) => void;
  10113. /**
  10114. * Creates a ShadowGenerator object.
  10115. * A ShadowGenerator is the required tool to use the shadows.
  10116. * Each light casting shadows needs to use its own ShadowGenerator.
  10117. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10118. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10119. * @param light The light object generating the shadows.
  10120. * @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.
  10121. */
  10122. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10123. private _initializeGenerator;
  10124. private _initializeShadowMap;
  10125. private _initializeBlurRTTAndPostProcesses;
  10126. private _renderForShadowMap;
  10127. private _renderSubMeshForShadowMap;
  10128. private _applyFilterValues;
  10129. /**
  10130. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10131. * @param onCompiled Callback triggered at the and of the effects compilation
  10132. * @param options Sets of optional options forcing the compilation with different modes
  10133. */
  10134. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10135. useInstances: boolean;
  10136. }>): void;
  10137. /**
  10138. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10139. * @param options Sets of optional options forcing the compilation with different modes
  10140. * @returns A promise that resolves when the compilation completes
  10141. */
  10142. forceCompilationAsync(options?: Partial<{
  10143. useInstances: boolean;
  10144. }>): Promise<void>;
  10145. /**
  10146. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10147. * @param subMesh The submesh we want to render in the shadow map
  10148. * @param useInstances Defines wether will draw in the map using instances
  10149. * @returns true if ready otherwise, false
  10150. */
  10151. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10152. /**
  10153. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10154. * @param defines Defines of the material we want to update
  10155. * @param lightIndex Index of the light in the enabled light list of the material
  10156. */
  10157. prepareDefines(defines: any, lightIndex: number): void;
  10158. /**
  10159. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10160. * defined in the generator but impacting the effect).
  10161. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10162. * @param effect The effect we are binfing the information for
  10163. */
  10164. bindShadowLight(lightIndex: string, effect: Effect): void;
  10165. /**
  10166. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10167. * (eq to shadow prjection matrix * light transform matrix)
  10168. * @returns The transform matrix used to create the shadow map
  10169. */
  10170. getTransformMatrix(): Matrix;
  10171. /**
  10172. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10173. * Cube and 2D textures for instance.
  10174. */
  10175. recreateShadowMap(): void;
  10176. private _disposeBlurPostProcesses;
  10177. private _disposeRTTandPostProcesses;
  10178. /**
  10179. * Disposes the ShadowGenerator.
  10180. * Returns nothing.
  10181. */
  10182. dispose(): void;
  10183. /**
  10184. * Serializes the shadow generator setup to a json object.
  10185. * @returns The serialized JSON object
  10186. */
  10187. serialize(): any;
  10188. /**
  10189. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10190. * @param parsedShadowGenerator The JSON object to parse
  10191. * @param scene The scene to create the shadow map for
  10192. * @returns The parsed shadow generator
  10193. */
  10194. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10195. }
  10196. }
  10197. declare module BABYLON {
  10198. /**
  10199. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10200. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10201. * 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.
  10202. */
  10203. export abstract class Light extends Node {
  10204. /**
  10205. * Falloff Default: light is falling off following the material specification:
  10206. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10207. */
  10208. static readonly FALLOFF_DEFAULT: number;
  10209. /**
  10210. * Falloff Physical: light is falling off following the inverse squared distance law.
  10211. */
  10212. static readonly FALLOFF_PHYSICAL: number;
  10213. /**
  10214. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10215. * to enhance interoperability with other engines.
  10216. */
  10217. static readonly FALLOFF_GLTF: number;
  10218. /**
  10219. * Falloff Standard: light is falling off like in the standard material
  10220. * to enhance interoperability with other materials.
  10221. */
  10222. static readonly FALLOFF_STANDARD: number;
  10223. /**
  10224. * If every light affecting the material is in this lightmapMode,
  10225. * material.lightmapTexture adds or multiplies
  10226. * (depends on material.useLightmapAsShadowmap)
  10227. * after every other light calculations.
  10228. */
  10229. static readonly LIGHTMAP_DEFAULT: number;
  10230. /**
  10231. * material.lightmapTexture as only diffuse lighting from this light
  10232. * adds only specular lighting from this light
  10233. * adds dynamic shadows
  10234. */
  10235. static readonly LIGHTMAP_SPECULAR: number;
  10236. /**
  10237. * material.lightmapTexture as only lighting
  10238. * no light calculation from this light
  10239. * only adds dynamic shadows from this light
  10240. */
  10241. static readonly LIGHTMAP_SHADOWSONLY: number;
  10242. /**
  10243. * Each light type uses the default quantity according to its type:
  10244. * point/spot lights use luminous intensity
  10245. * directional lights use illuminance
  10246. */
  10247. static readonly INTENSITYMODE_AUTOMATIC: number;
  10248. /**
  10249. * lumen (lm)
  10250. */
  10251. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10252. /**
  10253. * candela (lm/sr)
  10254. */
  10255. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10256. /**
  10257. * lux (lm/m^2)
  10258. */
  10259. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10260. /**
  10261. * nit (cd/m^2)
  10262. */
  10263. static readonly INTENSITYMODE_LUMINANCE: number;
  10264. /**
  10265. * Light type const id of the point light.
  10266. */
  10267. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10268. /**
  10269. * Light type const id of the directional light.
  10270. */
  10271. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10272. /**
  10273. * Light type const id of the spot light.
  10274. */
  10275. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10276. /**
  10277. * Light type const id of the hemispheric light.
  10278. */
  10279. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10280. /**
  10281. * Diffuse gives the basic color to an object.
  10282. */
  10283. diffuse: Color3;
  10284. /**
  10285. * Specular produces a highlight color on an object.
  10286. * Note: This is note affecting PBR materials.
  10287. */
  10288. specular: Color3;
  10289. /**
  10290. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10291. * falling off base on range or angle.
  10292. * This can be set to any values in Light.FALLOFF_x.
  10293. *
  10294. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10295. * other types of materials.
  10296. */
  10297. falloffType: number;
  10298. /**
  10299. * Strength of the light.
  10300. * Note: By default it is define in the framework own unit.
  10301. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10302. */
  10303. intensity: number;
  10304. private _range;
  10305. protected _inverseSquaredRange: number;
  10306. /**
  10307. * Defines how far from the source the light is impacting in scene units.
  10308. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10309. */
  10310. /**
  10311. * Defines how far from the source the light is impacting in scene units.
  10312. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10313. */
  10314. range: number;
  10315. /**
  10316. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10317. * of light.
  10318. */
  10319. private _photometricScale;
  10320. private _intensityMode;
  10321. /**
  10322. * Gets the photometric scale used to interpret the intensity.
  10323. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10324. */
  10325. /**
  10326. * Sets the photometric scale used to interpret the intensity.
  10327. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10328. */
  10329. intensityMode: number;
  10330. private _radius;
  10331. /**
  10332. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10333. */
  10334. /**
  10335. * sets the light radius used by PBR Materials to simulate soft area lights.
  10336. */
  10337. radius: number;
  10338. private _renderPriority;
  10339. /**
  10340. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10341. * exceeding the number allowed of the materials.
  10342. */
  10343. renderPriority: number;
  10344. private _shadowEnabled;
  10345. /**
  10346. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10347. * the current shadow generator.
  10348. */
  10349. /**
  10350. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10351. * the current shadow generator.
  10352. */
  10353. shadowEnabled: boolean;
  10354. private _includedOnlyMeshes;
  10355. /**
  10356. * Gets the only meshes impacted by this light.
  10357. */
  10358. /**
  10359. * Sets the only meshes impacted by this light.
  10360. */
  10361. includedOnlyMeshes: AbstractMesh[];
  10362. private _excludedMeshes;
  10363. /**
  10364. * Gets the meshes not impacted by this light.
  10365. */
  10366. /**
  10367. * Sets the meshes not impacted by this light.
  10368. */
  10369. excludedMeshes: AbstractMesh[];
  10370. private _excludeWithLayerMask;
  10371. /**
  10372. * Gets the layer id use to find what meshes are not impacted by the light.
  10373. * Inactive if 0
  10374. */
  10375. /**
  10376. * Sets the layer id use to find what meshes are not impacted by the light.
  10377. * Inactive if 0
  10378. */
  10379. excludeWithLayerMask: number;
  10380. private _includeOnlyWithLayerMask;
  10381. /**
  10382. * Gets the layer id use to find what meshes are impacted by the light.
  10383. * Inactive if 0
  10384. */
  10385. /**
  10386. * Sets the layer id use to find what meshes are impacted by the light.
  10387. * Inactive if 0
  10388. */
  10389. includeOnlyWithLayerMask: number;
  10390. private _lightmapMode;
  10391. /**
  10392. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10393. */
  10394. /**
  10395. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10396. */
  10397. lightmapMode: number;
  10398. /**
  10399. * Shadow generator associted to the light.
  10400. * @hidden Internal use only.
  10401. */
  10402. _shadowGenerator: Nullable<IShadowGenerator>;
  10403. /**
  10404. * @hidden Internal use only.
  10405. */
  10406. _excludedMeshesIds: string[];
  10407. /**
  10408. * @hidden Internal use only.
  10409. */
  10410. _includedOnlyMeshesIds: string[];
  10411. /**
  10412. * The current light unifom buffer.
  10413. * @hidden Internal use only.
  10414. */
  10415. _uniformBuffer: UniformBuffer;
  10416. /**
  10417. * Creates a Light object in the scene.
  10418. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10419. * @param name The firendly name of the light
  10420. * @param scene The scene the light belongs too
  10421. */
  10422. constructor(name: string, scene: Scene);
  10423. protected abstract _buildUniformLayout(): void;
  10424. /**
  10425. * Sets the passed Effect "effect" with the Light information.
  10426. * @param effect The effect to update
  10427. * @param lightIndex The index of the light in the effect to update
  10428. * @returns The light
  10429. */
  10430. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10431. /**
  10432. * Returns the string "Light".
  10433. * @returns the class name
  10434. */
  10435. getClassName(): string;
  10436. /** @hidden */
  10437. readonly _isLight: boolean;
  10438. /**
  10439. * Converts the light information to a readable string for debug purpose.
  10440. * @param fullDetails Supports for multiple levels of logging within scene loading
  10441. * @returns the human readable light info
  10442. */
  10443. toString(fullDetails?: boolean): string;
  10444. /** @hidden */
  10445. protected _syncParentEnabledState(): void;
  10446. /**
  10447. * Set the enabled state of this node.
  10448. * @param value - the new enabled state
  10449. */
  10450. setEnabled(value: boolean): void;
  10451. /**
  10452. * Returns the Light associated shadow generator if any.
  10453. * @return the associated shadow generator.
  10454. */
  10455. getShadowGenerator(): Nullable<IShadowGenerator>;
  10456. /**
  10457. * Returns a Vector3, the absolute light position in the World.
  10458. * @returns the world space position of the light
  10459. */
  10460. getAbsolutePosition(): Vector3;
  10461. /**
  10462. * Specifies if the light will affect the passed mesh.
  10463. * @param mesh The mesh to test against the light
  10464. * @return true the mesh is affected otherwise, false.
  10465. */
  10466. canAffectMesh(mesh: AbstractMesh): boolean;
  10467. /**
  10468. * Sort function to order lights for rendering.
  10469. * @param a First Light object to compare to second.
  10470. * @param b Second Light object to compare first.
  10471. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10472. */
  10473. static CompareLightsPriority(a: Light, b: Light): number;
  10474. /**
  10475. * Releases resources associated with this node.
  10476. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10477. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10478. */
  10479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10480. /**
  10481. * Returns the light type ID (integer).
  10482. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10483. */
  10484. getTypeID(): number;
  10485. /**
  10486. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10487. * @returns the scaled intensity in intensity mode unit
  10488. */
  10489. getScaledIntensity(): number;
  10490. /**
  10491. * Returns a new Light object, named "name", from the current one.
  10492. * @param name The name of the cloned light
  10493. * @returns the new created light
  10494. */
  10495. clone(name: string): Nullable<Light>;
  10496. /**
  10497. * Serializes the current light into a Serialization object.
  10498. * @returns the serialized object.
  10499. */
  10500. serialize(): any;
  10501. /**
  10502. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10503. * This new light is named "name" and added to the passed scene.
  10504. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10505. * @param name The friendly name of the light
  10506. * @param scene The scene the new light will belong to
  10507. * @returns the constructor function
  10508. */
  10509. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10510. /**
  10511. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10512. * @param parsedLight The JSON representation of the light
  10513. * @param scene The scene to create the parsed light in
  10514. * @returns the created light after parsing
  10515. */
  10516. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10517. private _hookArrayForExcluded;
  10518. private _hookArrayForIncludedOnly;
  10519. private _resyncMeshes;
  10520. /**
  10521. * Forces the meshes to update their light related information in their rendering used effects
  10522. * @hidden Internal Use Only
  10523. */
  10524. _markMeshesAsLightDirty(): void;
  10525. /**
  10526. * Recomputes the cached photometric scale if needed.
  10527. */
  10528. private _computePhotometricScale;
  10529. /**
  10530. * Returns the Photometric Scale according to the light type and intensity mode.
  10531. */
  10532. private _getPhotometricScale;
  10533. /**
  10534. * Reorder the light in the scene according to their defined priority.
  10535. * @hidden Internal Use Only
  10536. */
  10537. _reorderLightsInScene(): void;
  10538. /**
  10539. * Prepares the list of defines specific to the light type.
  10540. * @param defines the list of defines
  10541. * @param lightIndex defines the index of the light for the effect
  10542. */
  10543. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10544. }
  10545. }
  10546. declare module BABYLON {
  10547. /**
  10548. * Interface used to define Action
  10549. */
  10550. export interface IAction {
  10551. /**
  10552. * Trigger for the action
  10553. */
  10554. trigger: number;
  10555. /** Options of the trigger */
  10556. triggerOptions: any;
  10557. /**
  10558. * Gets the trigger parameters
  10559. * @returns the trigger parameters
  10560. */
  10561. getTriggerParameter(): any;
  10562. /**
  10563. * Internal only - executes current action event
  10564. * @hidden
  10565. */
  10566. _executeCurrent(evt?: ActionEvent): void;
  10567. /**
  10568. * Serialize placeholder for child classes
  10569. * @param parent of child
  10570. * @returns the serialized object
  10571. */
  10572. serialize(parent: any): any;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. _prepare(): void;
  10578. /**
  10579. * Internal only - manager for action
  10580. * @hidden
  10581. */
  10582. _actionManager: AbstractActionManager;
  10583. }
  10584. /**
  10585. * The action to be carried out following a trigger
  10586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10587. */
  10588. export class Action implements IAction {
  10589. /** the trigger, with or without parameters, for the action */
  10590. triggerOptions: any;
  10591. /**
  10592. * Trigger for the action
  10593. */
  10594. trigger: number;
  10595. /**
  10596. * Internal only - manager for action
  10597. * @hidden
  10598. */
  10599. _actionManager: ActionManager;
  10600. private _nextActiveAction;
  10601. private _child;
  10602. private _condition?;
  10603. private _triggerParameter;
  10604. /**
  10605. * An event triggered prior to action being executed.
  10606. */
  10607. onBeforeExecuteObservable: Observable<Action>;
  10608. /**
  10609. * Creates a new Action
  10610. * @param triggerOptions the trigger, with or without parameters, for the action
  10611. * @param condition an optional determinant of action
  10612. */
  10613. constructor(
  10614. /** the trigger, with or without parameters, for the action */
  10615. triggerOptions: any, condition?: Condition);
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. _prepare(): void;
  10621. /**
  10622. * Gets the trigger parameters
  10623. * @returns the trigger parameters
  10624. */
  10625. getTriggerParameter(): any;
  10626. /**
  10627. * Internal only - executes current action event
  10628. * @hidden
  10629. */
  10630. _executeCurrent(evt?: ActionEvent): void;
  10631. /**
  10632. * Execute placeholder for child classes
  10633. * @param evt optional action event
  10634. */
  10635. execute(evt?: ActionEvent): void;
  10636. /**
  10637. * Skips to next active action
  10638. */
  10639. skipToNextActiveAction(): void;
  10640. /**
  10641. * Adds action to chain of actions, may be a DoNothingAction
  10642. * @param action defines the next action to execute
  10643. * @returns The action passed in
  10644. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10645. */
  10646. then(action: Action): Action;
  10647. /**
  10648. * Internal only
  10649. * @hidden
  10650. */
  10651. _getProperty(propertyPath: string): string;
  10652. /**
  10653. * Internal only
  10654. * @hidden
  10655. */
  10656. _getEffectiveTarget(target: any, propertyPath: string): any;
  10657. /**
  10658. * Serialize placeholder for child classes
  10659. * @param parent of child
  10660. * @returns the serialized object
  10661. */
  10662. serialize(parent: any): any;
  10663. /**
  10664. * Internal only called by serialize
  10665. * @hidden
  10666. */
  10667. protected _serialize(serializedAction: any, parent?: any): any;
  10668. /**
  10669. * Internal only
  10670. * @hidden
  10671. */
  10672. static _SerializeValueAsString: (value: any) => string;
  10673. /**
  10674. * Internal only
  10675. * @hidden
  10676. */
  10677. static _GetTargetProperty: (target: Scene | Node) => {
  10678. name: string;
  10679. targetType: string;
  10680. value: string;
  10681. };
  10682. }
  10683. }
  10684. declare module BABYLON {
  10685. /**
  10686. * A Condition applied to an Action
  10687. */
  10688. export class Condition {
  10689. /**
  10690. * Internal only - manager for action
  10691. * @hidden
  10692. */
  10693. _actionManager: ActionManager;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. _evaluationId: number;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. _currentResult: boolean;
  10704. /**
  10705. * Creates a new Condition
  10706. * @param actionManager the manager of the action the condition is applied to
  10707. */
  10708. constructor(actionManager: ActionManager);
  10709. /**
  10710. * Check if the current condition is valid
  10711. * @returns a boolean
  10712. */
  10713. isValid(): boolean;
  10714. /**
  10715. * Internal only
  10716. * @hidden
  10717. */
  10718. _getProperty(propertyPath: string): string;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. _getEffectiveTarget(target: any, propertyPath: string): any;
  10724. /**
  10725. * Serialize placeholder for child classes
  10726. * @returns the serialized object
  10727. */
  10728. serialize(): any;
  10729. /**
  10730. * Internal only
  10731. * @hidden
  10732. */
  10733. protected _serialize(serializedCondition: any): any;
  10734. }
  10735. /**
  10736. * Defines specific conditional operators as extensions of Condition
  10737. */
  10738. export class ValueCondition extends Condition {
  10739. /** path to specify the property of the target the conditional operator uses */
  10740. propertyPath: string;
  10741. /** the value compared by the conditional operator against the current value of the property */
  10742. value: any;
  10743. /** the conditional operator, default ValueCondition.IsEqual */
  10744. operator: number;
  10745. /**
  10746. * Internal only
  10747. * @hidden
  10748. */
  10749. private static _IsEqual;
  10750. /**
  10751. * Internal only
  10752. * @hidden
  10753. */
  10754. private static _IsDifferent;
  10755. /**
  10756. * Internal only
  10757. * @hidden
  10758. */
  10759. private static _IsGreater;
  10760. /**
  10761. * Internal only
  10762. * @hidden
  10763. */
  10764. private static _IsLesser;
  10765. /**
  10766. * returns the number for IsEqual
  10767. */
  10768. static readonly IsEqual: number;
  10769. /**
  10770. * Returns the number for IsDifferent
  10771. */
  10772. static readonly IsDifferent: number;
  10773. /**
  10774. * Returns the number for IsGreater
  10775. */
  10776. static readonly IsGreater: number;
  10777. /**
  10778. * Returns the number for IsLesser
  10779. */
  10780. static readonly IsLesser: number;
  10781. /**
  10782. * Internal only The action manager for the condition
  10783. * @hidden
  10784. */
  10785. _actionManager: ActionManager;
  10786. /**
  10787. * Internal only
  10788. * @hidden
  10789. */
  10790. private _target;
  10791. /**
  10792. * Internal only
  10793. * @hidden
  10794. */
  10795. private _effectiveTarget;
  10796. /**
  10797. * Internal only
  10798. * @hidden
  10799. */
  10800. private _property;
  10801. /**
  10802. * Creates a new ValueCondition
  10803. * @param actionManager manager for the action the condition applies to
  10804. * @param target for the action
  10805. * @param propertyPath path to specify the property of the target the conditional operator uses
  10806. * @param value the value compared by the conditional operator against the current value of the property
  10807. * @param operator the conditional operator, default ValueCondition.IsEqual
  10808. */
  10809. constructor(actionManager: ActionManager, target: any,
  10810. /** path to specify the property of the target the conditional operator uses */
  10811. propertyPath: string,
  10812. /** the value compared by the conditional operator against the current value of the property */
  10813. value: any,
  10814. /** the conditional operator, default ValueCondition.IsEqual */
  10815. operator?: number);
  10816. /**
  10817. * Compares the given value with the property value for the specified conditional operator
  10818. * @returns the result of the comparison
  10819. */
  10820. isValid(): boolean;
  10821. /**
  10822. * Serialize the ValueCondition into a JSON compatible object
  10823. * @returns serialization object
  10824. */
  10825. serialize(): any;
  10826. /**
  10827. * Gets the name of the conditional operator for the ValueCondition
  10828. * @param operator the conditional operator
  10829. * @returns the name
  10830. */
  10831. static GetOperatorName(operator: number): string;
  10832. }
  10833. /**
  10834. * Defines a predicate condition as an extension of Condition
  10835. */
  10836. export class PredicateCondition extends Condition {
  10837. /** defines the predicate function used to validate the condition */
  10838. predicate: () => boolean;
  10839. /**
  10840. * Internal only - manager for action
  10841. * @hidden
  10842. */
  10843. _actionManager: ActionManager;
  10844. /**
  10845. * Creates a new PredicateCondition
  10846. * @param actionManager manager for the action the condition applies to
  10847. * @param predicate defines the predicate function used to validate the condition
  10848. */
  10849. constructor(actionManager: ActionManager,
  10850. /** defines the predicate function used to validate the condition */
  10851. predicate: () => boolean);
  10852. /**
  10853. * @returns the validity of the predicate condition
  10854. */
  10855. isValid(): boolean;
  10856. }
  10857. /**
  10858. * Defines a state condition as an extension of Condition
  10859. */
  10860. export class StateCondition extends Condition {
  10861. /** Value to compare with target state */
  10862. value: string;
  10863. /**
  10864. * Internal only - manager for action
  10865. * @hidden
  10866. */
  10867. _actionManager: ActionManager;
  10868. /**
  10869. * Internal only
  10870. * @hidden
  10871. */
  10872. private _target;
  10873. /**
  10874. * Creates a new StateCondition
  10875. * @param actionManager manager for the action the condition applies to
  10876. * @param target of the condition
  10877. * @param value to compare with target state
  10878. */
  10879. constructor(actionManager: ActionManager, target: any,
  10880. /** Value to compare with target state */
  10881. value: string);
  10882. /**
  10883. * Gets a boolean indicating if the current condition is met
  10884. * @returns the validity of the state
  10885. */
  10886. isValid(): boolean;
  10887. /**
  10888. * Serialize the StateCondition into a JSON compatible object
  10889. * @returns serialization object
  10890. */
  10891. serialize(): any;
  10892. }
  10893. }
  10894. declare module BABYLON {
  10895. /**
  10896. * This defines an action responsible to toggle a boolean once triggered.
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10898. */
  10899. export class SwitchBooleanAction extends Action {
  10900. /**
  10901. * The path to the boolean property in the target object
  10902. */
  10903. propertyPath: string;
  10904. private _target;
  10905. private _effectiveTarget;
  10906. private _property;
  10907. /**
  10908. * Instantiate the action
  10909. * @param triggerOptions defines the trigger options
  10910. * @param target defines the object containing the boolean
  10911. * @param propertyPath defines the path to the boolean property in the target object
  10912. * @param condition defines the trigger related conditions
  10913. */
  10914. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10915. /** @hidden */
  10916. _prepare(): void;
  10917. /**
  10918. * Execute the action toggle the boolean value.
  10919. */
  10920. execute(): void;
  10921. /**
  10922. * Serializes the actions and its related information.
  10923. * @param parent defines the object to serialize in
  10924. * @returns the serialized object
  10925. */
  10926. serialize(parent: any): any;
  10927. }
  10928. /**
  10929. * This defines an action responsible to set a the state field of the target
  10930. * to a desired value once triggered.
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10932. */
  10933. export class SetStateAction extends Action {
  10934. /**
  10935. * The value to store in the state field.
  10936. */
  10937. value: string;
  10938. private _target;
  10939. /**
  10940. * Instantiate the action
  10941. * @param triggerOptions defines the trigger options
  10942. * @param target defines the object containing the state property
  10943. * @param value defines the value to store in the state field
  10944. * @param condition defines the trigger related conditions
  10945. */
  10946. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10947. /**
  10948. * Execute the action and store the value on the target state property.
  10949. */
  10950. execute(): void;
  10951. /**
  10952. * Serializes the actions and its related information.
  10953. * @param parent defines the object to serialize in
  10954. * @returns the serialized object
  10955. */
  10956. serialize(parent: any): any;
  10957. }
  10958. /**
  10959. * This defines an action responsible to set a property of the target
  10960. * to a desired value once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class SetValueAction extends Action {
  10964. /**
  10965. * The path of the property to set in the target.
  10966. */
  10967. propertyPath: string;
  10968. /**
  10969. * The value to set in the property
  10970. */
  10971. value: any;
  10972. private _target;
  10973. private _effectiveTarget;
  10974. private _property;
  10975. /**
  10976. * Instantiate the action
  10977. * @param triggerOptions defines the trigger options
  10978. * @param target defines the object containing the property
  10979. * @param propertyPath defines the path of the property to set in the target
  10980. * @param value defines the value to set in the property
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10984. /** @hidden */
  10985. _prepare(): void;
  10986. /**
  10987. * Execute the action and set the targetted property to the desired value.
  10988. */
  10989. execute(): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. /**
  10998. * This defines an action responsible to increment the target value
  10999. * to a desired value once triggered.
  11000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11001. */
  11002. export class IncrementValueAction extends Action {
  11003. /**
  11004. * The path of the property to increment in the target.
  11005. */
  11006. propertyPath: string;
  11007. /**
  11008. * The value we should increment the property by.
  11009. */
  11010. value: any;
  11011. private _target;
  11012. private _effectiveTarget;
  11013. private _property;
  11014. /**
  11015. * Instantiate the action
  11016. * @param triggerOptions defines the trigger options
  11017. * @param target defines the object containing the property
  11018. * @param propertyPath defines the path of the property to increment in the target
  11019. * @param value defines the value value we should increment the property by
  11020. * @param condition defines the trigger related conditions
  11021. */
  11022. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11023. /** @hidden */
  11024. _prepare(): void;
  11025. /**
  11026. * Execute the action and increment the target of the value amount.
  11027. */
  11028. execute(): void;
  11029. /**
  11030. * Serializes the actions and its related information.
  11031. * @param parent defines the object to serialize in
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. }
  11036. /**
  11037. * This defines an action responsible to start an animation once triggered.
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11039. */
  11040. export class PlayAnimationAction extends Action {
  11041. /**
  11042. * Where the animation should start (animation frame)
  11043. */
  11044. from: number;
  11045. /**
  11046. * Where the animation should stop (animation frame)
  11047. */
  11048. to: number;
  11049. /**
  11050. * Define if the animation should loop or stop after the first play.
  11051. */
  11052. loop?: boolean;
  11053. private _target;
  11054. /**
  11055. * Instantiate the action
  11056. * @param triggerOptions defines the trigger options
  11057. * @param target defines the target animation or animation name
  11058. * @param from defines from where the animation should start (animation frame)
  11059. * @param end defines where the animation should stop (animation frame)
  11060. * @param loop defines if the animation should loop or stop after the first play
  11061. * @param condition defines the trigger related conditions
  11062. */
  11063. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11064. /** @hidden */
  11065. _prepare(): void;
  11066. /**
  11067. * Execute the action and play the animation.
  11068. */
  11069. execute(): void;
  11070. /**
  11071. * Serializes the actions and its related information.
  11072. * @param parent defines the object to serialize in
  11073. * @returns the serialized object
  11074. */
  11075. serialize(parent: any): any;
  11076. }
  11077. /**
  11078. * This defines an action responsible to stop an animation once triggered.
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11080. */
  11081. export class StopAnimationAction extends Action {
  11082. private _target;
  11083. /**
  11084. * Instantiate the action
  11085. * @param triggerOptions defines the trigger options
  11086. * @param target defines the target animation or animation name
  11087. * @param condition defines the trigger related conditions
  11088. */
  11089. constructor(triggerOptions: any, target: any, condition?: Condition);
  11090. /** @hidden */
  11091. _prepare(): void;
  11092. /**
  11093. * Execute the action and stop the animation.
  11094. */
  11095. execute(): void;
  11096. /**
  11097. * Serializes the actions and its related information.
  11098. * @param parent defines the object to serialize in
  11099. * @returns the serialized object
  11100. */
  11101. serialize(parent: any): any;
  11102. }
  11103. /**
  11104. * This defines an action responsible that does nothing once triggered.
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11106. */
  11107. export class DoNothingAction extends Action {
  11108. /**
  11109. * Instantiate the action
  11110. * @param triggerOptions defines the trigger options
  11111. * @param condition defines the trigger related conditions
  11112. */
  11113. constructor(triggerOptions?: any, condition?: Condition);
  11114. /**
  11115. * Execute the action and do nothing.
  11116. */
  11117. execute(): void;
  11118. /**
  11119. * Serializes the actions and its related information.
  11120. * @param parent defines the object to serialize in
  11121. * @returns the serialized object
  11122. */
  11123. serialize(parent: any): any;
  11124. }
  11125. /**
  11126. * This defines an action responsible to trigger several actions once triggered.
  11127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11128. */
  11129. export class CombineAction extends Action {
  11130. /**
  11131. * The list of aggregated animations to run.
  11132. */
  11133. children: Action[];
  11134. /**
  11135. * Instantiate the action
  11136. * @param triggerOptions defines the trigger options
  11137. * @param children defines the list of aggregated animations to run
  11138. * @param condition defines the trigger related conditions
  11139. */
  11140. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11141. /** @hidden */
  11142. _prepare(): void;
  11143. /**
  11144. * Execute the action and executes all the aggregated actions.
  11145. */
  11146. execute(evt: ActionEvent): void;
  11147. /**
  11148. * Serializes the actions and its related information.
  11149. * @param parent defines the object to serialize in
  11150. * @returns the serialized object
  11151. */
  11152. serialize(parent: any): any;
  11153. }
  11154. /**
  11155. * This defines an action responsible to run code (external event) once triggered.
  11156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11157. */
  11158. export class ExecuteCodeAction extends Action {
  11159. /**
  11160. * The callback function to run.
  11161. */
  11162. func: (evt: ActionEvent) => void;
  11163. /**
  11164. * Instantiate the action
  11165. * @param triggerOptions defines the trigger options
  11166. * @param func defines the callback function to run
  11167. * @param condition defines the trigger related conditions
  11168. */
  11169. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11170. /**
  11171. * Execute the action and run the attached code.
  11172. */
  11173. execute(evt: ActionEvent): void;
  11174. }
  11175. /**
  11176. * This defines an action responsible to set the parent property of the target once triggered.
  11177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11178. */
  11179. export class SetParentAction extends Action {
  11180. private _parent;
  11181. private _target;
  11182. /**
  11183. * Instantiate the action
  11184. * @param triggerOptions defines the trigger options
  11185. * @param target defines the target containing the parent property
  11186. * @param parent defines from where the animation should start (animation frame)
  11187. * @param condition defines the trigger related conditions
  11188. */
  11189. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11190. /** @hidden */
  11191. _prepare(): void;
  11192. /**
  11193. * Execute the action and set the parent property.
  11194. */
  11195. execute(): void;
  11196. /**
  11197. * Serializes the actions and its related information.
  11198. * @param parent defines the object to serialize in
  11199. * @returns the serialized object
  11200. */
  11201. serialize(parent: any): any;
  11202. }
  11203. }
  11204. declare module BABYLON {
  11205. /**
  11206. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11207. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11209. */
  11210. export class ActionManager extends AbstractActionManager {
  11211. /**
  11212. * Nothing
  11213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11214. */
  11215. static readonly NothingTrigger: number;
  11216. /**
  11217. * On pick
  11218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11219. */
  11220. static readonly OnPickTrigger: number;
  11221. /**
  11222. * On left pick
  11223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11224. */
  11225. static readonly OnLeftPickTrigger: number;
  11226. /**
  11227. * On right pick
  11228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11229. */
  11230. static readonly OnRightPickTrigger: number;
  11231. /**
  11232. * On center pick
  11233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11234. */
  11235. static readonly OnCenterPickTrigger: number;
  11236. /**
  11237. * On pick down
  11238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11239. */
  11240. static readonly OnPickDownTrigger: number;
  11241. /**
  11242. * On double pick
  11243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11244. */
  11245. static readonly OnDoublePickTrigger: number;
  11246. /**
  11247. * On pick up
  11248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11249. */
  11250. static readonly OnPickUpTrigger: number;
  11251. /**
  11252. * On pick out.
  11253. * This trigger will only be raised if you also declared a OnPickDown
  11254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11255. */
  11256. static readonly OnPickOutTrigger: number;
  11257. /**
  11258. * On long press
  11259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11260. */
  11261. static readonly OnLongPressTrigger: number;
  11262. /**
  11263. * On pointer over
  11264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11265. */
  11266. static readonly OnPointerOverTrigger: number;
  11267. /**
  11268. * On pointer out
  11269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11270. */
  11271. static readonly OnPointerOutTrigger: number;
  11272. /**
  11273. * On every frame
  11274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11275. */
  11276. static readonly OnEveryFrameTrigger: number;
  11277. /**
  11278. * On intersection enter
  11279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11280. */
  11281. static readonly OnIntersectionEnterTrigger: number;
  11282. /**
  11283. * On intersection exit
  11284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11285. */
  11286. static readonly OnIntersectionExitTrigger: number;
  11287. /**
  11288. * On key down
  11289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11290. */
  11291. static readonly OnKeyDownTrigger: number;
  11292. /**
  11293. * On key up
  11294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11295. */
  11296. static readonly OnKeyUpTrigger: number;
  11297. private _scene;
  11298. /**
  11299. * Creates a new action manager
  11300. * @param scene defines the hosting scene
  11301. */
  11302. constructor(scene: Scene);
  11303. /**
  11304. * Releases all associated resources
  11305. */
  11306. dispose(): void;
  11307. /**
  11308. * Gets hosting scene
  11309. * @returns the hosting scene
  11310. */
  11311. getScene(): Scene;
  11312. /**
  11313. * Does this action manager handles actions of any of the given triggers
  11314. * @param triggers defines the triggers to be tested
  11315. * @return a boolean indicating whether one (or more) of the triggers is handled
  11316. */
  11317. hasSpecificTriggers(triggers: number[]): boolean;
  11318. /**
  11319. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11320. * speed.
  11321. * @param triggerA defines the trigger to be tested
  11322. * @param triggerB defines the trigger to be tested
  11323. * @return a boolean indicating whether one (or more) of the triggers is handled
  11324. */
  11325. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11326. /**
  11327. * Does this action manager handles actions of a given trigger
  11328. * @param trigger defines the trigger to be tested
  11329. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11330. * @return whether the trigger is handled
  11331. */
  11332. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11333. /**
  11334. * Does this action manager has pointer triggers
  11335. */
  11336. readonly hasPointerTriggers: boolean;
  11337. /**
  11338. * Does this action manager has pick triggers
  11339. */
  11340. readonly hasPickTriggers: boolean;
  11341. /**
  11342. * Registers an action to this action manager
  11343. * @param action defines the action to be registered
  11344. * @return the action amended (prepared) after registration
  11345. */
  11346. registerAction(action: IAction): Nullable<IAction>;
  11347. /**
  11348. * Unregisters an action to this action manager
  11349. * @param action defines the action to be unregistered
  11350. * @return a boolean indicating whether the action has been unregistered
  11351. */
  11352. unregisterAction(action: IAction): Boolean;
  11353. /**
  11354. * Process a specific trigger
  11355. * @param trigger defines the trigger to process
  11356. * @param evt defines the event details to be processed
  11357. */
  11358. processTrigger(trigger: number, evt?: IActionEvent): void;
  11359. /** @hidden */
  11360. _getEffectiveTarget(target: any, propertyPath: string): any;
  11361. /** @hidden */
  11362. _getProperty(propertyPath: string): string;
  11363. /**
  11364. * Serialize this manager to a JSON object
  11365. * @param name defines the property name to store this manager
  11366. * @returns a JSON representation of this manager
  11367. */
  11368. serialize(name: string): any;
  11369. /**
  11370. * Creates a new ActionManager from a JSON data
  11371. * @param parsedActions defines the JSON data to read from
  11372. * @param object defines the hosting mesh
  11373. * @param scene defines the hosting scene
  11374. */
  11375. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11376. /**
  11377. * Get a trigger name by index
  11378. * @param trigger defines the trigger index
  11379. * @returns a trigger name
  11380. */
  11381. static GetTriggerName(trigger: number): string;
  11382. }
  11383. }
  11384. declare module BABYLON {
  11385. /**
  11386. * Class representing a ray with position and direction
  11387. */
  11388. export class Ray {
  11389. /** origin point */
  11390. origin: Vector3;
  11391. /** direction */
  11392. direction: Vector3;
  11393. /** length of the ray */
  11394. length: number;
  11395. private static readonly TmpVector3;
  11396. private _tmpRay;
  11397. /**
  11398. * Creates a new ray
  11399. * @param origin origin point
  11400. * @param direction direction
  11401. * @param length length of the ray
  11402. */
  11403. constructor(
  11404. /** origin point */
  11405. origin: Vector3,
  11406. /** direction */
  11407. direction: Vector3,
  11408. /** length of the ray */
  11409. length?: number);
  11410. /**
  11411. * Checks if the ray intersects a box
  11412. * @param minimum bound of the box
  11413. * @param maximum bound of the box
  11414. * @param intersectionTreshold extra extend to be added to the box in all direction
  11415. * @returns if the box was hit
  11416. */
  11417. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11418. /**
  11419. * Checks if the ray intersects a box
  11420. * @param box the bounding box to check
  11421. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11422. * @returns if the box was hit
  11423. */
  11424. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11425. /**
  11426. * If the ray hits a sphere
  11427. * @param sphere the bounding sphere to check
  11428. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11429. * @returns true if it hits the sphere
  11430. */
  11431. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11432. /**
  11433. * If the ray hits a triange
  11434. * @param vertex0 triangle vertex
  11435. * @param vertex1 triangle vertex
  11436. * @param vertex2 triangle vertex
  11437. * @returns intersection information if hit
  11438. */
  11439. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11440. /**
  11441. * Checks if ray intersects a plane
  11442. * @param plane the plane to check
  11443. * @returns the distance away it was hit
  11444. */
  11445. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11446. /**
  11447. * Checks if ray intersects a mesh
  11448. * @param mesh the mesh to check
  11449. * @param fastCheck if only the bounding box should checked
  11450. * @returns picking info of the intersecton
  11451. */
  11452. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11453. /**
  11454. * Checks if ray intersects a mesh
  11455. * @param meshes the meshes to check
  11456. * @param fastCheck if only the bounding box should checked
  11457. * @param results array to store result in
  11458. * @returns Array of picking infos
  11459. */
  11460. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11461. private _comparePickingInfo;
  11462. private static smallnum;
  11463. private static rayl;
  11464. /**
  11465. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11466. * @param sega the first point of the segment to test the intersection against
  11467. * @param segb the second point of the segment to test the intersection against
  11468. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11469. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11470. */
  11471. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11472. /**
  11473. * Update the ray from viewport position
  11474. * @param x position
  11475. * @param y y position
  11476. * @param viewportWidth viewport width
  11477. * @param viewportHeight viewport height
  11478. * @param world world matrix
  11479. * @param view view matrix
  11480. * @param projection projection matrix
  11481. * @returns this ray updated
  11482. */
  11483. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11484. /**
  11485. * Creates a ray with origin and direction of 0,0,0
  11486. * @returns the new ray
  11487. */
  11488. static Zero(): Ray;
  11489. /**
  11490. * Creates a new ray from screen space and viewport
  11491. * @param x position
  11492. * @param y y position
  11493. * @param viewportWidth viewport width
  11494. * @param viewportHeight viewport height
  11495. * @param world world matrix
  11496. * @param view view matrix
  11497. * @param projection projection matrix
  11498. * @returns new ray
  11499. */
  11500. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11501. /**
  11502. * 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
  11503. * transformed to the given world matrix.
  11504. * @param origin The origin point
  11505. * @param end The end point
  11506. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11507. * @returns the new ray
  11508. */
  11509. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11510. /**
  11511. * Transforms a ray by a matrix
  11512. * @param ray ray to transform
  11513. * @param matrix matrix to apply
  11514. * @returns the resulting new ray
  11515. */
  11516. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11517. /**
  11518. * Transforms a ray by a matrix
  11519. * @param ray ray to transform
  11520. * @param matrix matrix to apply
  11521. * @param result ray to store result in
  11522. */
  11523. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11524. /**
  11525. * Unproject a ray from screen space to object space
  11526. * @param sourceX defines the screen space x coordinate to use
  11527. * @param sourceY defines the screen space y coordinate to use
  11528. * @param viewportWidth defines the current width of the viewport
  11529. * @param viewportHeight defines the current height of the viewport
  11530. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11531. * @param view defines the view matrix to use
  11532. * @param projection defines the projection matrix to use
  11533. */
  11534. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11535. }
  11536. /**
  11537. * Type used to define predicate used to select faces when a mesh intersection is detected
  11538. */
  11539. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11540. interface Scene {
  11541. /** @hidden */
  11542. _tempPickingRay: Nullable<Ray>;
  11543. /** @hidden */
  11544. _cachedRayForTransform: Ray;
  11545. /** @hidden */
  11546. _pickWithRayInverseMatrix: Matrix;
  11547. /** @hidden */
  11548. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11549. /** @hidden */
  11550. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11551. }
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Groups all the scene component constants in one place to ease maintenance.
  11556. * @hidden
  11557. */
  11558. export class SceneComponentConstants {
  11559. static readonly NAME_EFFECTLAYER: string;
  11560. static readonly NAME_LAYER: string;
  11561. static readonly NAME_LENSFLARESYSTEM: string;
  11562. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11563. static readonly NAME_PARTICLESYSTEM: string;
  11564. static readonly NAME_GAMEPAD: string;
  11565. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11566. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11567. static readonly NAME_DEPTHRENDERER: string;
  11568. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11569. static readonly NAME_SPRITE: string;
  11570. static readonly NAME_OUTLINERENDERER: string;
  11571. static readonly NAME_PROCEDURALTEXTURE: string;
  11572. static readonly NAME_SHADOWGENERATOR: string;
  11573. static readonly NAME_OCTREE: string;
  11574. static readonly NAME_PHYSICSENGINE: string;
  11575. static readonly NAME_AUDIO: string;
  11576. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11577. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11578. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11579. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11580. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11581. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11582. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11583. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11584. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11585. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11586. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11587. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11588. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11589. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11590. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11591. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11592. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11593. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11594. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11595. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11596. static readonly STEP_AFTERRENDER_AUDIO: number;
  11597. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11598. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11599. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11600. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11601. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11602. static readonly STEP_POINTERMOVE_SPRITE: number;
  11603. static readonly STEP_POINTERDOWN_SPRITE: number;
  11604. static readonly STEP_POINTERUP_SPRITE: number;
  11605. }
  11606. /**
  11607. * This represents a scene component.
  11608. *
  11609. * This is used to decouple the dependency the scene is having on the different workloads like
  11610. * layers, post processes...
  11611. */
  11612. export interface ISceneComponent {
  11613. /**
  11614. * The name of the component. Each component must have a unique name.
  11615. */
  11616. name: string;
  11617. /**
  11618. * The scene the component belongs to.
  11619. */
  11620. scene: Scene;
  11621. /**
  11622. * Register the component to one instance of a scene.
  11623. */
  11624. register(): void;
  11625. /**
  11626. * Rebuilds the elements related to this component in case of
  11627. * context lost for instance.
  11628. */
  11629. rebuild(): void;
  11630. /**
  11631. * Disposes the component and the associated ressources.
  11632. */
  11633. dispose(): void;
  11634. }
  11635. /**
  11636. * This represents a SERIALIZABLE scene component.
  11637. *
  11638. * This extends Scene Component to add Serialization methods on top.
  11639. */
  11640. export interface ISceneSerializableComponent extends ISceneComponent {
  11641. /**
  11642. * Adds all the element from the container to the scene
  11643. * @param container the container holding the elements
  11644. */
  11645. addFromContainer(container: AbstractScene): void;
  11646. /**
  11647. * Removes all the elements in the container from the scene
  11648. * @param container contains the elements to remove
  11649. * @param dispose if the removed element should be disposed (default: false)
  11650. */
  11651. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11652. /**
  11653. * Serializes the component data to the specified json object
  11654. * @param serializationObject The object to serialize to
  11655. */
  11656. serialize(serializationObject: any): void;
  11657. }
  11658. /**
  11659. * Strong typing of a Mesh related stage step action
  11660. */
  11661. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11662. /**
  11663. * Strong typing of a Evaluate Sub Mesh related stage step action
  11664. */
  11665. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11666. /**
  11667. * Strong typing of a Active Mesh related stage step action
  11668. */
  11669. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11670. /**
  11671. * Strong typing of a Camera related stage step action
  11672. */
  11673. export type CameraStageAction = (camera: Camera) => void;
  11674. /**
  11675. * Strong typing of a Camera Frame buffer related stage step action
  11676. */
  11677. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11678. /**
  11679. * Strong typing of a Render Target related stage step action
  11680. */
  11681. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11682. /**
  11683. * Strong typing of a RenderingGroup related stage step action
  11684. */
  11685. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11686. /**
  11687. * Strong typing of a Mesh Render related stage step action
  11688. */
  11689. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11690. /**
  11691. * Strong typing of a simple stage step action
  11692. */
  11693. export type SimpleStageAction = () => void;
  11694. /**
  11695. * Strong typing of a render target action.
  11696. */
  11697. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11698. /**
  11699. * Strong typing of a pointer move action.
  11700. */
  11701. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11702. /**
  11703. * Strong typing of a pointer up/down action.
  11704. */
  11705. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11706. /**
  11707. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11708. * @hidden
  11709. */
  11710. export class Stage<T extends Function> extends Array<{
  11711. index: number;
  11712. component: ISceneComponent;
  11713. action: T;
  11714. }> {
  11715. /**
  11716. * Hide ctor from the rest of the world.
  11717. * @param items The items to add.
  11718. */
  11719. private constructor();
  11720. /**
  11721. * Creates a new Stage.
  11722. * @returns A new instance of a Stage
  11723. */
  11724. static Create<T extends Function>(): Stage<T>;
  11725. /**
  11726. * Registers a step in an ordered way in the targeted stage.
  11727. * @param index Defines the position to register the step in
  11728. * @param component Defines the component attached to the step
  11729. * @param action Defines the action to launch during the step
  11730. */
  11731. registerStep(index: number, component: ISceneComponent, action: T): void;
  11732. /**
  11733. * Clears all the steps from the stage.
  11734. */
  11735. clear(): void;
  11736. }
  11737. }
  11738. declare module BABYLON {
  11739. interface Scene {
  11740. /** @hidden */
  11741. _pointerOverSprite: Nullable<Sprite>;
  11742. /** @hidden */
  11743. _pickedDownSprite: Nullable<Sprite>;
  11744. /** @hidden */
  11745. _tempSpritePickingRay: Nullable<Ray>;
  11746. /**
  11747. * All of the sprite managers added to this scene
  11748. * @see http://doc.babylonjs.com/babylon101/sprites
  11749. */
  11750. spriteManagers: Array<ISpriteManager>;
  11751. /**
  11752. * An event triggered when sprites rendering is about to start
  11753. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11754. */
  11755. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11756. /**
  11757. * An event triggered when sprites rendering is done
  11758. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11759. */
  11760. onAfterSpritesRenderingObservable: Observable<Scene>;
  11761. /** @hidden */
  11762. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11763. /** Launch a ray to try to pick a sprite in the scene
  11764. * @param x position on screen
  11765. * @param y position on screen
  11766. * @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
  11767. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11768. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11769. * @returns a PickingInfo
  11770. */
  11771. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11772. /** Use the given ray to pick a sprite in the scene
  11773. * @param ray The ray (in world space) to use to pick meshes
  11774. * @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
  11775. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11776. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11777. * @returns a PickingInfo
  11778. */
  11779. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11780. /**
  11781. * Force the sprite under the pointer
  11782. * @param sprite defines the sprite to use
  11783. */
  11784. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11785. /**
  11786. * Gets the sprite under the pointer
  11787. * @returns a Sprite or null if no sprite is under the pointer
  11788. */
  11789. getPointerOverSprite(): Nullable<Sprite>;
  11790. }
  11791. /**
  11792. * Defines the sprite scene component responsible to manage sprites
  11793. * in a given scene.
  11794. */
  11795. export class SpriteSceneComponent implements ISceneComponent {
  11796. /**
  11797. * The component name helpfull to identify the component in the list of scene components.
  11798. */
  11799. readonly name: string;
  11800. /**
  11801. * The scene the component belongs to.
  11802. */
  11803. scene: Scene;
  11804. /** @hidden */
  11805. private _spritePredicate;
  11806. /**
  11807. * Creates a new instance of the component for the given scene
  11808. * @param scene Defines the scene to register the component in
  11809. */
  11810. constructor(scene: Scene);
  11811. /**
  11812. * Registers the component in a given scene
  11813. */
  11814. register(): void;
  11815. /**
  11816. * Rebuilds the elements related to this component in case of
  11817. * context lost for instance.
  11818. */
  11819. rebuild(): void;
  11820. /**
  11821. * Disposes the component and the associated ressources.
  11822. */
  11823. dispose(): void;
  11824. private _pickSpriteButKeepRay;
  11825. private _pointerMove;
  11826. private _pointerDown;
  11827. private _pointerUp;
  11828. }
  11829. }
  11830. declare module BABYLON {
  11831. /** @hidden */
  11832. export var fogFragmentDeclaration: {
  11833. name: string;
  11834. shader: string;
  11835. };
  11836. }
  11837. declare module BABYLON {
  11838. /** @hidden */
  11839. export var fogFragment: {
  11840. name: string;
  11841. shader: string;
  11842. };
  11843. }
  11844. declare module BABYLON {
  11845. /** @hidden */
  11846. export var spritesPixelShader: {
  11847. name: string;
  11848. shader: string;
  11849. };
  11850. }
  11851. declare module BABYLON {
  11852. /** @hidden */
  11853. export var fogVertexDeclaration: {
  11854. name: string;
  11855. shader: string;
  11856. };
  11857. }
  11858. declare module BABYLON {
  11859. /** @hidden */
  11860. export var spritesVertexShader: {
  11861. name: string;
  11862. shader: string;
  11863. };
  11864. }
  11865. declare module BABYLON {
  11866. /**
  11867. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11868. */
  11869. export interface ISpriteManager extends IDisposable {
  11870. /**
  11871. * Restricts the camera to viewing objects with the same layerMask.
  11872. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11873. */
  11874. layerMask: number;
  11875. /**
  11876. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11877. */
  11878. isPickable: boolean;
  11879. /**
  11880. * Specifies the rendering group id for this mesh (0 by default)
  11881. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11882. */
  11883. renderingGroupId: number;
  11884. /**
  11885. * Defines the list of sprites managed by the manager.
  11886. */
  11887. sprites: Array<Sprite>;
  11888. /**
  11889. * Tests the intersection of a sprite with a specific ray.
  11890. * @param ray The ray we are sending to test the collision
  11891. * @param camera The camera space we are sending rays in
  11892. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11893. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11894. * @returns picking info or null.
  11895. */
  11896. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11897. /**
  11898. * Renders the list of sprites on screen.
  11899. */
  11900. render(): void;
  11901. }
  11902. /**
  11903. * Class used to manage multiple sprites on the same spritesheet
  11904. * @see http://doc.babylonjs.com/babylon101/sprites
  11905. */
  11906. export class SpriteManager implements ISpriteManager {
  11907. /** defines the manager's name */
  11908. name: string;
  11909. /** Gets the list of sprites */
  11910. sprites: Sprite[];
  11911. /** Gets or sets the rendering group id (0 by default) */
  11912. renderingGroupId: number;
  11913. /** Gets or sets camera layer mask */
  11914. layerMask: number;
  11915. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11916. fogEnabled: boolean;
  11917. /** Gets or sets a boolean indicating if the sprites are pickable */
  11918. isPickable: boolean;
  11919. /** Defines the default width of a cell in the spritesheet */
  11920. cellWidth: number;
  11921. /** Defines the default height of a cell in the spritesheet */
  11922. cellHeight: number;
  11923. /**
  11924. * An event triggered when the manager is disposed.
  11925. */
  11926. onDisposeObservable: Observable<SpriteManager>;
  11927. private _onDisposeObserver;
  11928. /**
  11929. * Callback called when the manager is disposed
  11930. */
  11931. onDispose: () => void;
  11932. private _capacity;
  11933. private _spriteTexture;
  11934. private _epsilon;
  11935. private _scene;
  11936. private _vertexData;
  11937. private _buffer;
  11938. private _vertexBuffers;
  11939. private _indexBuffer;
  11940. private _effectBase;
  11941. private _effectFog;
  11942. /**
  11943. * Gets or sets the spritesheet texture
  11944. */
  11945. texture: Texture;
  11946. /**
  11947. * Creates a new sprite manager
  11948. * @param name defines the manager's name
  11949. * @param imgUrl defines the sprite sheet url
  11950. * @param capacity defines the maximum allowed number of sprites
  11951. * @param cellSize defines the size of a sprite cell
  11952. * @param scene defines the hosting scene
  11953. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11954. * @param samplingMode defines the smapling mode to use with spritesheet
  11955. */
  11956. constructor(
  11957. /** defines the manager's name */
  11958. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11959. private _appendSpriteVertex;
  11960. /**
  11961. * Intersects the sprites with a ray
  11962. * @param ray defines the ray to intersect with
  11963. * @param camera defines the current active camera
  11964. * @param predicate defines a predicate used to select candidate sprites
  11965. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11966. * @returns null if no hit or a PickingInfo
  11967. */
  11968. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11969. /**
  11970. * Render all child sprites
  11971. */
  11972. render(): void;
  11973. /**
  11974. * Release associated resources
  11975. */
  11976. dispose(): void;
  11977. }
  11978. }
  11979. declare module BABYLON {
  11980. /**
  11981. * Class used to represent a sprite
  11982. * @see http://doc.babylonjs.com/babylon101/sprites
  11983. */
  11984. export class Sprite {
  11985. /** defines the name */
  11986. name: string;
  11987. /** Gets or sets the current world position */
  11988. position: Vector3;
  11989. /** Gets or sets the main color */
  11990. color: Color4;
  11991. /** Gets or sets the width */
  11992. width: number;
  11993. /** Gets or sets the height */
  11994. height: number;
  11995. /** Gets or sets rotation angle */
  11996. angle: number;
  11997. /** Gets or sets the cell index in the sprite sheet */
  11998. cellIndex: number;
  11999. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12000. invertU: number;
  12001. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12002. invertV: number;
  12003. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12004. disposeWhenFinishedAnimating: boolean;
  12005. /** Gets the list of attached animations */
  12006. animations: Animation[];
  12007. /** Gets or sets a boolean indicating if the sprite can be picked */
  12008. isPickable: boolean;
  12009. /**
  12010. * Gets or sets the associated action manager
  12011. */
  12012. actionManager: Nullable<ActionManager>;
  12013. private _animationStarted;
  12014. private _loopAnimation;
  12015. private _fromIndex;
  12016. private _toIndex;
  12017. private _delay;
  12018. private _direction;
  12019. private _manager;
  12020. private _time;
  12021. private _onAnimationEnd;
  12022. /**
  12023. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12024. */
  12025. isVisible: boolean;
  12026. /**
  12027. * Gets or sets the sprite size
  12028. */
  12029. size: number;
  12030. /**
  12031. * Creates a new Sprite
  12032. * @param name defines the name
  12033. * @param manager defines the manager
  12034. */
  12035. constructor(
  12036. /** defines the name */
  12037. name: string, manager: ISpriteManager);
  12038. /**
  12039. * Starts an animation
  12040. * @param from defines the initial key
  12041. * @param to defines the end key
  12042. * @param loop defines if the animation must loop
  12043. * @param delay defines the start delay (in ms)
  12044. * @param onAnimationEnd defines a callback to call when animation ends
  12045. */
  12046. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12047. /** Stops current animation (if any) */
  12048. stopAnimation(): void;
  12049. /** @hidden */
  12050. _animate(deltaTime: number): void;
  12051. /** Release associated resources */
  12052. dispose(): void;
  12053. }
  12054. }
  12055. declare module BABYLON {
  12056. /**
  12057. * Information about the result of picking within a scene
  12058. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12059. */
  12060. export class PickingInfo {
  12061. /** @hidden */
  12062. _pickingUnavailable: boolean;
  12063. /**
  12064. * If the pick collided with an object
  12065. */
  12066. hit: boolean;
  12067. /**
  12068. * Distance away where the pick collided
  12069. */
  12070. distance: number;
  12071. /**
  12072. * The location of pick collision
  12073. */
  12074. pickedPoint: Nullable<Vector3>;
  12075. /**
  12076. * The mesh corresponding the the pick collision
  12077. */
  12078. pickedMesh: Nullable<AbstractMesh>;
  12079. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12080. bu: number;
  12081. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12082. bv: number;
  12083. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12084. faceId: number;
  12085. /** Id of the the submesh that was picked */
  12086. subMeshId: number;
  12087. /** If a sprite was picked, this will be the sprite the pick collided with */
  12088. pickedSprite: Nullable<Sprite>;
  12089. /**
  12090. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12091. */
  12092. originMesh: Nullable<AbstractMesh>;
  12093. /**
  12094. * The ray that was used to perform the picking.
  12095. */
  12096. ray: Nullable<Ray>;
  12097. /**
  12098. * Gets the normal correspodning to the face the pick collided with
  12099. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12100. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12101. * @returns The normal correspodning to the face the pick collided with
  12102. */
  12103. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12104. /**
  12105. * Gets the texture coordinates of where the pick occured
  12106. * @returns the vector containing the coordnates of the texture
  12107. */
  12108. getTextureCoordinates(): Nullable<Vector2>;
  12109. }
  12110. }
  12111. declare module BABYLON {
  12112. /**
  12113. * Gather the list of pointer event types as constants.
  12114. */
  12115. export class PointerEventTypes {
  12116. /**
  12117. * 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.
  12118. */
  12119. static readonly POINTERDOWN: number;
  12120. /**
  12121. * The pointerup event is fired when a pointer is no longer active.
  12122. */
  12123. static readonly POINTERUP: number;
  12124. /**
  12125. * The pointermove event is fired when a pointer changes coordinates.
  12126. */
  12127. static readonly POINTERMOVE: number;
  12128. /**
  12129. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12130. */
  12131. static readonly POINTERWHEEL: number;
  12132. /**
  12133. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12134. */
  12135. static readonly POINTERPICK: number;
  12136. /**
  12137. * The pointertap event is fired when a the object has been touched and released without drag.
  12138. */
  12139. static readonly POINTERTAP: number;
  12140. /**
  12141. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12142. */
  12143. static readonly POINTERDOUBLETAP: number;
  12144. }
  12145. /**
  12146. * Base class of pointer info types.
  12147. */
  12148. export class PointerInfoBase {
  12149. /**
  12150. * Defines the type of event (PointerEventTypes)
  12151. */
  12152. type: number;
  12153. /**
  12154. * Defines the related dom event
  12155. */
  12156. event: PointerEvent | MouseWheelEvent;
  12157. /**
  12158. * Instantiates the base class of pointers info.
  12159. * @param type Defines the type of event (PointerEventTypes)
  12160. * @param event Defines the related dom event
  12161. */
  12162. constructor(
  12163. /**
  12164. * Defines the type of event (PointerEventTypes)
  12165. */
  12166. type: number,
  12167. /**
  12168. * Defines the related dom event
  12169. */
  12170. event: PointerEvent | MouseWheelEvent);
  12171. }
  12172. /**
  12173. * This class is used to store pointer related info for the onPrePointerObservable event.
  12174. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12175. */
  12176. export class PointerInfoPre extends PointerInfoBase {
  12177. /**
  12178. * Ray from a pointer if availible (eg. 6dof controller)
  12179. */
  12180. ray: Nullable<Ray>;
  12181. /**
  12182. * Defines the local position of the pointer on the canvas.
  12183. */
  12184. localPosition: Vector2;
  12185. /**
  12186. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12187. */
  12188. skipOnPointerObservable: boolean;
  12189. /**
  12190. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12191. * @param type Defines the type of event (PointerEventTypes)
  12192. * @param event Defines the related dom event
  12193. * @param localX Defines the local x coordinates of the pointer when the event occured
  12194. * @param localY Defines the local y coordinates of the pointer when the event occured
  12195. */
  12196. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12197. }
  12198. /**
  12199. * This type contains all the data related to a pointer event in Babylon.js.
  12200. * 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.
  12201. */
  12202. export class PointerInfo extends PointerInfoBase {
  12203. /**
  12204. * Defines the picking info associated to the info (if any)\
  12205. */
  12206. pickInfo: Nullable<PickingInfo>;
  12207. /**
  12208. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12209. * @param type Defines the type of event (PointerEventTypes)
  12210. * @param event Defines the related dom event
  12211. * @param pickInfo Defines the picking info associated to the info (if any)\
  12212. */
  12213. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12214. /**
  12215. * Defines the picking info associated to the info (if any)\
  12216. */
  12217. pickInfo: Nullable<PickingInfo>);
  12218. }
  12219. /**
  12220. * Data relating to a touch event on the screen.
  12221. */
  12222. export interface PointerTouch {
  12223. /**
  12224. * X coordinate of touch.
  12225. */
  12226. x: number;
  12227. /**
  12228. * Y coordinate of touch.
  12229. */
  12230. y: number;
  12231. /**
  12232. * Id of touch. Unique for each finger.
  12233. */
  12234. pointerId: number;
  12235. /**
  12236. * Event type passed from DOM.
  12237. */
  12238. type: any;
  12239. }
  12240. }
  12241. declare module BABYLON {
  12242. /**
  12243. * Manage the mouse inputs to control the movement of a free camera.
  12244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12245. */
  12246. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12247. /**
  12248. * Define if touch is enabled in the mouse input
  12249. */
  12250. touchEnabled: boolean;
  12251. /**
  12252. * Defines the camera the input is attached to.
  12253. */
  12254. camera: FreeCamera;
  12255. /**
  12256. * Defines the buttons associated with the input to handle camera move.
  12257. */
  12258. buttons: number[];
  12259. /**
  12260. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12261. */
  12262. angularSensibility: number;
  12263. private _pointerInput;
  12264. private _onMouseMove;
  12265. private _observer;
  12266. private previousPosition;
  12267. /**
  12268. * Observable for when a pointer move event occurs containing the move offset
  12269. */
  12270. onPointerMovedObservable: Observable<{
  12271. offsetX: number;
  12272. offsetY: number;
  12273. }>;
  12274. /**
  12275. * @hidden
  12276. * If the camera should be rotated automatically based on pointer movement
  12277. */
  12278. _allowCameraRotation: boolean;
  12279. /**
  12280. * Manage the mouse inputs to control the movement of a free camera.
  12281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12282. * @param touchEnabled Defines if touch is enabled or not
  12283. */
  12284. constructor(
  12285. /**
  12286. * Define if touch is enabled in the mouse input
  12287. */
  12288. touchEnabled?: boolean);
  12289. /**
  12290. * Attach the input controls to a specific dom element to get the input from.
  12291. * @param element Defines the element the controls should be listened from
  12292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12293. */
  12294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12295. /**
  12296. * Called on JS contextmenu event.
  12297. * Override this method to provide functionality.
  12298. */
  12299. protected onContextMenu(evt: PointerEvent): void;
  12300. /**
  12301. * Detach the current controls from the specified dom element.
  12302. * @param element Defines the element to stop listening the inputs from
  12303. */
  12304. detachControl(element: Nullable<HTMLElement>): void;
  12305. /**
  12306. * Gets the class name of the current intput.
  12307. * @returns the class name
  12308. */
  12309. getClassName(): string;
  12310. /**
  12311. * Get the friendly name associated with the input class.
  12312. * @returns the input friendly name
  12313. */
  12314. getSimpleName(): string;
  12315. }
  12316. }
  12317. declare module BABYLON {
  12318. /**
  12319. * Manage the touch inputs to control the movement of a free camera.
  12320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12321. */
  12322. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12323. /**
  12324. * Defines the camera the input is attached to.
  12325. */
  12326. camera: FreeCamera;
  12327. /**
  12328. * Defines the touch sensibility for rotation.
  12329. * The higher the faster.
  12330. */
  12331. touchAngularSensibility: number;
  12332. /**
  12333. * Defines the touch sensibility for move.
  12334. * The higher the faster.
  12335. */
  12336. touchMoveSensibility: number;
  12337. private _offsetX;
  12338. private _offsetY;
  12339. private _pointerPressed;
  12340. private _pointerInput;
  12341. private _observer;
  12342. private _onLostFocus;
  12343. /**
  12344. * Attach the input controls to a specific dom element to get the input from.
  12345. * @param element Defines the element the controls should be listened from
  12346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12347. */
  12348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12349. /**
  12350. * Detach the current controls from the specified dom element.
  12351. * @param element Defines the element to stop listening the inputs from
  12352. */
  12353. detachControl(element: Nullable<HTMLElement>): void;
  12354. /**
  12355. * Update the current camera state depending on the inputs that have been used this frame.
  12356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12357. */
  12358. checkInputs(): void;
  12359. /**
  12360. * Gets the class name of the current intput.
  12361. * @returns the class name
  12362. */
  12363. getClassName(): string;
  12364. /**
  12365. * Get the friendly name associated with the input class.
  12366. * @returns the input friendly name
  12367. */
  12368. getSimpleName(): string;
  12369. }
  12370. }
  12371. declare module BABYLON {
  12372. /**
  12373. * Default Inputs manager for the FreeCamera.
  12374. * It groups all the default supported inputs for ease of use.
  12375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12376. */
  12377. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12378. /**
  12379. * @hidden
  12380. */
  12381. _mouseInput: Nullable<FreeCameraMouseInput>;
  12382. /**
  12383. * Instantiates a new FreeCameraInputsManager.
  12384. * @param camera Defines the camera the inputs belong to
  12385. */
  12386. constructor(camera: FreeCamera);
  12387. /**
  12388. * Add keyboard input support to the input manager.
  12389. * @returns the current input manager
  12390. */
  12391. addKeyboard(): FreeCameraInputsManager;
  12392. /**
  12393. * Add mouse input support to the input manager.
  12394. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12395. * @returns the current input manager
  12396. */
  12397. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12398. /**
  12399. * Removes the mouse input support from the manager
  12400. * @returns the current input manager
  12401. */
  12402. removeMouse(): FreeCameraInputsManager;
  12403. /**
  12404. * Add touch input support to the input manager.
  12405. * @returns the current input manager
  12406. */
  12407. addTouch(): FreeCameraInputsManager;
  12408. /**
  12409. * Remove all attached input methods from a camera
  12410. */
  12411. clear(): void;
  12412. }
  12413. }
  12414. declare module BABYLON {
  12415. /**
  12416. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12417. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12418. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12419. */
  12420. export class FreeCamera extends TargetCamera {
  12421. /**
  12422. * Define the collision ellipsoid of the camera.
  12423. * This is helpful to simulate a camera body like the player body around the camera
  12424. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12425. */
  12426. ellipsoid: Vector3;
  12427. /**
  12428. * Define an offset for the position of the ellipsoid around the camera.
  12429. * This can be helpful to determine the center of the body near the gravity center of the body
  12430. * instead of its head.
  12431. */
  12432. ellipsoidOffset: Vector3;
  12433. /**
  12434. * Enable or disable collisions of the camera with the rest of the scene objects.
  12435. */
  12436. checkCollisions: boolean;
  12437. /**
  12438. * Enable or disable gravity on the camera.
  12439. */
  12440. applyGravity: boolean;
  12441. /**
  12442. * Define the input manager associated to the camera.
  12443. */
  12444. inputs: FreeCameraInputsManager;
  12445. /**
  12446. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12447. * Higher values reduce sensitivity.
  12448. */
  12449. /**
  12450. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12451. * Higher values reduce sensitivity.
  12452. */
  12453. angularSensibility: number;
  12454. /**
  12455. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12456. */
  12457. keysUp: number[];
  12458. /**
  12459. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12460. */
  12461. keysDown: number[];
  12462. /**
  12463. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12464. */
  12465. keysLeft: number[];
  12466. /**
  12467. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12468. */
  12469. keysRight: number[];
  12470. /**
  12471. * Event raised when the camera collide with a mesh in the scene.
  12472. */
  12473. onCollide: (collidedMesh: AbstractMesh) => void;
  12474. private _collider;
  12475. private _needMoveForGravity;
  12476. private _oldPosition;
  12477. private _diffPosition;
  12478. private _newPosition;
  12479. /** @hidden */
  12480. _localDirection: Vector3;
  12481. /** @hidden */
  12482. _transformedDirection: Vector3;
  12483. /**
  12484. * Instantiates a Free Camera.
  12485. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12486. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12487. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12488. * @param name Define the name of the camera in the scene
  12489. * @param position Define the start position of the camera in the scene
  12490. * @param scene Define the scene the camera belongs to
  12491. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12492. */
  12493. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12494. /**
  12495. * Attached controls to the current camera.
  12496. * @param element Defines the element the controls should be listened from
  12497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12498. */
  12499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12500. /**
  12501. * Detach the current controls from the camera.
  12502. * The camera will stop reacting to inputs.
  12503. * @param element Defines the element to stop listening the inputs from
  12504. */
  12505. detachControl(element: HTMLElement): void;
  12506. private _collisionMask;
  12507. /**
  12508. * Define a collision mask to limit the list of object the camera can collide with
  12509. */
  12510. collisionMask: number;
  12511. /** @hidden */
  12512. _collideWithWorld(displacement: Vector3): void;
  12513. private _onCollisionPositionChange;
  12514. /** @hidden */
  12515. _checkInputs(): void;
  12516. /** @hidden */
  12517. _decideIfNeedsToMove(): boolean;
  12518. /** @hidden */
  12519. _updatePosition(): void;
  12520. /**
  12521. * Destroy the camera and release the current resources hold by it.
  12522. */
  12523. dispose(): void;
  12524. /**
  12525. * Gets the current object class name.
  12526. * @return the class name
  12527. */
  12528. getClassName(): string;
  12529. }
  12530. }
  12531. declare module BABYLON {
  12532. /**
  12533. * Represents a gamepad control stick position
  12534. */
  12535. export class StickValues {
  12536. /**
  12537. * The x component of the control stick
  12538. */
  12539. x: number;
  12540. /**
  12541. * The y component of the control stick
  12542. */
  12543. y: number;
  12544. /**
  12545. * Initializes the gamepad x and y control stick values
  12546. * @param x The x component of the gamepad control stick value
  12547. * @param y The y component of the gamepad control stick value
  12548. */
  12549. constructor(
  12550. /**
  12551. * The x component of the control stick
  12552. */
  12553. x: number,
  12554. /**
  12555. * The y component of the control stick
  12556. */
  12557. y: number);
  12558. }
  12559. /**
  12560. * An interface which manages callbacks for gamepad button changes
  12561. */
  12562. export interface GamepadButtonChanges {
  12563. /**
  12564. * Called when a gamepad has been changed
  12565. */
  12566. changed: boolean;
  12567. /**
  12568. * Called when a gamepad press event has been triggered
  12569. */
  12570. pressChanged: boolean;
  12571. /**
  12572. * Called when a touch event has been triggered
  12573. */
  12574. touchChanged: boolean;
  12575. /**
  12576. * Called when a value has changed
  12577. */
  12578. valueChanged: boolean;
  12579. }
  12580. /**
  12581. * Represents a gamepad
  12582. */
  12583. export class Gamepad {
  12584. /**
  12585. * The id of the gamepad
  12586. */
  12587. id: string;
  12588. /**
  12589. * The index of the gamepad
  12590. */
  12591. index: number;
  12592. /**
  12593. * The browser gamepad
  12594. */
  12595. browserGamepad: any;
  12596. /**
  12597. * Specifies what type of gamepad this represents
  12598. */
  12599. type: number;
  12600. private _leftStick;
  12601. private _rightStick;
  12602. /** @hidden */
  12603. _isConnected: boolean;
  12604. private _leftStickAxisX;
  12605. private _leftStickAxisY;
  12606. private _rightStickAxisX;
  12607. private _rightStickAxisY;
  12608. /**
  12609. * Triggered when the left control stick has been changed
  12610. */
  12611. private _onleftstickchanged;
  12612. /**
  12613. * Triggered when the right control stick has been changed
  12614. */
  12615. private _onrightstickchanged;
  12616. /**
  12617. * Represents a gamepad controller
  12618. */
  12619. static GAMEPAD: number;
  12620. /**
  12621. * Represents a generic controller
  12622. */
  12623. static GENERIC: number;
  12624. /**
  12625. * Represents an XBox controller
  12626. */
  12627. static XBOX: number;
  12628. /**
  12629. * Represents a pose-enabled controller
  12630. */
  12631. static POSE_ENABLED: number;
  12632. /**
  12633. * Specifies whether the left control stick should be Y-inverted
  12634. */
  12635. protected _invertLeftStickY: boolean;
  12636. /**
  12637. * Specifies if the gamepad has been connected
  12638. */
  12639. readonly isConnected: boolean;
  12640. /**
  12641. * Initializes the gamepad
  12642. * @param id The id of the gamepad
  12643. * @param index The index of the gamepad
  12644. * @param browserGamepad The browser gamepad
  12645. * @param leftStickX The x component of the left joystick
  12646. * @param leftStickY The y component of the left joystick
  12647. * @param rightStickX The x component of the right joystick
  12648. * @param rightStickY The y component of the right joystick
  12649. */
  12650. constructor(
  12651. /**
  12652. * The id of the gamepad
  12653. */
  12654. id: string,
  12655. /**
  12656. * The index of the gamepad
  12657. */
  12658. index: number,
  12659. /**
  12660. * The browser gamepad
  12661. */
  12662. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12663. /**
  12664. * Callback triggered when the left joystick has changed
  12665. * @param callback
  12666. */
  12667. onleftstickchanged(callback: (values: StickValues) => void): void;
  12668. /**
  12669. * Callback triggered when the right joystick has changed
  12670. * @param callback
  12671. */
  12672. onrightstickchanged(callback: (values: StickValues) => void): void;
  12673. /**
  12674. * Gets the left joystick
  12675. */
  12676. /**
  12677. * Sets the left joystick values
  12678. */
  12679. leftStick: StickValues;
  12680. /**
  12681. * Gets the right joystick
  12682. */
  12683. /**
  12684. * Sets the right joystick value
  12685. */
  12686. rightStick: StickValues;
  12687. /**
  12688. * Updates the gamepad joystick positions
  12689. */
  12690. update(): void;
  12691. /**
  12692. * Disposes the gamepad
  12693. */
  12694. dispose(): void;
  12695. }
  12696. /**
  12697. * Represents a generic gamepad
  12698. */
  12699. export class GenericPad extends Gamepad {
  12700. private _buttons;
  12701. private _onbuttondown;
  12702. private _onbuttonup;
  12703. /**
  12704. * Observable triggered when a button has been pressed
  12705. */
  12706. onButtonDownObservable: Observable<number>;
  12707. /**
  12708. * Observable triggered when a button has been released
  12709. */
  12710. onButtonUpObservable: Observable<number>;
  12711. /**
  12712. * Callback triggered when a button has been pressed
  12713. * @param callback Called when a button has been pressed
  12714. */
  12715. onbuttondown(callback: (buttonPressed: number) => void): void;
  12716. /**
  12717. * Callback triggered when a button has been released
  12718. * @param callback Called when a button has been released
  12719. */
  12720. onbuttonup(callback: (buttonReleased: number) => void): void;
  12721. /**
  12722. * Initializes the generic gamepad
  12723. * @param id The id of the generic gamepad
  12724. * @param index The index of the generic gamepad
  12725. * @param browserGamepad The browser gamepad
  12726. */
  12727. constructor(id: string, index: number, browserGamepad: any);
  12728. private _setButtonValue;
  12729. /**
  12730. * Updates the generic gamepad
  12731. */
  12732. update(): void;
  12733. /**
  12734. * Disposes the generic gamepad
  12735. */
  12736. dispose(): void;
  12737. }
  12738. }
  12739. declare module BABYLON {
  12740. /**
  12741. * Defines the types of pose enabled controllers that are supported
  12742. */
  12743. export enum PoseEnabledControllerType {
  12744. /**
  12745. * HTC Vive
  12746. */
  12747. VIVE = 0,
  12748. /**
  12749. * Oculus Rift
  12750. */
  12751. OCULUS = 1,
  12752. /**
  12753. * Windows mixed reality
  12754. */
  12755. WINDOWS = 2,
  12756. /**
  12757. * Samsung gear VR
  12758. */
  12759. GEAR_VR = 3,
  12760. /**
  12761. * Google Daydream
  12762. */
  12763. DAYDREAM = 4,
  12764. /**
  12765. * Generic
  12766. */
  12767. GENERIC = 5
  12768. }
  12769. /**
  12770. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12771. */
  12772. export interface MutableGamepadButton {
  12773. /**
  12774. * Value of the button/trigger
  12775. */
  12776. value: number;
  12777. /**
  12778. * If the button/trigger is currently touched
  12779. */
  12780. touched: boolean;
  12781. /**
  12782. * If the button/trigger is currently pressed
  12783. */
  12784. pressed: boolean;
  12785. }
  12786. /**
  12787. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12788. * @hidden
  12789. */
  12790. export interface ExtendedGamepadButton extends GamepadButton {
  12791. /**
  12792. * If the button/trigger is currently pressed
  12793. */
  12794. readonly pressed: boolean;
  12795. /**
  12796. * If the button/trigger is currently touched
  12797. */
  12798. readonly touched: boolean;
  12799. /**
  12800. * Value of the button/trigger
  12801. */
  12802. readonly value: number;
  12803. }
  12804. /** @hidden */
  12805. export interface _GamePadFactory {
  12806. /**
  12807. * Returns wether or not the current gamepad can be created for this type of controller.
  12808. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12809. * @returns true if it can be created, otherwise false
  12810. */
  12811. canCreate(gamepadInfo: any): boolean;
  12812. /**
  12813. * Creates a new instance of the Gamepad.
  12814. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12815. * @returns the new gamepad instance
  12816. */
  12817. create(gamepadInfo: any): Gamepad;
  12818. }
  12819. /**
  12820. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12821. */
  12822. export class PoseEnabledControllerHelper {
  12823. /** @hidden */
  12824. static _ControllerFactories: _GamePadFactory[];
  12825. /** @hidden */
  12826. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12827. /**
  12828. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12829. * @param vrGamepad the gamepad to initialized
  12830. * @returns a vr controller of the type the gamepad identified as
  12831. */
  12832. static InitiateController(vrGamepad: any): Gamepad;
  12833. }
  12834. /**
  12835. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12836. */
  12837. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12838. private _deviceRoomPosition;
  12839. private _deviceRoomRotationQuaternion;
  12840. /**
  12841. * The device position in babylon space
  12842. */
  12843. devicePosition: Vector3;
  12844. /**
  12845. * The device rotation in babylon space
  12846. */
  12847. deviceRotationQuaternion: Quaternion;
  12848. /**
  12849. * The scale factor of the device in babylon space
  12850. */
  12851. deviceScaleFactor: number;
  12852. /**
  12853. * (Likely devicePosition should be used instead) The device position in its room space
  12854. */
  12855. position: Vector3;
  12856. /**
  12857. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12858. */
  12859. rotationQuaternion: Quaternion;
  12860. /**
  12861. * The type of controller (Eg. Windows mixed reality)
  12862. */
  12863. controllerType: PoseEnabledControllerType;
  12864. protected _calculatedPosition: Vector3;
  12865. private _calculatedRotation;
  12866. /**
  12867. * The raw pose from the device
  12868. */
  12869. rawPose: DevicePose;
  12870. private _trackPosition;
  12871. private _maxRotationDistFromHeadset;
  12872. private _draggedRoomRotation;
  12873. /**
  12874. * @hidden
  12875. */
  12876. _disableTrackPosition(fixedPosition: Vector3): void;
  12877. /**
  12878. * Internal, the mesh attached to the controller
  12879. * @hidden
  12880. */
  12881. _mesh: Nullable<AbstractMesh>;
  12882. private _poseControlledCamera;
  12883. private _leftHandSystemQuaternion;
  12884. /**
  12885. * Internal, matrix used to convert room space to babylon space
  12886. * @hidden
  12887. */
  12888. _deviceToWorld: Matrix;
  12889. /**
  12890. * Node to be used when casting a ray from the controller
  12891. * @hidden
  12892. */
  12893. _pointingPoseNode: Nullable<TransformNode>;
  12894. /**
  12895. * Name of the child mesh that can be used to cast a ray from the controller
  12896. */
  12897. static readonly POINTING_POSE: string;
  12898. /**
  12899. * Creates a new PoseEnabledController from a gamepad
  12900. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12901. */
  12902. constructor(browserGamepad: any);
  12903. private _workingMatrix;
  12904. /**
  12905. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12906. */
  12907. update(): void;
  12908. /**
  12909. * Updates only the pose device and mesh without doing any button event checking
  12910. */
  12911. protected _updatePoseAndMesh(): void;
  12912. /**
  12913. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12914. * @param poseData raw pose fromthe device
  12915. */
  12916. updateFromDevice(poseData: DevicePose): void;
  12917. /**
  12918. * @hidden
  12919. */
  12920. _meshAttachedObservable: Observable<AbstractMesh>;
  12921. /**
  12922. * Attaches a mesh to the controller
  12923. * @param mesh the mesh to be attached
  12924. */
  12925. attachToMesh(mesh: AbstractMesh): void;
  12926. /**
  12927. * Attaches the controllers mesh to a camera
  12928. * @param camera the camera the mesh should be attached to
  12929. */
  12930. attachToPoseControlledCamera(camera: TargetCamera): void;
  12931. /**
  12932. * Disposes of the controller
  12933. */
  12934. dispose(): void;
  12935. /**
  12936. * The mesh that is attached to the controller
  12937. */
  12938. readonly mesh: Nullable<AbstractMesh>;
  12939. /**
  12940. * Gets the ray of the controller in the direction the controller is pointing
  12941. * @param length the length the resulting ray should be
  12942. * @returns a ray in the direction the controller is pointing
  12943. */
  12944. getForwardRay(length?: number): Ray;
  12945. }
  12946. }
  12947. declare module BABYLON {
  12948. /**
  12949. * Defines the WebVRController object that represents controllers tracked in 3D space
  12950. */
  12951. export abstract class WebVRController extends PoseEnabledController {
  12952. /**
  12953. * Internal, the default controller model for the controller
  12954. */
  12955. protected _defaultModel: AbstractMesh;
  12956. /**
  12957. * Fired when the trigger state has changed
  12958. */
  12959. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12960. /**
  12961. * Fired when the main button state has changed
  12962. */
  12963. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12964. /**
  12965. * Fired when the secondary button state has changed
  12966. */
  12967. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12968. /**
  12969. * Fired when the pad state has changed
  12970. */
  12971. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12972. /**
  12973. * Fired when controllers stick values have changed
  12974. */
  12975. onPadValuesChangedObservable: Observable<StickValues>;
  12976. /**
  12977. * Array of button availible on the controller
  12978. */
  12979. protected _buttons: Array<MutableGamepadButton>;
  12980. private _onButtonStateChange;
  12981. /**
  12982. * Fired when a controller button's state has changed
  12983. * @param callback the callback containing the button that was modified
  12984. */
  12985. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12986. /**
  12987. * X and Y axis corrisponding to the controllers joystick
  12988. */
  12989. pad: StickValues;
  12990. /**
  12991. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12992. */
  12993. hand: string;
  12994. /**
  12995. * The default controller model for the controller
  12996. */
  12997. readonly defaultModel: AbstractMesh;
  12998. /**
  12999. * Creates a new WebVRController from a gamepad
  13000. * @param vrGamepad the gamepad that the WebVRController should be created from
  13001. */
  13002. constructor(vrGamepad: any);
  13003. /**
  13004. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13005. */
  13006. update(): void;
  13007. /**
  13008. * Function to be called when a button is modified
  13009. */
  13010. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13011. /**
  13012. * Loads a mesh and attaches it to the controller
  13013. * @param scene the scene the mesh should be added to
  13014. * @param meshLoaded callback for when the mesh has been loaded
  13015. */
  13016. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13017. private _setButtonValue;
  13018. private _changes;
  13019. private _checkChanges;
  13020. /**
  13021. * Disposes of th webVRCOntroller
  13022. */
  13023. dispose(): void;
  13024. }
  13025. }
  13026. declare module BABYLON {
  13027. /**
  13028. * The HemisphericLight simulates the ambient environment light,
  13029. * so the passed direction is the light reflection direction, not the incoming direction.
  13030. */
  13031. export class HemisphericLight extends Light {
  13032. /**
  13033. * The groundColor is the light in the opposite direction to the one specified during creation.
  13034. * 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.
  13035. */
  13036. groundColor: Color3;
  13037. /**
  13038. * The light reflection direction, not the incoming direction.
  13039. */
  13040. direction: Vector3;
  13041. /**
  13042. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13043. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13044. * The HemisphericLight can't cast shadows.
  13045. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13046. * @param name The friendly name of the light
  13047. * @param direction The direction of the light reflection
  13048. * @param scene The scene the light belongs to
  13049. */
  13050. constructor(name: string, direction: Vector3, scene: Scene);
  13051. protected _buildUniformLayout(): void;
  13052. /**
  13053. * Returns the string "HemisphericLight".
  13054. * @return The class name
  13055. */
  13056. getClassName(): string;
  13057. /**
  13058. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13059. * Returns the updated direction.
  13060. * @param target The target the direction should point to
  13061. * @return The computed direction
  13062. */
  13063. setDirectionToTarget(target: Vector3): Vector3;
  13064. /**
  13065. * Returns the shadow generator associated to the light.
  13066. * @returns Always null for hemispheric lights because it does not support shadows.
  13067. */
  13068. getShadowGenerator(): Nullable<IShadowGenerator>;
  13069. /**
  13070. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13071. * @param effect The effect to update
  13072. * @param lightIndex The index of the light in the effect to update
  13073. * @returns The hemispheric light
  13074. */
  13075. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13076. /**
  13077. * Computes the world matrix of the node
  13078. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13079. * @param useWasUpdatedFlag defines a reserved property
  13080. * @returns the world matrix
  13081. */
  13082. computeWorldMatrix(): Matrix;
  13083. /**
  13084. * Returns the integer 3.
  13085. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13086. */
  13087. getTypeID(): number;
  13088. /**
  13089. * Prepares the list of defines specific to the light type.
  13090. * @param defines the list of defines
  13091. * @param lightIndex defines the index of the light for the effect
  13092. */
  13093. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13094. }
  13095. }
  13096. declare module BABYLON {
  13097. /** @hidden */
  13098. export var vrMultiviewToSingleviewPixelShader: {
  13099. name: string;
  13100. shader: string;
  13101. };
  13102. }
  13103. declare module BABYLON {
  13104. /**
  13105. * Renders to multiple views with a single draw call
  13106. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13107. */
  13108. export class MultiviewRenderTarget extends RenderTargetTexture {
  13109. /**
  13110. * Creates a multiview render target
  13111. * @param scene scene used with the render target
  13112. * @param size the size of the render target (used for each view)
  13113. */
  13114. constructor(scene: Scene, size?: number | {
  13115. width: number;
  13116. height: number;
  13117. } | {
  13118. ratio: number;
  13119. });
  13120. /**
  13121. * @hidden
  13122. * @param faceIndex the face index, if its a cube texture
  13123. */
  13124. _bindFrameBuffer(faceIndex?: number): void;
  13125. /**
  13126. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13127. * @returns the view count
  13128. */
  13129. getViewCount(): number;
  13130. }
  13131. }
  13132. declare module BABYLON {
  13133. interface Engine {
  13134. /**
  13135. * Creates a new multiview render target
  13136. * @param width defines the width of the texture
  13137. * @param height defines the height of the texture
  13138. * @returns the created multiview texture
  13139. */
  13140. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13141. /**
  13142. * Binds a multiview framebuffer to be drawn to
  13143. * @param multiviewTexture texture to bind
  13144. */
  13145. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13146. }
  13147. interface Camera {
  13148. /**
  13149. * @hidden
  13150. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13151. */
  13152. _useMultiviewToSingleView: boolean;
  13153. /**
  13154. * @hidden
  13155. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13156. */
  13157. _multiviewTexture: Nullable<RenderTargetTexture>;
  13158. /**
  13159. * @hidden
  13160. * ensures the multiview texture of the camera exists and has the specified width/height
  13161. * @param width height to set on the multiview texture
  13162. * @param height width to set on the multiview texture
  13163. */
  13164. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13165. }
  13166. interface Scene {
  13167. /** @hidden */
  13168. _transformMatrixR: Matrix;
  13169. /** @hidden */
  13170. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13171. /** @hidden */
  13172. _createMultiviewUbo(): void;
  13173. /** @hidden */
  13174. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13175. /** @hidden */
  13176. _renderMultiviewToSingleView(camera: Camera): void;
  13177. }
  13178. }
  13179. declare module BABYLON {
  13180. /**
  13181. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13182. * This will not be used for webXR as it supports displaying texture arrays directly
  13183. */
  13184. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13185. /**
  13186. * Initializes a VRMultiviewToSingleview
  13187. * @param name name of the post process
  13188. * @param camera camera to be applied to
  13189. * @param scaleFactor scaling factor to the size of the output texture
  13190. */
  13191. constructor(name: string, camera: Camera, scaleFactor: number);
  13192. }
  13193. }
  13194. declare module BABYLON {
  13195. /**
  13196. * Defines the interface used by display changed events
  13197. */
  13198. interface IDisplayChangedEventArgs {
  13199. /** Gets the vrDisplay object (if any) */
  13200. vrDisplay: Nullable<any>;
  13201. /** Gets a boolean indicating if webVR is supported */
  13202. vrSupported: boolean;
  13203. }
  13204. interface Engine {
  13205. /** @hidden */
  13206. _vrDisplay: any;
  13207. /** @hidden */
  13208. _vrSupported: boolean;
  13209. /** @hidden */
  13210. _oldSize: Size;
  13211. /** @hidden */
  13212. _oldHardwareScaleFactor: number;
  13213. /** @hidden */
  13214. _vrExclusivePointerMode: boolean;
  13215. /** @hidden */
  13216. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13217. /** @hidden */
  13218. _onVRDisplayPointerRestricted: () => void;
  13219. /** @hidden */
  13220. _onVRDisplayPointerUnrestricted: () => void;
  13221. /** @hidden */
  13222. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13223. /** @hidden */
  13224. _onVrDisplayDisconnect: Nullable<() => void>;
  13225. /** @hidden */
  13226. _onVrDisplayPresentChange: Nullable<() => void>;
  13227. /**
  13228. * Observable signaled when VR display mode changes
  13229. */
  13230. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13231. /**
  13232. * Observable signaled when VR request present is complete
  13233. */
  13234. onVRRequestPresentComplete: Observable<boolean>;
  13235. /**
  13236. * Observable signaled when VR request present starts
  13237. */
  13238. onVRRequestPresentStart: Observable<Engine>;
  13239. /**
  13240. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13241. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13242. */
  13243. isInVRExclusivePointerMode: boolean;
  13244. /**
  13245. * Gets a boolean indicating if a webVR device was detected
  13246. * @returns true if a webVR device was detected
  13247. */
  13248. isVRDevicePresent(): boolean;
  13249. /**
  13250. * Gets the current webVR device
  13251. * @returns the current webVR device (or null)
  13252. */
  13253. getVRDevice(): any;
  13254. /**
  13255. * Initializes a webVR display and starts listening to display change events
  13256. * The onVRDisplayChangedObservable will be notified upon these changes
  13257. * @returns A promise containing a VRDisplay and if vr is supported
  13258. */
  13259. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13260. /** @hidden */
  13261. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13262. /**
  13263. * Call this function to switch to webVR mode
  13264. * Will do nothing if webVR is not supported or if there is no webVR device
  13265. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13266. */
  13267. enableVR(): void;
  13268. /** @hidden */
  13269. _onVRFullScreenTriggered(): void;
  13270. }
  13271. }
  13272. declare module BABYLON {
  13273. /**
  13274. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13275. * IMPORTANT!! The data is right-hand data.
  13276. * @export
  13277. * @interface DevicePose
  13278. */
  13279. export interface DevicePose {
  13280. /**
  13281. * The position of the device, values in array are [x,y,z].
  13282. */
  13283. readonly position: Nullable<Float32Array>;
  13284. /**
  13285. * The linearVelocity of the device, values in array are [x,y,z].
  13286. */
  13287. readonly linearVelocity: Nullable<Float32Array>;
  13288. /**
  13289. * The linearAcceleration of the device, values in array are [x,y,z].
  13290. */
  13291. readonly linearAcceleration: Nullable<Float32Array>;
  13292. /**
  13293. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13294. */
  13295. readonly orientation: Nullable<Float32Array>;
  13296. /**
  13297. * The angularVelocity of the device, values in array are [x,y,z].
  13298. */
  13299. readonly angularVelocity: Nullable<Float32Array>;
  13300. /**
  13301. * The angularAcceleration of the device, values in array are [x,y,z].
  13302. */
  13303. readonly angularAcceleration: Nullable<Float32Array>;
  13304. }
  13305. /**
  13306. * Interface representing a pose controlled object in Babylon.
  13307. * A pose controlled object has both regular pose values as well as pose values
  13308. * from an external device such as a VR head mounted display
  13309. */
  13310. export interface PoseControlled {
  13311. /**
  13312. * The position of the object in babylon space.
  13313. */
  13314. position: Vector3;
  13315. /**
  13316. * The rotation quaternion of the object in babylon space.
  13317. */
  13318. rotationQuaternion: Quaternion;
  13319. /**
  13320. * The position of the device in babylon space.
  13321. */
  13322. devicePosition?: Vector3;
  13323. /**
  13324. * The rotation quaternion of the device in babylon space.
  13325. */
  13326. deviceRotationQuaternion: Quaternion;
  13327. /**
  13328. * The raw pose coming from the device.
  13329. */
  13330. rawPose: Nullable<DevicePose>;
  13331. /**
  13332. * The scale of the device to be used when translating from device space to babylon space.
  13333. */
  13334. deviceScaleFactor: number;
  13335. /**
  13336. * Updates the poseControlled values based on the input device pose.
  13337. * @param poseData the pose data to update the object with
  13338. */
  13339. updateFromDevice(poseData: DevicePose): void;
  13340. }
  13341. /**
  13342. * Set of options to customize the webVRCamera
  13343. */
  13344. export interface WebVROptions {
  13345. /**
  13346. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13347. */
  13348. trackPosition?: boolean;
  13349. /**
  13350. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13351. */
  13352. positionScale?: number;
  13353. /**
  13354. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13355. */
  13356. displayName?: string;
  13357. /**
  13358. * Should the native controller meshes be initialized. (default: true)
  13359. */
  13360. controllerMeshes?: boolean;
  13361. /**
  13362. * Creating a default HemiLight only on controllers. (default: true)
  13363. */
  13364. defaultLightingOnControllers?: boolean;
  13365. /**
  13366. * If you don't want to use the default VR button of the helper. (default: false)
  13367. */
  13368. useCustomVRButton?: boolean;
  13369. /**
  13370. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13371. */
  13372. customVRButton?: HTMLButtonElement;
  13373. /**
  13374. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13375. */
  13376. rayLength?: number;
  13377. /**
  13378. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13379. */
  13380. defaultHeight?: number;
  13381. /**
  13382. * If multiview should be used if availible (default: false)
  13383. */
  13384. useMultiview?: boolean;
  13385. }
  13386. /**
  13387. * This represents a WebVR camera.
  13388. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13389. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13390. */
  13391. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13392. private webVROptions;
  13393. /**
  13394. * @hidden
  13395. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13396. */
  13397. _vrDevice: any;
  13398. /**
  13399. * The rawPose of the vrDevice.
  13400. */
  13401. rawPose: Nullable<DevicePose>;
  13402. private _onVREnabled;
  13403. private _specsVersion;
  13404. private _attached;
  13405. private _frameData;
  13406. protected _descendants: Array<Node>;
  13407. private _deviceRoomPosition;
  13408. /** @hidden */
  13409. _deviceRoomRotationQuaternion: Quaternion;
  13410. private _standingMatrix;
  13411. /**
  13412. * Represents device position in babylon space.
  13413. */
  13414. devicePosition: Vector3;
  13415. /**
  13416. * Represents device rotation in babylon space.
  13417. */
  13418. deviceRotationQuaternion: Quaternion;
  13419. /**
  13420. * The scale of the device to be used when translating from device space to babylon space.
  13421. */
  13422. deviceScaleFactor: number;
  13423. private _deviceToWorld;
  13424. private _worldToDevice;
  13425. /**
  13426. * References to the webVR controllers for the vrDevice.
  13427. */
  13428. controllers: Array<WebVRController>;
  13429. /**
  13430. * Emits an event when a controller is attached.
  13431. */
  13432. onControllersAttachedObservable: Observable<WebVRController[]>;
  13433. /**
  13434. * Emits an event when a controller's mesh has been loaded;
  13435. */
  13436. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13437. /**
  13438. * Emits an event when the HMD's pose has been updated.
  13439. */
  13440. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13441. private _poseSet;
  13442. /**
  13443. * If the rig cameras be used as parent instead of this camera.
  13444. */
  13445. rigParenting: boolean;
  13446. private _lightOnControllers;
  13447. private _defaultHeight?;
  13448. /**
  13449. * Instantiates a WebVRFreeCamera.
  13450. * @param name The name of the WebVRFreeCamera
  13451. * @param position The starting anchor position for the camera
  13452. * @param scene The scene the camera belongs to
  13453. * @param webVROptions a set of customizable options for the webVRCamera
  13454. */
  13455. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13456. /**
  13457. * Gets the device distance from the ground in meters.
  13458. * @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.
  13459. */
  13460. deviceDistanceToRoomGround(): number;
  13461. /**
  13462. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13463. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13464. */
  13465. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13466. /**
  13467. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13468. * @returns A promise with a boolean set to if the standing matrix is supported.
  13469. */
  13470. useStandingMatrixAsync(): Promise<boolean>;
  13471. /**
  13472. * Disposes the camera
  13473. */
  13474. dispose(): void;
  13475. /**
  13476. * Gets a vrController by name.
  13477. * @param name The name of the controller to retreive
  13478. * @returns the controller matching the name specified or null if not found
  13479. */
  13480. getControllerByName(name: string): Nullable<WebVRController>;
  13481. private _leftController;
  13482. /**
  13483. * The controller corrisponding to the users left hand.
  13484. */
  13485. readonly leftController: Nullable<WebVRController>;
  13486. private _rightController;
  13487. /**
  13488. * The controller corrisponding to the users right hand.
  13489. */
  13490. readonly rightController: Nullable<WebVRController>;
  13491. /**
  13492. * Casts a ray forward from the vrCamera's gaze.
  13493. * @param length Length of the ray (default: 100)
  13494. * @returns the ray corrisponding to the gaze
  13495. */
  13496. getForwardRay(length?: number): Ray;
  13497. /**
  13498. * @hidden
  13499. * Updates the camera based on device's frame data
  13500. */
  13501. _checkInputs(): void;
  13502. /**
  13503. * Updates the poseControlled values based on the input device pose.
  13504. * @param poseData Pose coming from the device
  13505. */
  13506. updateFromDevice(poseData: DevicePose): void;
  13507. private _htmlElementAttached;
  13508. private _detachIfAttached;
  13509. /**
  13510. * WebVR's attach control will start broadcasting frames to the device.
  13511. * Note that in certain browsers (chrome for example) this function must be called
  13512. * within a user-interaction callback. Example:
  13513. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13514. *
  13515. * @param element html element to attach the vrDevice to
  13516. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13517. */
  13518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13519. /**
  13520. * Detaches the camera from the html element and disables VR
  13521. *
  13522. * @param element html element to detach from
  13523. */
  13524. detachControl(element: HTMLElement): void;
  13525. /**
  13526. * @returns the name of this class
  13527. */
  13528. getClassName(): string;
  13529. /**
  13530. * Calls resetPose on the vrDisplay
  13531. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13532. */
  13533. resetToCurrentRotation(): void;
  13534. /**
  13535. * @hidden
  13536. * Updates the rig cameras (left and right eye)
  13537. */
  13538. _updateRigCameras(): void;
  13539. private _workingVector;
  13540. private _oneVector;
  13541. private _workingMatrix;
  13542. private updateCacheCalled;
  13543. private _correctPositionIfNotTrackPosition;
  13544. /**
  13545. * @hidden
  13546. * Updates the cached values of the camera
  13547. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13548. */
  13549. _updateCache(ignoreParentClass?: boolean): void;
  13550. /**
  13551. * @hidden
  13552. * Get current device position in babylon world
  13553. */
  13554. _computeDevicePosition(): void;
  13555. /**
  13556. * Updates the current device position and rotation in the babylon world
  13557. */
  13558. update(): void;
  13559. /**
  13560. * @hidden
  13561. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13562. * @returns an identity matrix
  13563. */
  13564. _getViewMatrix(): Matrix;
  13565. private _tmpMatrix;
  13566. /**
  13567. * This function is called by the two RIG cameras.
  13568. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13569. * @hidden
  13570. */
  13571. _getWebVRViewMatrix(): Matrix;
  13572. /** @hidden */
  13573. _getWebVRProjectionMatrix(): Matrix;
  13574. private _onGamepadConnectedObserver;
  13575. private _onGamepadDisconnectedObserver;
  13576. private _updateCacheWhenTrackingDisabledObserver;
  13577. /**
  13578. * Initializes the controllers and their meshes
  13579. */
  13580. initControllers(): void;
  13581. }
  13582. }
  13583. declare module BABYLON {
  13584. /**
  13585. * Size options for a post process
  13586. */
  13587. export type PostProcessOptions = {
  13588. width: number;
  13589. height: number;
  13590. };
  13591. /**
  13592. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13593. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13594. */
  13595. export class PostProcess {
  13596. /** Name of the PostProcess. */
  13597. name: string;
  13598. /**
  13599. * Gets or sets the unique id of the post process
  13600. */
  13601. uniqueId: number;
  13602. /**
  13603. * Width of the texture to apply the post process on
  13604. */
  13605. width: number;
  13606. /**
  13607. * Height of the texture to apply the post process on
  13608. */
  13609. height: number;
  13610. /**
  13611. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13612. * @hidden
  13613. */
  13614. _outputTexture: Nullable<InternalTexture>;
  13615. /**
  13616. * Sampling mode used by the shader
  13617. * See https://doc.babylonjs.com/classes/3.1/texture
  13618. */
  13619. renderTargetSamplingMode: number;
  13620. /**
  13621. * Clear color to use when screen clearing
  13622. */
  13623. clearColor: Color4;
  13624. /**
  13625. * If the buffer needs to be cleared before applying the post process. (default: true)
  13626. * Should be set to false if shader will overwrite all previous pixels.
  13627. */
  13628. autoClear: boolean;
  13629. /**
  13630. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13631. */
  13632. alphaMode: number;
  13633. /**
  13634. * Sets the setAlphaBlendConstants of the babylon engine
  13635. */
  13636. alphaConstants: Color4;
  13637. /**
  13638. * Animations to be used for the post processing
  13639. */
  13640. animations: Animation[];
  13641. /**
  13642. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13643. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13644. */
  13645. enablePixelPerfectMode: boolean;
  13646. /**
  13647. * Force the postprocess to be applied without taking in account viewport
  13648. */
  13649. forceFullscreenViewport: boolean;
  13650. /**
  13651. * List of inspectable custom properties (used by the Inspector)
  13652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13653. */
  13654. inspectableCustomProperties: IInspectable[];
  13655. /**
  13656. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13657. *
  13658. * | Value | Type | Description |
  13659. * | ----- | ----------------------------------- | ----------- |
  13660. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13661. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13662. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13663. *
  13664. */
  13665. scaleMode: number;
  13666. /**
  13667. * Force textures to be a power of two (default: false)
  13668. */
  13669. alwaysForcePOT: boolean;
  13670. private _samples;
  13671. /**
  13672. * Number of sample textures (default: 1)
  13673. */
  13674. samples: number;
  13675. /**
  13676. * Modify the scale of the post process to be the same as the viewport (default: false)
  13677. */
  13678. adaptScaleToCurrentViewport: boolean;
  13679. private _camera;
  13680. private _scene;
  13681. private _engine;
  13682. private _options;
  13683. private _reusable;
  13684. private _textureType;
  13685. /**
  13686. * Smart array of input and output textures for the post process.
  13687. * @hidden
  13688. */
  13689. _textures: SmartArray<InternalTexture>;
  13690. /**
  13691. * The index in _textures that corresponds to the output texture.
  13692. * @hidden
  13693. */
  13694. _currentRenderTextureInd: number;
  13695. private _effect;
  13696. private _samplers;
  13697. private _fragmentUrl;
  13698. private _vertexUrl;
  13699. private _parameters;
  13700. private _scaleRatio;
  13701. protected _indexParameters: any;
  13702. private _shareOutputWithPostProcess;
  13703. private _texelSize;
  13704. private _forcedOutputTexture;
  13705. /**
  13706. * Returns the fragment url or shader name used in the post process.
  13707. * @returns the fragment url or name in the shader store.
  13708. */
  13709. getEffectName(): string;
  13710. /**
  13711. * An event triggered when the postprocess is activated.
  13712. */
  13713. onActivateObservable: Observable<Camera>;
  13714. private _onActivateObserver;
  13715. /**
  13716. * A function that is added to the onActivateObservable
  13717. */
  13718. onActivate: Nullable<(camera: Camera) => void>;
  13719. /**
  13720. * An event triggered when the postprocess changes its size.
  13721. */
  13722. onSizeChangedObservable: Observable<PostProcess>;
  13723. private _onSizeChangedObserver;
  13724. /**
  13725. * A function that is added to the onSizeChangedObservable
  13726. */
  13727. onSizeChanged: (postProcess: PostProcess) => void;
  13728. /**
  13729. * An event triggered when the postprocess applies its effect.
  13730. */
  13731. onApplyObservable: Observable<Effect>;
  13732. private _onApplyObserver;
  13733. /**
  13734. * A function that is added to the onApplyObservable
  13735. */
  13736. onApply: (effect: Effect) => void;
  13737. /**
  13738. * An event triggered before rendering the postprocess
  13739. */
  13740. onBeforeRenderObservable: Observable<Effect>;
  13741. private _onBeforeRenderObserver;
  13742. /**
  13743. * A function that is added to the onBeforeRenderObservable
  13744. */
  13745. onBeforeRender: (effect: Effect) => void;
  13746. /**
  13747. * An event triggered after rendering the postprocess
  13748. */
  13749. onAfterRenderObservable: Observable<Effect>;
  13750. private _onAfterRenderObserver;
  13751. /**
  13752. * A function that is added to the onAfterRenderObservable
  13753. */
  13754. onAfterRender: (efect: Effect) => void;
  13755. /**
  13756. * 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
  13757. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13758. */
  13759. inputTexture: InternalTexture;
  13760. /**
  13761. * Gets the camera which post process is applied to.
  13762. * @returns The camera the post process is applied to.
  13763. */
  13764. getCamera(): Camera;
  13765. /**
  13766. * Gets the texel size of the postprocess.
  13767. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13768. */
  13769. readonly texelSize: Vector2;
  13770. /**
  13771. * Creates a new instance PostProcess
  13772. * @param name The name of the PostProcess.
  13773. * @param fragmentUrl The url of the fragment shader to be used.
  13774. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13775. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13776. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13777. * @param camera The camera to apply the render pass to.
  13778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13779. * @param engine The engine which the post process will be applied. (default: current engine)
  13780. * @param reusable If the post process can be reused on the same frame. (default: false)
  13781. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13782. * @param textureType Type of textures used when performing the post process. (default: 0)
  13783. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13784. * @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
  13785. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13786. */
  13787. constructor(
  13788. /** Name of the PostProcess. */
  13789. 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);
  13790. /**
  13791. * Gets a string idenfifying the name of the class
  13792. * @returns "PostProcess" string
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Gets the engine which this post process belongs to.
  13797. * @returns The engine the post process was enabled with.
  13798. */
  13799. getEngine(): Engine;
  13800. /**
  13801. * The effect that is created when initializing the post process.
  13802. * @returns The created effect corrisponding the the postprocess.
  13803. */
  13804. getEffect(): Effect;
  13805. /**
  13806. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13807. * @param postProcess The post process to share the output with.
  13808. * @returns This post process.
  13809. */
  13810. shareOutputWith(postProcess: PostProcess): PostProcess;
  13811. /**
  13812. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13813. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13814. */
  13815. useOwnOutput(): void;
  13816. /**
  13817. * Updates the effect with the current post process compile time values and recompiles the shader.
  13818. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13819. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13820. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13821. * @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
  13822. * @param onCompiled Called when the shader has been compiled.
  13823. * @param onError Called if there is an error when compiling a shader.
  13824. */
  13825. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13826. /**
  13827. * The post process is reusable if it can be used multiple times within one frame.
  13828. * @returns If the post process is reusable
  13829. */
  13830. isReusable(): boolean;
  13831. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13832. markTextureDirty(): void;
  13833. /**
  13834. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13835. * 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.
  13836. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13837. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13838. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13839. * @returns The target texture that was bound to be written to.
  13840. */
  13841. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13842. /**
  13843. * If the post process is supported.
  13844. */
  13845. readonly isSupported: boolean;
  13846. /**
  13847. * The aspect ratio of the output texture.
  13848. */
  13849. readonly aspectRatio: number;
  13850. /**
  13851. * Get a value indicating if the post-process is ready to be used
  13852. * @returns true if the post-process is ready (shader is compiled)
  13853. */
  13854. isReady(): boolean;
  13855. /**
  13856. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13857. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13858. */
  13859. apply(): Nullable<Effect>;
  13860. private _disposeTextures;
  13861. /**
  13862. * Disposes the post process.
  13863. * @param camera The camera to dispose the post process on.
  13864. */
  13865. dispose(camera?: Camera): void;
  13866. }
  13867. }
  13868. declare module BABYLON {
  13869. /**
  13870. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13871. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13872. */
  13873. export class PostProcessManager {
  13874. private _scene;
  13875. private _indexBuffer;
  13876. private _vertexBuffers;
  13877. /**
  13878. * Creates a new instance PostProcess
  13879. * @param scene The scene that the post process is associated with.
  13880. */
  13881. constructor(scene: Scene);
  13882. private _prepareBuffers;
  13883. private _buildIndexBuffer;
  13884. /**
  13885. * Rebuilds the vertex buffers of the manager.
  13886. * @hidden
  13887. */
  13888. _rebuild(): void;
  13889. /**
  13890. * Prepares a frame to be run through a post process.
  13891. * @param sourceTexture The input texture to the post procesess. (default: null)
  13892. * @param postProcesses An array of post processes to be run. (default: null)
  13893. * @returns True if the post processes were able to be run.
  13894. * @hidden
  13895. */
  13896. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13897. /**
  13898. * Manually render a set of post processes to a texture.
  13899. * @param postProcesses An array of post processes to be run.
  13900. * @param targetTexture The target texture to render to.
  13901. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13902. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13903. * @param lodLevel defines which lod of the texture to render to
  13904. */
  13905. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13906. /**
  13907. * Finalize the result of the output of the postprocesses.
  13908. * @param doNotPresent If true the result will not be displayed to the screen.
  13909. * @param targetTexture The target texture to render to.
  13910. * @param faceIndex The index of the face to bind the target texture to.
  13911. * @param postProcesses The array of post processes to render.
  13912. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13913. * @hidden
  13914. */
  13915. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13916. /**
  13917. * Disposes of the post process manager.
  13918. */
  13919. dispose(): void;
  13920. }
  13921. }
  13922. declare module BABYLON {
  13923. interface AbstractScene {
  13924. /**
  13925. * The list of layers (background and foreground) of the scene
  13926. */
  13927. layers: Array<Layer>;
  13928. }
  13929. /**
  13930. * Defines the layer scene component responsible to manage any layers
  13931. * in a given scene.
  13932. */
  13933. export class LayerSceneComponent implements ISceneComponent {
  13934. /**
  13935. * The component name helpfull to identify the component in the list of scene components.
  13936. */
  13937. readonly name: string;
  13938. /**
  13939. * The scene the component belongs to.
  13940. */
  13941. scene: Scene;
  13942. private _engine;
  13943. /**
  13944. * Creates a new instance of the component for the given scene
  13945. * @param scene Defines the scene to register the component in
  13946. */
  13947. constructor(scene: Scene);
  13948. /**
  13949. * Registers the component in a given scene
  13950. */
  13951. register(): void;
  13952. /**
  13953. * Rebuilds the elements related to this component in case of
  13954. * context lost for instance.
  13955. */
  13956. rebuild(): void;
  13957. /**
  13958. * Disposes the component and the associated ressources.
  13959. */
  13960. dispose(): void;
  13961. private _draw;
  13962. private _drawCameraPredicate;
  13963. private _drawCameraBackground;
  13964. private _drawCameraForeground;
  13965. private _drawRenderTargetPredicate;
  13966. private _drawRenderTargetBackground;
  13967. private _drawRenderTargetForeground;
  13968. }
  13969. }
  13970. declare module BABYLON {
  13971. /** @hidden */
  13972. export var layerPixelShader: {
  13973. name: string;
  13974. shader: string;
  13975. };
  13976. }
  13977. declare module BABYLON {
  13978. /** @hidden */
  13979. export var layerVertexShader: {
  13980. name: string;
  13981. shader: string;
  13982. };
  13983. }
  13984. declare module BABYLON {
  13985. /**
  13986. * This represents a full screen 2d layer.
  13987. * This can be useful to display a picture in the background of your scene for instance.
  13988. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13989. */
  13990. export class Layer {
  13991. /**
  13992. * Define the name of the layer.
  13993. */
  13994. name: string;
  13995. /**
  13996. * Define the texture the layer should display.
  13997. */
  13998. texture: Nullable<Texture>;
  13999. /**
  14000. * Is the layer in background or foreground.
  14001. */
  14002. isBackground: boolean;
  14003. /**
  14004. * Define the color of the layer (instead of texture).
  14005. */
  14006. color: Color4;
  14007. /**
  14008. * Define the scale of the layer in order to zoom in out of the texture.
  14009. */
  14010. scale: Vector2;
  14011. /**
  14012. * Define an offset for the layer in order to shift the texture.
  14013. */
  14014. offset: Vector2;
  14015. /**
  14016. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14017. */
  14018. alphaBlendingMode: number;
  14019. /**
  14020. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14021. * Alpha test will not mix with the background color in case of transparency.
  14022. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14023. */
  14024. alphaTest: boolean;
  14025. /**
  14026. * Define a mask to restrict the layer to only some of the scene cameras.
  14027. */
  14028. layerMask: number;
  14029. /**
  14030. * Define the list of render target the layer is visible into.
  14031. */
  14032. renderTargetTextures: RenderTargetTexture[];
  14033. /**
  14034. * Define if the layer is only used in renderTarget or if it also
  14035. * renders in the main frame buffer of the canvas.
  14036. */
  14037. renderOnlyInRenderTargetTextures: boolean;
  14038. private _scene;
  14039. private _vertexBuffers;
  14040. private _indexBuffer;
  14041. private _effect;
  14042. private _alphaTestEffect;
  14043. /**
  14044. * An event triggered when the layer is disposed.
  14045. */
  14046. onDisposeObservable: Observable<Layer>;
  14047. private _onDisposeObserver;
  14048. /**
  14049. * Back compatibility with callback before the onDisposeObservable existed.
  14050. * The set callback will be triggered when the layer has been disposed.
  14051. */
  14052. onDispose: () => void;
  14053. /**
  14054. * An event triggered before rendering the scene
  14055. */
  14056. onBeforeRenderObservable: Observable<Layer>;
  14057. private _onBeforeRenderObserver;
  14058. /**
  14059. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14060. * The set callback will be triggered just before rendering the layer.
  14061. */
  14062. onBeforeRender: () => void;
  14063. /**
  14064. * An event triggered after rendering the scene
  14065. */
  14066. onAfterRenderObservable: Observable<Layer>;
  14067. private _onAfterRenderObserver;
  14068. /**
  14069. * Back compatibility with callback before the onAfterRenderObservable existed.
  14070. * The set callback will be triggered just after rendering the layer.
  14071. */
  14072. onAfterRender: () => void;
  14073. /**
  14074. * Instantiates a new layer.
  14075. * This represents a full screen 2d layer.
  14076. * This can be useful to display a picture in the background of your scene for instance.
  14077. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14078. * @param name Define the name of the layer in the scene
  14079. * @param imgUrl Define the url of the texture to display in the layer
  14080. * @param scene Define the scene the layer belongs to
  14081. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14082. * @param color Defines a color for the layer
  14083. */
  14084. constructor(
  14085. /**
  14086. * Define the name of the layer.
  14087. */
  14088. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14089. private _createIndexBuffer;
  14090. /** @hidden */
  14091. _rebuild(): void;
  14092. /**
  14093. * Renders the layer in the scene.
  14094. */
  14095. render(): void;
  14096. /**
  14097. * Disposes and releases the associated ressources.
  14098. */
  14099. dispose(): void;
  14100. }
  14101. }
  14102. declare module BABYLON {
  14103. interface AbstractScene {
  14104. /**
  14105. * The list of procedural textures added to the scene
  14106. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14107. */
  14108. proceduralTextures: Array<ProceduralTexture>;
  14109. }
  14110. /**
  14111. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14112. * in a given scene.
  14113. */
  14114. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14115. /**
  14116. * The component name helpfull to identify the component in the list of scene components.
  14117. */
  14118. readonly name: string;
  14119. /**
  14120. * The scene the component belongs to.
  14121. */
  14122. scene: Scene;
  14123. /**
  14124. * Creates a new instance of the component for the given scene
  14125. * @param scene Defines the scene to register the component in
  14126. */
  14127. constructor(scene: Scene);
  14128. /**
  14129. * Registers the component in a given scene
  14130. */
  14131. register(): void;
  14132. /**
  14133. * Rebuilds the elements related to this component in case of
  14134. * context lost for instance.
  14135. */
  14136. rebuild(): void;
  14137. /**
  14138. * Disposes the component and the associated ressources.
  14139. */
  14140. dispose(): void;
  14141. private _beforeClear;
  14142. }
  14143. }
  14144. declare module BABYLON {
  14145. interface Engine {
  14146. /**
  14147. * Creates a new render target cube texture
  14148. * @param size defines the size of the texture
  14149. * @param options defines the options used to create the texture
  14150. * @returns a new render target cube texture stored in an InternalTexture
  14151. */
  14152. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14153. }
  14154. }
  14155. declare module BABYLON {
  14156. /** @hidden */
  14157. export var proceduralVertexShader: {
  14158. name: string;
  14159. shader: string;
  14160. };
  14161. }
  14162. declare module BABYLON {
  14163. /**
  14164. * 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.
  14165. * This is the base class of any Procedural texture and contains most of the shareable code.
  14166. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14167. */
  14168. export class ProceduralTexture extends Texture {
  14169. isCube: boolean;
  14170. /**
  14171. * Define if the texture is enabled or not (disabled texture will not render)
  14172. */
  14173. isEnabled: boolean;
  14174. /**
  14175. * Define if the texture must be cleared before rendering (default is true)
  14176. */
  14177. autoClear: boolean;
  14178. /**
  14179. * Callback called when the texture is generated
  14180. */
  14181. onGenerated: () => void;
  14182. /**
  14183. * Event raised when the texture is generated
  14184. */
  14185. onGeneratedObservable: Observable<ProceduralTexture>;
  14186. /** @hidden */
  14187. _generateMipMaps: boolean;
  14188. /** @hidden **/
  14189. _effect: Effect;
  14190. /** @hidden */
  14191. _textures: {
  14192. [key: string]: Texture;
  14193. };
  14194. private _size;
  14195. private _currentRefreshId;
  14196. private _refreshRate;
  14197. private _vertexBuffers;
  14198. private _indexBuffer;
  14199. private _uniforms;
  14200. private _samplers;
  14201. private _fragment;
  14202. private _floats;
  14203. private _ints;
  14204. private _floatsArrays;
  14205. private _colors3;
  14206. private _colors4;
  14207. private _vectors2;
  14208. private _vectors3;
  14209. private _matrices;
  14210. private _fallbackTexture;
  14211. private _fallbackTextureUsed;
  14212. private _engine;
  14213. private _cachedDefines;
  14214. private _contentUpdateId;
  14215. private _contentData;
  14216. /**
  14217. * Instantiates a new procedural texture.
  14218. * 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.
  14219. * This is the base class of any Procedural texture and contains most of the shareable code.
  14220. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14221. * @param name Define the name of the texture
  14222. * @param size Define the size of the texture to create
  14223. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14224. * @param scene Define the scene the texture belongs to
  14225. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14226. * @param generateMipMaps Define if the texture should creates mip maps or not
  14227. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14228. */
  14229. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14230. /**
  14231. * The effect that is created when initializing the post process.
  14232. * @returns The created effect corrisponding the the postprocess.
  14233. */
  14234. getEffect(): Effect;
  14235. /**
  14236. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14237. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14238. */
  14239. getContent(): Nullable<ArrayBufferView>;
  14240. private _createIndexBuffer;
  14241. /** @hidden */
  14242. _rebuild(): void;
  14243. /**
  14244. * Resets the texture in order to recreate its associated resources.
  14245. * This can be called in case of context loss
  14246. */
  14247. reset(): void;
  14248. protected _getDefines(): string;
  14249. /**
  14250. * Is the texture ready to be used ? (rendered at least once)
  14251. * @returns true if ready, otherwise, false.
  14252. */
  14253. isReady(): boolean;
  14254. /**
  14255. * Resets the refresh counter of the texture and start bak from scratch.
  14256. * Could be useful to regenerate the texture if it is setup to render only once.
  14257. */
  14258. resetRefreshCounter(): void;
  14259. /**
  14260. * Set the fragment shader to use in order to render the texture.
  14261. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14262. */
  14263. setFragment(fragment: any): void;
  14264. /**
  14265. * Define the refresh rate of the texture or the rendering frequency.
  14266. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14267. */
  14268. refreshRate: number;
  14269. /** @hidden */
  14270. _shouldRender(): boolean;
  14271. /**
  14272. * Get the size the texture is rendering at.
  14273. * @returns the size (texture is always squared)
  14274. */
  14275. getRenderSize(): number;
  14276. /**
  14277. * Resize the texture to new value.
  14278. * @param size Define the new size the texture should have
  14279. * @param generateMipMaps Define whether the new texture should create mip maps
  14280. */
  14281. resize(size: number, generateMipMaps: boolean): void;
  14282. private _checkUniform;
  14283. /**
  14284. * Set a texture in the shader program used to render.
  14285. * @param name Define the name of the uniform samplers as defined in the shader
  14286. * @param texture Define the texture to bind to this sampler
  14287. * @return the texture itself allowing "fluent" like uniform updates
  14288. */
  14289. setTexture(name: string, texture: Texture): ProceduralTexture;
  14290. /**
  14291. * Set a float in the shader.
  14292. * @param name Define the name of the uniform as defined in the shader
  14293. * @param value Define the value to give to the uniform
  14294. * @return the texture itself allowing "fluent" like uniform updates
  14295. */
  14296. setFloat(name: string, value: number): ProceduralTexture;
  14297. /**
  14298. * Set a int in the shader.
  14299. * @param name Define the name of the uniform as defined in the shader
  14300. * @param value Define the value to give to the uniform
  14301. * @return the texture itself allowing "fluent" like uniform updates
  14302. */
  14303. setInt(name: string, value: number): ProceduralTexture;
  14304. /**
  14305. * Set an array of floats in the shader.
  14306. * @param name Define the name of the uniform as defined in the shader
  14307. * @param value Define the value to give to the uniform
  14308. * @return the texture itself allowing "fluent" like uniform updates
  14309. */
  14310. setFloats(name: string, value: number[]): ProceduralTexture;
  14311. /**
  14312. * Set a vec3 in the shader from a Color3.
  14313. * @param name Define the name of the uniform as defined in the shader
  14314. * @param value Define the value to give to the uniform
  14315. * @return the texture itself allowing "fluent" like uniform updates
  14316. */
  14317. setColor3(name: string, value: Color3): ProceduralTexture;
  14318. /**
  14319. * Set a vec4 in the shader from a Color4.
  14320. * @param name Define the name of the uniform as defined in the shader
  14321. * @param value Define the value to give to the uniform
  14322. * @return the texture itself allowing "fluent" like uniform updates
  14323. */
  14324. setColor4(name: string, value: Color4): ProceduralTexture;
  14325. /**
  14326. * Set a vec2 in the shader from a Vector2.
  14327. * @param name Define the name of the uniform as defined in the shader
  14328. * @param value Define the value to give to the uniform
  14329. * @return the texture itself allowing "fluent" like uniform updates
  14330. */
  14331. setVector2(name: string, value: Vector2): ProceduralTexture;
  14332. /**
  14333. * Set a vec3 in the shader from a Vector3.
  14334. * @param name Define the name of the uniform as defined in the shader
  14335. * @param value Define the value to give to the uniform
  14336. * @return the texture itself allowing "fluent" like uniform updates
  14337. */
  14338. setVector3(name: string, value: Vector3): ProceduralTexture;
  14339. /**
  14340. * Set a mat4 in the shader from a MAtrix.
  14341. * @param name Define the name of the uniform as defined in the shader
  14342. * @param value Define the value to give to the uniform
  14343. * @return the texture itself allowing "fluent" like uniform updates
  14344. */
  14345. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14346. /**
  14347. * Render the texture to its associated render target.
  14348. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14349. */
  14350. render(useCameraPostProcess?: boolean): void;
  14351. /**
  14352. * Clone the texture.
  14353. * @returns the cloned texture
  14354. */
  14355. clone(): ProceduralTexture;
  14356. /**
  14357. * Dispose the texture and release its asoociated resources.
  14358. */
  14359. dispose(): void;
  14360. }
  14361. }
  14362. declare module BABYLON {
  14363. /**
  14364. * This represents the base class for particle system in Babylon.
  14365. * 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.
  14366. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14367. * @example https://doc.babylonjs.com/babylon101/particles
  14368. */
  14369. export class BaseParticleSystem {
  14370. /**
  14371. * Source color is added to the destination color without alpha affecting the result
  14372. */
  14373. static BLENDMODE_ONEONE: number;
  14374. /**
  14375. * Blend current color and particle color using particle’s alpha
  14376. */
  14377. static BLENDMODE_STANDARD: number;
  14378. /**
  14379. * Add current color and particle color multiplied by particle’s alpha
  14380. */
  14381. static BLENDMODE_ADD: number;
  14382. /**
  14383. * Multiply current color with particle color
  14384. */
  14385. static BLENDMODE_MULTIPLY: number;
  14386. /**
  14387. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14388. */
  14389. static BLENDMODE_MULTIPLYADD: number;
  14390. /**
  14391. * List of animations used by the particle system.
  14392. */
  14393. animations: Animation[];
  14394. /**
  14395. * The id of the Particle system.
  14396. */
  14397. id: string;
  14398. /**
  14399. * The friendly name of the Particle system.
  14400. */
  14401. name: string;
  14402. /**
  14403. * The rendering group used by the Particle system to chose when to render.
  14404. */
  14405. renderingGroupId: number;
  14406. /**
  14407. * The emitter represents the Mesh or position we are attaching the particle system to.
  14408. */
  14409. emitter: Nullable<AbstractMesh | Vector3>;
  14410. /**
  14411. * The maximum number of particles to emit per frame
  14412. */
  14413. emitRate: number;
  14414. /**
  14415. * If you want to launch only a few particles at once, that can be done, as well.
  14416. */
  14417. manualEmitCount: number;
  14418. /**
  14419. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14420. */
  14421. updateSpeed: number;
  14422. /**
  14423. * The amount of time the particle system is running (depends of the overall update speed).
  14424. */
  14425. targetStopDuration: number;
  14426. /**
  14427. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14428. */
  14429. disposeOnStop: boolean;
  14430. /**
  14431. * Minimum power of emitting particles.
  14432. */
  14433. minEmitPower: number;
  14434. /**
  14435. * Maximum power of emitting particles.
  14436. */
  14437. maxEmitPower: number;
  14438. /**
  14439. * Minimum life time of emitting particles.
  14440. */
  14441. minLifeTime: number;
  14442. /**
  14443. * Maximum life time of emitting particles.
  14444. */
  14445. maxLifeTime: number;
  14446. /**
  14447. * Minimum Size of emitting particles.
  14448. */
  14449. minSize: number;
  14450. /**
  14451. * Maximum Size of emitting particles.
  14452. */
  14453. maxSize: number;
  14454. /**
  14455. * Minimum scale of emitting particles on X axis.
  14456. */
  14457. minScaleX: number;
  14458. /**
  14459. * Maximum scale of emitting particles on X axis.
  14460. */
  14461. maxScaleX: number;
  14462. /**
  14463. * Minimum scale of emitting particles on Y axis.
  14464. */
  14465. minScaleY: number;
  14466. /**
  14467. * Maximum scale of emitting particles on Y axis.
  14468. */
  14469. maxScaleY: number;
  14470. /**
  14471. * Gets or sets the minimal initial rotation in radians.
  14472. */
  14473. minInitialRotation: number;
  14474. /**
  14475. * Gets or sets the maximal initial rotation in radians.
  14476. */
  14477. maxInitialRotation: number;
  14478. /**
  14479. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14480. */
  14481. minAngularSpeed: number;
  14482. /**
  14483. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14484. */
  14485. maxAngularSpeed: number;
  14486. /**
  14487. * The texture used to render each particle. (this can be a spritesheet)
  14488. */
  14489. particleTexture: Nullable<Texture>;
  14490. /**
  14491. * The layer mask we are rendering the particles through.
  14492. */
  14493. layerMask: number;
  14494. /**
  14495. * This can help using your own shader to render the particle system.
  14496. * The according effect will be created
  14497. */
  14498. customShader: any;
  14499. /**
  14500. * By default particle system starts as soon as they are created. This prevents the
  14501. * automatic start to happen and let you decide when to start emitting particles.
  14502. */
  14503. preventAutoStart: boolean;
  14504. private _noiseTexture;
  14505. /**
  14506. * Gets or sets a texture used to add random noise to particle positions
  14507. */
  14508. noiseTexture: Nullable<ProceduralTexture>;
  14509. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14510. noiseStrength: Vector3;
  14511. /**
  14512. * Callback triggered when the particle animation is ending.
  14513. */
  14514. onAnimationEnd: Nullable<() => void>;
  14515. /**
  14516. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14517. */
  14518. blendMode: number;
  14519. /**
  14520. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14521. * to override the particles.
  14522. */
  14523. forceDepthWrite: boolean;
  14524. /** 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 */
  14525. preWarmCycles: number;
  14526. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14527. preWarmStepOffset: number;
  14528. /**
  14529. * 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)
  14530. */
  14531. spriteCellChangeSpeed: number;
  14532. /**
  14533. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14534. */
  14535. startSpriteCellID: number;
  14536. /**
  14537. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14538. */
  14539. endSpriteCellID: number;
  14540. /**
  14541. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14542. */
  14543. spriteCellWidth: number;
  14544. /**
  14545. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14546. */
  14547. spriteCellHeight: number;
  14548. /**
  14549. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14550. */
  14551. spriteRandomStartCell: boolean;
  14552. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14553. translationPivot: Vector2;
  14554. /** @hidden */
  14555. protected _isAnimationSheetEnabled: boolean;
  14556. /**
  14557. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14558. */
  14559. beginAnimationOnStart: boolean;
  14560. /**
  14561. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14562. */
  14563. beginAnimationFrom: number;
  14564. /**
  14565. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14566. */
  14567. beginAnimationTo: number;
  14568. /**
  14569. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14570. */
  14571. beginAnimationLoop: boolean;
  14572. /**
  14573. * Gets or sets a world offset applied to all particles
  14574. */
  14575. worldOffset: Vector3;
  14576. /**
  14577. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14578. */
  14579. isAnimationSheetEnabled: boolean;
  14580. /**
  14581. * Get hosting scene
  14582. * @returns the scene
  14583. */
  14584. getScene(): Scene;
  14585. /**
  14586. * You can use gravity if you want to give an orientation to your particles.
  14587. */
  14588. gravity: Vector3;
  14589. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14590. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14591. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14592. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14593. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14594. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14595. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14596. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14597. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14598. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14599. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14600. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14601. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14602. /**
  14603. * Defines the delay in milliseconds before starting the system (0 by default)
  14604. */
  14605. startDelay: number;
  14606. /**
  14607. * Gets the current list of drag gradients.
  14608. * You must use addDragGradient and removeDragGradient to udpate this list
  14609. * @returns the list of drag gradients
  14610. */
  14611. getDragGradients(): Nullable<Array<FactorGradient>>;
  14612. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14613. limitVelocityDamping: number;
  14614. /**
  14615. * Gets the current list of limit velocity gradients.
  14616. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14617. * @returns the list of limit velocity gradients
  14618. */
  14619. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14620. /**
  14621. * Gets the current list of color gradients.
  14622. * You must use addColorGradient and removeColorGradient to udpate this list
  14623. * @returns the list of color gradients
  14624. */
  14625. getColorGradients(): Nullable<Array<ColorGradient>>;
  14626. /**
  14627. * Gets the current list of size gradients.
  14628. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14629. * @returns the list of size gradients
  14630. */
  14631. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14632. /**
  14633. * Gets the current list of color remap gradients.
  14634. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14635. * @returns the list of color remap gradients
  14636. */
  14637. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Gets the current list of alpha remap gradients.
  14640. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14641. * @returns the list of alpha remap gradients
  14642. */
  14643. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14644. /**
  14645. * Gets the current list of life time gradients.
  14646. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14647. * @returns the list of life time gradients
  14648. */
  14649. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14650. /**
  14651. * Gets the current list of angular speed gradients.
  14652. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14653. * @returns the list of angular speed gradients
  14654. */
  14655. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14656. /**
  14657. * Gets the current list of velocity gradients.
  14658. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14659. * @returns the list of velocity gradients
  14660. */
  14661. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14662. /**
  14663. * Gets the current list of start size gradients.
  14664. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14665. * @returns the list of start size gradients
  14666. */
  14667. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14668. /**
  14669. * Gets the current list of emit rate gradients.
  14670. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14671. * @returns the list of emit rate gradients
  14672. */
  14673. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14674. /**
  14675. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14676. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14677. */
  14678. direction1: Vector3;
  14679. /**
  14680. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14681. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14682. */
  14683. direction2: Vector3;
  14684. /**
  14685. * 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.
  14686. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14687. */
  14688. minEmitBox: Vector3;
  14689. /**
  14690. * 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.
  14691. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14692. */
  14693. maxEmitBox: Vector3;
  14694. /**
  14695. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14696. */
  14697. color1: Color4;
  14698. /**
  14699. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14700. */
  14701. color2: Color4;
  14702. /**
  14703. * Color the particle will have at the end of its lifetime
  14704. */
  14705. colorDead: Color4;
  14706. /**
  14707. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14708. */
  14709. textureMask: Color4;
  14710. /**
  14711. * The particle emitter type defines the emitter used by the particle system.
  14712. * It can be for example box, sphere, or cone...
  14713. */
  14714. particleEmitterType: IParticleEmitterType;
  14715. /** @hidden */
  14716. _isSubEmitter: boolean;
  14717. /**
  14718. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14719. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14720. */
  14721. billboardMode: number;
  14722. protected _isBillboardBased: boolean;
  14723. /**
  14724. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14725. */
  14726. isBillboardBased: boolean;
  14727. /**
  14728. * The scene the particle system belongs to.
  14729. */
  14730. protected _scene: Scene;
  14731. /**
  14732. * Local cache of defines for image processing.
  14733. */
  14734. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14735. /**
  14736. * Default configuration related to image processing available in the standard Material.
  14737. */
  14738. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14739. /**
  14740. * Gets the image processing configuration used either in this material.
  14741. */
  14742. /**
  14743. * Sets the Default image processing configuration used either in the this material.
  14744. *
  14745. * If sets to null, the scene one is in use.
  14746. */
  14747. imageProcessingConfiguration: ImageProcessingConfiguration;
  14748. /**
  14749. * Attaches a new image processing configuration to the Standard Material.
  14750. * @param configuration
  14751. */
  14752. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14753. /** @hidden */
  14754. protected _reset(): void;
  14755. /** @hidden */
  14756. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14757. /**
  14758. * Instantiates a particle system.
  14759. * 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.
  14760. * @param name The name of the particle system
  14761. */
  14762. constructor(name: string);
  14763. /**
  14764. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14765. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14766. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14767. * @returns the emitter
  14768. */
  14769. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14770. /**
  14771. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14772. * @param radius The radius of the hemisphere to emit from
  14773. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14774. * @returns the emitter
  14775. */
  14776. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14777. /**
  14778. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14779. * @param radius The radius of the sphere to emit from
  14780. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14781. * @returns the emitter
  14782. */
  14783. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14784. /**
  14785. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14786. * @param radius The radius of the sphere to emit from
  14787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14789. * @returns the emitter
  14790. */
  14791. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14792. /**
  14793. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14794. * @param radius The radius of the emission cylinder
  14795. * @param height The height of the emission cylinder
  14796. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14797. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14798. * @returns the emitter
  14799. */
  14800. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14801. /**
  14802. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14803. * @param radius The radius of the cylinder to emit from
  14804. * @param height The height of the emission cylinder
  14805. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14806. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14807. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14808. * @returns the emitter
  14809. */
  14810. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14811. /**
  14812. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14813. * @param radius The radius of the cone to emit from
  14814. * @param angle The base angle of the cone
  14815. * @returns the emitter
  14816. */
  14817. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14818. /**
  14819. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14820. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14821. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14822. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14823. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14824. * @returns the emitter
  14825. */
  14826. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14827. }
  14828. }
  14829. declare module BABYLON {
  14830. /**
  14831. * Type of sub emitter
  14832. */
  14833. export enum SubEmitterType {
  14834. /**
  14835. * Attached to the particle over it's lifetime
  14836. */
  14837. ATTACHED = 0,
  14838. /**
  14839. * Created when the particle dies
  14840. */
  14841. END = 1
  14842. }
  14843. /**
  14844. * Sub emitter class used to emit particles from an existing particle
  14845. */
  14846. export class SubEmitter {
  14847. /**
  14848. * the particle system to be used by the sub emitter
  14849. */
  14850. particleSystem: ParticleSystem;
  14851. /**
  14852. * Type of the submitter (Default: END)
  14853. */
  14854. type: SubEmitterType;
  14855. /**
  14856. * 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)
  14857. * Note: This only is supported when using an emitter of type Mesh
  14858. */
  14859. inheritDirection: boolean;
  14860. /**
  14861. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14862. */
  14863. inheritedVelocityAmount: number;
  14864. /**
  14865. * Creates a sub emitter
  14866. * @param particleSystem the particle system to be used by the sub emitter
  14867. */
  14868. constructor(
  14869. /**
  14870. * the particle system to be used by the sub emitter
  14871. */
  14872. particleSystem: ParticleSystem);
  14873. /**
  14874. * Clones the sub emitter
  14875. * @returns the cloned sub emitter
  14876. */
  14877. clone(): SubEmitter;
  14878. /**
  14879. * Serialize current object to a JSON object
  14880. * @returns the serialized object
  14881. */
  14882. serialize(): any;
  14883. /** @hidden */
  14884. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14885. /**
  14886. * Creates a new SubEmitter from a serialized JSON version
  14887. * @param serializationObject defines the JSON object to read from
  14888. * @param scene defines the hosting scene
  14889. * @param rootUrl defines the rootUrl for data loading
  14890. * @returns a new SubEmitter
  14891. */
  14892. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14893. /** Release associated resources */
  14894. dispose(): void;
  14895. }
  14896. }
  14897. declare module BABYLON {
  14898. /** @hidden */
  14899. export var clipPlaneFragmentDeclaration: {
  14900. name: string;
  14901. shader: string;
  14902. };
  14903. }
  14904. declare module BABYLON {
  14905. /** @hidden */
  14906. export var imageProcessingDeclaration: {
  14907. name: string;
  14908. shader: string;
  14909. };
  14910. }
  14911. declare module BABYLON {
  14912. /** @hidden */
  14913. export var imageProcessingFunctions: {
  14914. name: string;
  14915. shader: string;
  14916. };
  14917. }
  14918. declare module BABYLON {
  14919. /** @hidden */
  14920. export var clipPlaneFragment: {
  14921. name: string;
  14922. shader: string;
  14923. };
  14924. }
  14925. declare module BABYLON {
  14926. /** @hidden */
  14927. export var particlesPixelShader: {
  14928. name: string;
  14929. shader: string;
  14930. };
  14931. }
  14932. declare module BABYLON {
  14933. /** @hidden */
  14934. export var clipPlaneVertexDeclaration: {
  14935. name: string;
  14936. shader: string;
  14937. };
  14938. }
  14939. declare module BABYLON {
  14940. /** @hidden */
  14941. export var clipPlaneVertex: {
  14942. name: string;
  14943. shader: string;
  14944. };
  14945. }
  14946. declare module BABYLON {
  14947. /** @hidden */
  14948. export var particlesVertexShader: {
  14949. name: string;
  14950. shader: string;
  14951. };
  14952. }
  14953. declare module BABYLON {
  14954. /**
  14955. * This represents a particle system in Babylon.
  14956. * 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.
  14957. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14958. * @example https://doc.babylonjs.com/babylon101/particles
  14959. */
  14960. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14961. /**
  14962. * Billboard mode will only apply to Y axis
  14963. */
  14964. static readonly BILLBOARDMODE_Y: number;
  14965. /**
  14966. * Billboard mode will apply to all axes
  14967. */
  14968. static readonly BILLBOARDMODE_ALL: number;
  14969. /**
  14970. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14971. */
  14972. static readonly BILLBOARDMODE_STRETCHED: number;
  14973. /**
  14974. * This function can be defined to provide custom update for active particles.
  14975. * This function will be called instead of regular update (age, position, color, etc.).
  14976. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14977. */
  14978. updateFunction: (particles: Particle[]) => void;
  14979. private _emitterWorldMatrix;
  14980. /**
  14981. * This function can be defined to specify initial direction for every new particle.
  14982. * It by default use the emitterType defined function
  14983. */
  14984. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14985. /**
  14986. * This function can be defined to specify initial position for every new particle.
  14987. * It by default use the emitterType defined function
  14988. */
  14989. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14990. /**
  14991. * @hidden
  14992. */
  14993. _inheritedVelocityOffset: Vector3;
  14994. /**
  14995. * An event triggered when the system is disposed
  14996. */
  14997. onDisposeObservable: Observable<ParticleSystem>;
  14998. private _onDisposeObserver;
  14999. /**
  15000. * Sets a callback that will be triggered when the system is disposed
  15001. */
  15002. onDispose: () => void;
  15003. private _particles;
  15004. private _epsilon;
  15005. private _capacity;
  15006. private _stockParticles;
  15007. private _newPartsExcess;
  15008. private _vertexData;
  15009. private _vertexBuffer;
  15010. private _vertexBuffers;
  15011. private _spriteBuffer;
  15012. private _indexBuffer;
  15013. private _effect;
  15014. private _customEffect;
  15015. private _cachedDefines;
  15016. private _scaledColorStep;
  15017. private _colorDiff;
  15018. private _scaledDirection;
  15019. private _scaledGravity;
  15020. private _currentRenderId;
  15021. private _alive;
  15022. private _useInstancing;
  15023. private _started;
  15024. private _stopped;
  15025. private _actualFrame;
  15026. private _scaledUpdateSpeed;
  15027. private _vertexBufferSize;
  15028. /** @hidden */
  15029. _currentEmitRateGradient: Nullable<FactorGradient>;
  15030. /** @hidden */
  15031. _currentEmitRate1: number;
  15032. /** @hidden */
  15033. _currentEmitRate2: number;
  15034. /** @hidden */
  15035. _currentStartSizeGradient: Nullable<FactorGradient>;
  15036. /** @hidden */
  15037. _currentStartSize1: number;
  15038. /** @hidden */
  15039. _currentStartSize2: number;
  15040. private readonly _rawTextureWidth;
  15041. private _rampGradientsTexture;
  15042. private _useRampGradients;
  15043. /** Gets or sets a boolean indicating that ramp gradients must be used
  15044. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15045. */
  15046. useRampGradients: boolean;
  15047. /**
  15048. * 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.
  15049. * 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: [])
  15050. */
  15051. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15052. private _subEmitters;
  15053. /**
  15054. * @hidden
  15055. * If the particle systems emitter should be disposed when the particle system is disposed
  15056. */
  15057. _disposeEmitterOnDispose: boolean;
  15058. /**
  15059. * The current active Sub-systems, this property is used by the root particle system only.
  15060. */
  15061. activeSubSystems: Array<ParticleSystem>;
  15062. private _rootParticleSystem;
  15063. /**
  15064. * Gets the current list of active particles
  15065. */
  15066. readonly particles: Particle[];
  15067. /**
  15068. * Returns the string "ParticleSystem"
  15069. * @returns a string containing the class name
  15070. */
  15071. getClassName(): string;
  15072. /**
  15073. * Instantiates a particle system.
  15074. * 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.
  15075. * @param name The name of the particle system
  15076. * @param capacity The max number of particles alive at the same time
  15077. * @param scene The scene the particle system belongs to
  15078. * @param customEffect a custom effect used to change the way particles are rendered by default
  15079. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15080. * @param epsilon Offset used to render the particles
  15081. */
  15082. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15083. private _addFactorGradient;
  15084. private _removeFactorGradient;
  15085. /**
  15086. * Adds a new life time gradient
  15087. * @param gradient defines the gradient to use (between 0 and 1)
  15088. * @param factor defines the life time factor to affect to the specified gradient
  15089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15090. * @returns the current particle system
  15091. */
  15092. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15093. /**
  15094. * Remove a specific life time gradient
  15095. * @param gradient defines the gradient to remove
  15096. * @returns the current particle system
  15097. */
  15098. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15099. /**
  15100. * Adds a new size gradient
  15101. * @param gradient defines the gradient to use (between 0 and 1)
  15102. * @param factor defines the size factor to affect to the specified gradient
  15103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15104. * @returns the current particle system
  15105. */
  15106. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15107. /**
  15108. * Remove a specific size gradient
  15109. * @param gradient defines the gradient to remove
  15110. * @returns the current particle system
  15111. */
  15112. removeSizeGradient(gradient: number): IParticleSystem;
  15113. /**
  15114. * Adds a new color remap gradient
  15115. * @param gradient defines the gradient to use (between 0 and 1)
  15116. * @param min defines the color remap minimal range
  15117. * @param max defines the color remap maximal range
  15118. * @returns the current particle system
  15119. */
  15120. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15121. /**
  15122. * Remove a specific color remap gradient
  15123. * @param gradient defines the gradient to remove
  15124. * @returns the current particle system
  15125. */
  15126. removeColorRemapGradient(gradient: number): IParticleSystem;
  15127. /**
  15128. * Adds a new alpha remap gradient
  15129. * @param gradient defines the gradient to use (between 0 and 1)
  15130. * @param min defines the alpha remap minimal range
  15131. * @param max defines the alpha remap maximal range
  15132. * @returns the current particle system
  15133. */
  15134. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15135. /**
  15136. * Remove a specific alpha remap gradient
  15137. * @param gradient defines the gradient to remove
  15138. * @returns the current particle system
  15139. */
  15140. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15141. /**
  15142. * Adds a new angular speed gradient
  15143. * @param gradient defines the gradient to use (between 0 and 1)
  15144. * @param factor defines the angular speed to affect to the specified gradient
  15145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15146. * @returns the current particle system
  15147. */
  15148. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15149. /**
  15150. * Remove a specific angular speed gradient
  15151. * @param gradient defines the gradient to remove
  15152. * @returns the current particle system
  15153. */
  15154. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15155. /**
  15156. * Adds a new velocity gradient
  15157. * @param gradient defines the gradient to use (between 0 and 1)
  15158. * @param factor defines the velocity to affect to the specified gradient
  15159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15160. * @returns the current particle system
  15161. */
  15162. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15163. /**
  15164. * Remove a specific velocity gradient
  15165. * @param gradient defines the gradient to remove
  15166. * @returns the current particle system
  15167. */
  15168. removeVelocityGradient(gradient: number): IParticleSystem;
  15169. /**
  15170. * Adds a new limit velocity gradient
  15171. * @param gradient defines the gradient to use (between 0 and 1)
  15172. * @param factor defines the limit velocity value to affect to the specified gradient
  15173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15174. * @returns the current particle system
  15175. */
  15176. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15177. /**
  15178. * Remove a specific limit velocity gradient
  15179. * @param gradient defines the gradient to remove
  15180. * @returns the current particle system
  15181. */
  15182. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15183. /**
  15184. * Adds a new drag gradient
  15185. * @param gradient defines the gradient to use (between 0 and 1)
  15186. * @param factor defines the drag value to affect to the specified gradient
  15187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15188. * @returns the current particle system
  15189. */
  15190. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15191. /**
  15192. * Remove a specific drag gradient
  15193. * @param gradient defines the gradient to remove
  15194. * @returns the current particle system
  15195. */
  15196. removeDragGradient(gradient: number): IParticleSystem;
  15197. /**
  15198. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15199. * @param gradient defines the gradient to use (between 0 and 1)
  15200. * @param factor defines the emit rate value to affect to the specified gradient
  15201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15202. * @returns the current particle system
  15203. */
  15204. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15205. /**
  15206. * Remove a specific emit rate gradient
  15207. * @param gradient defines the gradient to remove
  15208. * @returns the current particle system
  15209. */
  15210. removeEmitRateGradient(gradient: number): IParticleSystem;
  15211. /**
  15212. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15213. * @param gradient defines the gradient to use (between 0 and 1)
  15214. * @param factor defines the start size value to affect to the specified gradient
  15215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15216. * @returns the current particle system
  15217. */
  15218. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15219. /**
  15220. * Remove a specific start size gradient
  15221. * @param gradient defines the gradient to remove
  15222. * @returns the current particle system
  15223. */
  15224. removeStartSizeGradient(gradient: number): IParticleSystem;
  15225. private _createRampGradientTexture;
  15226. /**
  15227. * Gets the current list of ramp gradients.
  15228. * You must use addRampGradient and removeRampGradient to udpate this list
  15229. * @returns the list of ramp gradients
  15230. */
  15231. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15232. /**
  15233. * Adds a new ramp gradient used to remap particle colors
  15234. * @param gradient defines the gradient to use (between 0 and 1)
  15235. * @param color defines the color to affect to the specified gradient
  15236. * @returns the current particle system
  15237. */
  15238. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15239. /**
  15240. * Remove a specific ramp gradient
  15241. * @param gradient defines the gradient to remove
  15242. * @returns the current particle system
  15243. */
  15244. removeRampGradient(gradient: number): ParticleSystem;
  15245. /**
  15246. * Adds a new color gradient
  15247. * @param gradient defines the gradient to use (between 0 and 1)
  15248. * @param color1 defines the color to affect to the specified gradient
  15249. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15250. * @returns this particle system
  15251. */
  15252. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15253. /**
  15254. * Remove a specific color gradient
  15255. * @param gradient defines the gradient to remove
  15256. * @returns this particle system
  15257. */
  15258. removeColorGradient(gradient: number): IParticleSystem;
  15259. private _fetchR;
  15260. protected _reset(): void;
  15261. private _resetEffect;
  15262. private _createVertexBuffers;
  15263. private _createIndexBuffer;
  15264. /**
  15265. * Gets the maximum number of particles active at the same time.
  15266. * @returns The max number of active particles.
  15267. */
  15268. getCapacity(): number;
  15269. /**
  15270. * Gets whether there are still active particles in the system.
  15271. * @returns True if it is alive, otherwise false.
  15272. */
  15273. isAlive(): boolean;
  15274. /**
  15275. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15276. * @returns True if it has been started, otherwise false.
  15277. */
  15278. isStarted(): boolean;
  15279. private _prepareSubEmitterInternalArray;
  15280. /**
  15281. * Starts the particle system and begins to emit
  15282. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15283. */
  15284. start(delay?: number): void;
  15285. /**
  15286. * Stops the particle system.
  15287. * @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.
  15288. */
  15289. stop(stopSubEmitters?: boolean): void;
  15290. /**
  15291. * Remove all active particles
  15292. */
  15293. reset(): void;
  15294. /**
  15295. * @hidden (for internal use only)
  15296. */
  15297. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15298. /**
  15299. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15300. * Its lifetime will start back at 0.
  15301. */
  15302. recycleParticle: (particle: Particle) => void;
  15303. private _stopSubEmitters;
  15304. private _createParticle;
  15305. private _removeFromRoot;
  15306. private _emitFromParticle;
  15307. private _update;
  15308. /** @hidden */
  15309. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15310. /** @hidden */
  15311. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15312. /** @hidden */
  15313. private _getEffect;
  15314. /**
  15315. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15316. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15317. */
  15318. animate(preWarmOnly?: boolean): void;
  15319. private _appendParticleVertices;
  15320. /**
  15321. * Rebuilds the particle system.
  15322. */
  15323. rebuild(): void;
  15324. /**
  15325. * Is this system ready to be used/rendered
  15326. * @return true if the system is ready
  15327. */
  15328. isReady(): boolean;
  15329. private _render;
  15330. /**
  15331. * Renders the particle system in its current state.
  15332. * @returns the current number of particles
  15333. */
  15334. render(): number;
  15335. /**
  15336. * Disposes the particle system and free the associated resources
  15337. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15338. */
  15339. dispose(disposeTexture?: boolean): void;
  15340. /**
  15341. * Clones the particle system.
  15342. * @param name The name of the cloned object
  15343. * @param newEmitter The new emitter to use
  15344. * @returns the cloned particle system
  15345. */
  15346. clone(name: string, newEmitter: any): ParticleSystem;
  15347. /**
  15348. * Serializes the particle system to a JSON object.
  15349. * @returns the JSON object
  15350. */
  15351. serialize(): any;
  15352. /** @hidden */
  15353. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15354. /** @hidden */
  15355. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15356. /**
  15357. * Parses a JSON object to create a particle system.
  15358. * @param parsedParticleSystem The JSON object to parse
  15359. * @param scene The scene to create the particle system in
  15360. * @param rootUrl The root url to use to load external dependencies like texture
  15361. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15362. * @returns the Parsed particle system
  15363. */
  15364. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15365. }
  15366. }
  15367. declare module BABYLON {
  15368. /**
  15369. * A particle represents one of the element emitted by a particle system.
  15370. * This is mainly define by its coordinates, direction, velocity and age.
  15371. */
  15372. export class Particle {
  15373. /**
  15374. * The particle system the particle belongs to.
  15375. */
  15376. particleSystem: ParticleSystem;
  15377. private static _Count;
  15378. /**
  15379. * Unique ID of the particle
  15380. */
  15381. id: number;
  15382. /**
  15383. * The world position of the particle in the scene.
  15384. */
  15385. position: Vector3;
  15386. /**
  15387. * The world direction of the particle in the scene.
  15388. */
  15389. direction: Vector3;
  15390. /**
  15391. * The color of the particle.
  15392. */
  15393. color: Color4;
  15394. /**
  15395. * The color change of the particle per step.
  15396. */
  15397. colorStep: Color4;
  15398. /**
  15399. * Defines how long will the life of the particle be.
  15400. */
  15401. lifeTime: number;
  15402. /**
  15403. * The current age of the particle.
  15404. */
  15405. age: number;
  15406. /**
  15407. * The current size of the particle.
  15408. */
  15409. size: number;
  15410. /**
  15411. * The current scale of the particle.
  15412. */
  15413. scale: Vector2;
  15414. /**
  15415. * The current angle of the particle.
  15416. */
  15417. angle: number;
  15418. /**
  15419. * Defines how fast is the angle changing.
  15420. */
  15421. angularSpeed: number;
  15422. /**
  15423. * Defines the cell index used by the particle to be rendered from a sprite.
  15424. */
  15425. cellIndex: number;
  15426. /**
  15427. * The information required to support color remapping
  15428. */
  15429. remapData: Vector4;
  15430. /** @hidden */
  15431. _randomCellOffset?: number;
  15432. /** @hidden */
  15433. _initialDirection: Nullable<Vector3>;
  15434. /** @hidden */
  15435. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15436. /** @hidden */
  15437. _initialStartSpriteCellID: number;
  15438. /** @hidden */
  15439. _initialEndSpriteCellID: number;
  15440. /** @hidden */
  15441. _currentColorGradient: Nullable<ColorGradient>;
  15442. /** @hidden */
  15443. _currentColor1: Color4;
  15444. /** @hidden */
  15445. _currentColor2: Color4;
  15446. /** @hidden */
  15447. _currentSizeGradient: Nullable<FactorGradient>;
  15448. /** @hidden */
  15449. _currentSize1: number;
  15450. /** @hidden */
  15451. _currentSize2: number;
  15452. /** @hidden */
  15453. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15454. /** @hidden */
  15455. _currentAngularSpeed1: number;
  15456. /** @hidden */
  15457. _currentAngularSpeed2: number;
  15458. /** @hidden */
  15459. _currentVelocityGradient: Nullable<FactorGradient>;
  15460. /** @hidden */
  15461. _currentVelocity1: number;
  15462. /** @hidden */
  15463. _currentVelocity2: number;
  15464. /** @hidden */
  15465. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15466. /** @hidden */
  15467. _currentLimitVelocity1: number;
  15468. /** @hidden */
  15469. _currentLimitVelocity2: number;
  15470. /** @hidden */
  15471. _currentDragGradient: Nullable<FactorGradient>;
  15472. /** @hidden */
  15473. _currentDrag1: number;
  15474. /** @hidden */
  15475. _currentDrag2: number;
  15476. /** @hidden */
  15477. _randomNoiseCoordinates1: Vector3;
  15478. /** @hidden */
  15479. _randomNoiseCoordinates2: Vector3;
  15480. /**
  15481. * Creates a new instance Particle
  15482. * @param particleSystem the particle system the particle belongs to
  15483. */
  15484. constructor(
  15485. /**
  15486. * The particle system the particle belongs to.
  15487. */
  15488. particleSystem: ParticleSystem);
  15489. private updateCellInfoFromSystem;
  15490. /**
  15491. * Defines how the sprite cell index is updated for the particle
  15492. */
  15493. updateCellIndex(): void;
  15494. /** @hidden */
  15495. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15496. /** @hidden */
  15497. _inheritParticleInfoToSubEmitters(): void;
  15498. /** @hidden */
  15499. _reset(): void;
  15500. /**
  15501. * Copy the properties of particle to another one.
  15502. * @param other the particle to copy the information to.
  15503. */
  15504. copyTo(other: Particle): void;
  15505. }
  15506. }
  15507. declare module BABYLON {
  15508. /**
  15509. * Particle emitter represents a volume emitting particles.
  15510. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15511. */
  15512. export interface IParticleEmitterType {
  15513. /**
  15514. * Called by the particle System when the direction is computed for the created particle.
  15515. * @param worldMatrix is the world matrix of the particle system
  15516. * @param directionToUpdate is the direction vector to update with the result
  15517. * @param particle is the particle we are computed the direction for
  15518. */
  15519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15520. /**
  15521. * Called by the particle System when the position is computed for the created particle.
  15522. * @param worldMatrix is the world matrix of the particle system
  15523. * @param positionToUpdate is the position vector to update with the result
  15524. * @param particle is the particle we are computed the position for
  15525. */
  15526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15527. /**
  15528. * Clones the current emitter and returns a copy of it
  15529. * @returns the new emitter
  15530. */
  15531. clone(): IParticleEmitterType;
  15532. /**
  15533. * Called by the GPUParticleSystem to setup the update shader
  15534. * @param effect defines the update shader
  15535. */
  15536. applyToShader(effect: Effect): void;
  15537. /**
  15538. * Returns a string to use to update the GPU particles update shader
  15539. * @returns the effect defines string
  15540. */
  15541. getEffectDefines(): string;
  15542. /**
  15543. * Returns a string representing the class name
  15544. * @returns a string containing the class name
  15545. */
  15546. getClassName(): string;
  15547. /**
  15548. * Serializes the particle system to a JSON object.
  15549. * @returns the JSON object
  15550. */
  15551. serialize(): any;
  15552. /**
  15553. * Parse properties from a JSON object
  15554. * @param serializationObject defines the JSON object
  15555. */
  15556. parse(serializationObject: any): void;
  15557. }
  15558. }
  15559. declare module BABYLON {
  15560. /**
  15561. * Particle emitter emitting particles from the inside of a box.
  15562. * It emits the particles randomly between 2 given directions.
  15563. */
  15564. export class BoxParticleEmitter implements IParticleEmitterType {
  15565. /**
  15566. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15567. */
  15568. direction1: Vector3;
  15569. /**
  15570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15571. */
  15572. direction2: Vector3;
  15573. /**
  15574. * 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.
  15575. */
  15576. minEmitBox: Vector3;
  15577. /**
  15578. * 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.
  15579. */
  15580. maxEmitBox: Vector3;
  15581. /**
  15582. * Creates a new instance BoxParticleEmitter
  15583. */
  15584. constructor();
  15585. /**
  15586. * Called by the particle System when the direction is computed for the created particle.
  15587. * @param worldMatrix is the world matrix of the particle system
  15588. * @param directionToUpdate is the direction vector to update with the result
  15589. * @param particle is the particle we are computed the direction for
  15590. */
  15591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15592. /**
  15593. * Called by the particle System when the position is computed for the created particle.
  15594. * @param worldMatrix is the world matrix of the particle system
  15595. * @param positionToUpdate is the position vector to update with the result
  15596. * @param particle is the particle we are computed the position for
  15597. */
  15598. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15599. /**
  15600. * Clones the current emitter and returns a copy of it
  15601. * @returns the new emitter
  15602. */
  15603. clone(): BoxParticleEmitter;
  15604. /**
  15605. * Called by the GPUParticleSystem to setup the update shader
  15606. * @param effect defines the update shader
  15607. */
  15608. applyToShader(effect: Effect): void;
  15609. /**
  15610. * Returns a string to use to update the GPU particles update shader
  15611. * @returns a string containng the defines string
  15612. */
  15613. getEffectDefines(): string;
  15614. /**
  15615. * Returns the string "BoxParticleEmitter"
  15616. * @returns a string containing the class name
  15617. */
  15618. getClassName(): string;
  15619. /**
  15620. * Serializes the particle system to a JSON object.
  15621. * @returns the JSON object
  15622. */
  15623. serialize(): any;
  15624. /**
  15625. * Parse properties from a JSON object
  15626. * @param serializationObject defines the JSON object
  15627. */
  15628. parse(serializationObject: any): void;
  15629. }
  15630. }
  15631. declare module BABYLON {
  15632. /**
  15633. * Particle emitter emitting particles from the inside of a cone.
  15634. * It emits the particles alongside the cone volume from the base to the particle.
  15635. * The emission direction might be randomized.
  15636. */
  15637. export class ConeParticleEmitter implements IParticleEmitterType {
  15638. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15639. directionRandomizer: number;
  15640. private _radius;
  15641. private _angle;
  15642. private _height;
  15643. /**
  15644. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15645. */
  15646. radiusRange: number;
  15647. /**
  15648. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15649. */
  15650. heightRange: number;
  15651. /**
  15652. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15653. */
  15654. emitFromSpawnPointOnly: boolean;
  15655. /**
  15656. * Gets or sets the radius of the emission cone
  15657. */
  15658. radius: number;
  15659. /**
  15660. * Gets or sets the angle of the emission cone
  15661. */
  15662. angle: number;
  15663. private _buildHeight;
  15664. /**
  15665. * Creates a new instance ConeParticleEmitter
  15666. * @param radius the radius of the emission cone (1 by default)
  15667. * @param angle the cone base angle (PI by default)
  15668. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15669. */
  15670. constructor(radius?: number, angle?: number,
  15671. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15672. directionRandomizer?: number);
  15673. /**
  15674. * Called by the particle System when the direction is computed for the created particle.
  15675. * @param worldMatrix is the world matrix of the particle system
  15676. * @param directionToUpdate is the direction vector to update with the result
  15677. * @param particle is the particle we are computed the direction for
  15678. */
  15679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15680. /**
  15681. * Called by the particle System when the position is computed for the created particle.
  15682. * @param worldMatrix is the world matrix of the particle system
  15683. * @param positionToUpdate is the position vector to update with the result
  15684. * @param particle is the particle we are computed the position for
  15685. */
  15686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15687. /**
  15688. * Clones the current emitter and returns a copy of it
  15689. * @returns the new emitter
  15690. */
  15691. clone(): ConeParticleEmitter;
  15692. /**
  15693. * Called by the GPUParticleSystem to setup the update shader
  15694. * @param effect defines the update shader
  15695. */
  15696. applyToShader(effect: Effect): void;
  15697. /**
  15698. * Returns a string to use to update the GPU particles update shader
  15699. * @returns a string containng the defines string
  15700. */
  15701. getEffectDefines(): string;
  15702. /**
  15703. * Returns the string "ConeParticleEmitter"
  15704. * @returns a string containing the class name
  15705. */
  15706. getClassName(): string;
  15707. /**
  15708. * Serializes the particle system to a JSON object.
  15709. * @returns the JSON object
  15710. */
  15711. serialize(): any;
  15712. /**
  15713. * Parse properties from a JSON object
  15714. * @param serializationObject defines the JSON object
  15715. */
  15716. parse(serializationObject: any): void;
  15717. }
  15718. }
  15719. declare module BABYLON {
  15720. /**
  15721. * Particle emitter emitting particles from the inside of a cylinder.
  15722. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15723. */
  15724. export class CylinderParticleEmitter implements IParticleEmitterType {
  15725. /**
  15726. * The radius of the emission cylinder.
  15727. */
  15728. radius: number;
  15729. /**
  15730. * The height of the emission cylinder.
  15731. */
  15732. height: number;
  15733. /**
  15734. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15735. */
  15736. radiusRange: number;
  15737. /**
  15738. * How much to randomize the particle direction [0-1].
  15739. */
  15740. directionRandomizer: number;
  15741. /**
  15742. * Creates a new instance CylinderParticleEmitter
  15743. * @param radius the radius of the emission cylinder (1 by default)
  15744. * @param height the height of the emission cylinder (1 by default)
  15745. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15747. */
  15748. constructor(
  15749. /**
  15750. * The radius of the emission cylinder.
  15751. */
  15752. radius?: number,
  15753. /**
  15754. * The height of the emission cylinder.
  15755. */
  15756. height?: number,
  15757. /**
  15758. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15759. */
  15760. radiusRange?: number,
  15761. /**
  15762. * How much to randomize the particle direction [0-1].
  15763. */
  15764. directionRandomizer?: number);
  15765. /**
  15766. * Called by the particle System when the direction is computed for the created particle.
  15767. * @param worldMatrix is the world matrix of the particle system
  15768. * @param directionToUpdate is the direction vector to update with the result
  15769. * @param particle is the particle we are computed the direction for
  15770. */
  15771. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15772. /**
  15773. * Called by the particle System when the position is computed for the created particle.
  15774. * @param worldMatrix is the world matrix of the particle system
  15775. * @param positionToUpdate is the position vector to update with the result
  15776. * @param particle is the particle we are computed the position for
  15777. */
  15778. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15779. /**
  15780. * Clones the current emitter and returns a copy of it
  15781. * @returns the new emitter
  15782. */
  15783. clone(): CylinderParticleEmitter;
  15784. /**
  15785. * Called by the GPUParticleSystem to setup the update shader
  15786. * @param effect defines the update shader
  15787. */
  15788. applyToShader(effect: Effect): void;
  15789. /**
  15790. * Returns a string to use to update the GPU particles update shader
  15791. * @returns a string containng the defines string
  15792. */
  15793. getEffectDefines(): string;
  15794. /**
  15795. * Returns the string "CylinderParticleEmitter"
  15796. * @returns a string containing the class name
  15797. */
  15798. getClassName(): string;
  15799. /**
  15800. * Serializes the particle system to a JSON object.
  15801. * @returns the JSON object
  15802. */
  15803. serialize(): any;
  15804. /**
  15805. * Parse properties from a JSON object
  15806. * @param serializationObject defines the JSON object
  15807. */
  15808. parse(serializationObject: any): void;
  15809. }
  15810. /**
  15811. * Particle emitter emitting particles from the inside of a cylinder.
  15812. * It emits the particles randomly between two vectors.
  15813. */
  15814. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15815. /**
  15816. * The min limit of the emission direction.
  15817. */
  15818. direction1: Vector3;
  15819. /**
  15820. * The max limit of the emission direction.
  15821. */
  15822. direction2: Vector3;
  15823. /**
  15824. * Creates a new instance CylinderDirectedParticleEmitter
  15825. * @param radius the radius of the emission cylinder (1 by default)
  15826. * @param height the height of the emission cylinder (1 by default)
  15827. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15828. * @param direction1 the min limit of the emission direction (up vector by default)
  15829. * @param direction2 the max limit of the emission direction (up vector by default)
  15830. */
  15831. constructor(radius?: number, height?: number, radiusRange?: number,
  15832. /**
  15833. * The min limit of the emission direction.
  15834. */
  15835. direction1?: Vector3,
  15836. /**
  15837. * The max limit of the emission direction.
  15838. */
  15839. direction2?: Vector3);
  15840. /**
  15841. * Called by the particle System when the direction is computed for the created particle.
  15842. * @param worldMatrix is the world matrix of the particle system
  15843. * @param directionToUpdate is the direction vector to update with the result
  15844. * @param particle is the particle we are computed the direction for
  15845. */
  15846. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15847. /**
  15848. * Clones the current emitter and returns a copy of it
  15849. * @returns the new emitter
  15850. */
  15851. clone(): CylinderDirectedParticleEmitter;
  15852. /**
  15853. * Called by the GPUParticleSystem to setup the update shader
  15854. * @param effect defines the update shader
  15855. */
  15856. applyToShader(effect: Effect): void;
  15857. /**
  15858. * Returns a string to use to update the GPU particles update shader
  15859. * @returns a string containng the defines string
  15860. */
  15861. getEffectDefines(): string;
  15862. /**
  15863. * Returns the string "CylinderDirectedParticleEmitter"
  15864. * @returns a string containing the class name
  15865. */
  15866. getClassName(): string;
  15867. /**
  15868. * Serializes the particle system to a JSON object.
  15869. * @returns the JSON object
  15870. */
  15871. serialize(): any;
  15872. /**
  15873. * Parse properties from a JSON object
  15874. * @param serializationObject defines the JSON object
  15875. */
  15876. parse(serializationObject: any): void;
  15877. }
  15878. }
  15879. declare module BABYLON {
  15880. /**
  15881. * Particle emitter emitting particles from the inside of a hemisphere.
  15882. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15883. */
  15884. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15885. /**
  15886. * The radius of the emission hemisphere.
  15887. */
  15888. radius: number;
  15889. /**
  15890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15891. */
  15892. radiusRange: number;
  15893. /**
  15894. * How much to randomize the particle direction [0-1].
  15895. */
  15896. directionRandomizer: number;
  15897. /**
  15898. * Creates a new instance HemisphericParticleEmitter
  15899. * @param radius the radius of the emission hemisphere (1 by default)
  15900. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15901. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15902. */
  15903. constructor(
  15904. /**
  15905. * The radius of the emission hemisphere.
  15906. */
  15907. radius?: number,
  15908. /**
  15909. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15910. */
  15911. radiusRange?: number,
  15912. /**
  15913. * How much to randomize the particle direction [0-1].
  15914. */
  15915. directionRandomizer?: number);
  15916. /**
  15917. * Called by the particle System when the direction is computed for the created particle.
  15918. * @param worldMatrix is the world matrix of the particle system
  15919. * @param directionToUpdate is the direction vector to update with the result
  15920. * @param particle is the particle we are computed the direction for
  15921. */
  15922. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15923. /**
  15924. * Called by the particle System when the position is computed for the created particle.
  15925. * @param worldMatrix is the world matrix of the particle system
  15926. * @param positionToUpdate is the position vector to update with the result
  15927. * @param particle is the particle we are computed the position for
  15928. */
  15929. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15930. /**
  15931. * Clones the current emitter and returns a copy of it
  15932. * @returns the new emitter
  15933. */
  15934. clone(): HemisphericParticleEmitter;
  15935. /**
  15936. * Called by the GPUParticleSystem to setup the update shader
  15937. * @param effect defines the update shader
  15938. */
  15939. applyToShader(effect: Effect): void;
  15940. /**
  15941. * Returns a string to use to update the GPU particles update shader
  15942. * @returns a string containng the defines string
  15943. */
  15944. getEffectDefines(): string;
  15945. /**
  15946. * Returns the string "HemisphericParticleEmitter"
  15947. * @returns a string containing the class name
  15948. */
  15949. getClassName(): string;
  15950. /**
  15951. * Serializes the particle system to a JSON object.
  15952. * @returns the JSON object
  15953. */
  15954. serialize(): any;
  15955. /**
  15956. * Parse properties from a JSON object
  15957. * @param serializationObject defines the JSON object
  15958. */
  15959. parse(serializationObject: any): void;
  15960. }
  15961. }
  15962. declare module BABYLON {
  15963. /**
  15964. * Particle emitter emitting particles from a point.
  15965. * It emits the particles randomly between 2 given directions.
  15966. */
  15967. export class PointParticleEmitter implements IParticleEmitterType {
  15968. /**
  15969. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15970. */
  15971. direction1: Vector3;
  15972. /**
  15973. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15974. */
  15975. direction2: Vector3;
  15976. /**
  15977. * Creates a new instance PointParticleEmitter
  15978. */
  15979. constructor();
  15980. /**
  15981. * Called by the particle System when the direction is computed for the created particle.
  15982. * @param worldMatrix is the world matrix of the particle system
  15983. * @param directionToUpdate is the direction vector to update with the result
  15984. * @param particle is the particle we are computed the direction for
  15985. */
  15986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15987. /**
  15988. * Called by the particle System when the position is computed for the created particle.
  15989. * @param worldMatrix is the world matrix of the particle system
  15990. * @param positionToUpdate is the position vector to update with the result
  15991. * @param particle is the particle we are computed the position for
  15992. */
  15993. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15994. /**
  15995. * Clones the current emitter and returns a copy of it
  15996. * @returns the new emitter
  15997. */
  15998. clone(): PointParticleEmitter;
  15999. /**
  16000. * Called by the GPUParticleSystem to setup the update shader
  16001. * @param effect defines the update shader
  16002. */
  16003. applyToShader(effect: Effect): void;
  16004. /**
  16005. * Returns a string to use to update the GPU particles update shader
  16006. * @returns a string containng the defines string
  16007. */
  16008. getEffectDefines(): string;
  16009. /**
  16010. * Returns the string "PointParticleEmitter"
  16011. * @returns a string containing the class name
  16012. */
  16013. getClassName(): string;
  16014. /**
  16015. * Serializes the particle system to a JSON object.
  16016. * @returns the JSON object
  16017. */
  16018. serialize(): any;
  16019. /**
  16020. * Parse properties from a JSON object
  16021. * @param serializationObject defines the JSON object
  16022. */
  16023. parse(serializationObject: any): void;
  16024. }
  16025. }
  16026. declare module BABYLON {
  16027. /**
  16028. * Particle emitter emitting particles from the inside of a sphere.
  16029. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16030. */
  16031. export class SphereParticleEmitter implements IParticleEmitterType {
  16032. /**
  16033. * The radius of the emission sphere.
  16034. */
  16035. radius: number;
  16036. /**
  16037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16038. */
  16039. radiusRange: number;
  16040. /**
  16041. * How much to randomize the particle direction [0-1].
  16042. */
  16043. directionRandomizer: number;
  16044. /**
  16045. * Creates a new instance SphereParticleEmitter
  16046. * @param radius the radius of the emission sphere (1 by default)
  16047. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16048. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16049. */
  16050. constructor(
  16051. /**
  16052. * The radius of the emission sphere.
  16053. */
  16054. radius?: number,
  16055. /**
  16056. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16057. */
  16058. radiusRange?: number,
  16059. /**
  16060. * How much to randomize the particle direction [0-1].
  16061. */
  16062. directionRandomizer?: number);
  16063. /**
  16064. * Called by the particle System when the direction is computed for the created particle.
  16065. * @param worldMatrix is the world matrix of the particle system
  16066. * @param directionToUpdate is the direction vector to update with the result
  16067. * @param particle is the particle we are computed the direction for
  16068. */
  16069. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16070. /**
  16071. * Called by the particle System when the position is computed for the created particle.
  16072. * @param worldMatrix is the world matrix of the particle system
  16073. * @param positionToUpdate is the position vector to update with the result
  16074. * @param particle is the particle we are computed the position for
  16075. */
  16076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16077. /**
  16078. * Clones the current emitter and returns a copy of it
  16079. * @returns the new emitter
  16080. */
  16081. clone(): SphereParticleEmitter;
  16082. /**
  16083. * Called by the GPUParticleSystem to setup the update shader
  16084. * @param effect defines the update shader
  16085. */
  16086. applyToShader(effect: Effect): void;
  16087. /**
  16088. * Returns a string to use to update the GPU particles update shader
  16089. * @returns a string containng the defines string
  16090. */
  16091. getEffectDefines(): string;
  16092. /**
  16093. * Returns the string "SphereParticleEmitter"
  16094. * @returns a string containing the class name
  16095. */
  16096. getClassName(): string;
  16097. /**
  16098. * Serializes the particle system to a JSON object.
  16099. * @returns the JSON object
  16100. */
  16101. serialize(): any;
  16102. /**
  16103. * Parse properties from a JSON object
  16104. * @param serializationObject defines the JSON object
  16105. */
  16106. parse(serializationObject: any): void;
  16107. }
  16108. /**
  16109. * Particle emitter emitting particles from the inside of a sphere.
  16110. * It emits the particles randomly between two vectors.
  16111. */
  16112. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16113. /**
  16114. * The min limit of the emission direction.
  16115. */
  16116. direction1: Vector3;
  16117. /**
  16118. * The max limit of the emission direction.
  16119. */
  16120. direction2: Vector3;
  16121. /**
  16122. * Creates a new instance SphereDirectedParticleEmitter
  16123. * @param radius the radius of the emission sphere (1 by default)
  16124. * @param direction1 the min limit of the emission direction (up vector by default)
  16125. * @param direction2 the max limit of the emission direction (up vector by default)
  16126. */
  16127. constructor(radius?: number,
  16128. /**
  16129. * The min limit of the emission direction.
  16130. */
  16131. direction1?: Vector3,
  16132. /**
  16133. * The max limit of the emission direction.
  16134. */
  16135. direction2?: Vector3);
  16136. /**
  16137. * Called by the particle System when the direction is computed for the created particle.
  16138. * @param worldMatrix is the world matrix of the particle system
  16139. * @param directionToUpdate is the direction vector to update with the result
  16140. * @param particle is the particle we are computed the direction for
  16141. */
  16142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16143. /**
  16144. * Clones the current emitter and returns a copy of it
  16145. * @returns the new emitter
  16146. */
  16147. clone(): SphereDirectedParticleEmitter;
  16148. /**
  16149. * Called by the GPUParticleSystem to setup the update shader
  16150. * @param effect defines the update shader
  16151. */
  16152. applyToShader(effect: Effect): void;
  16153. /**
  16154. * Returns a string to use to update the GPU particles update shader
  16155. * @returns a string containng the defines string
  16156. */
  16157. getEffectDefines(): string;
  16158. /**
  16159. * Returns the string "SphereDirectedParticleEmitter"
  16160. * @returns a string containing the class name
  16161. */
  16162. getClassName(): string;
  16163. /**
  16164. * Serializes the particle system to a JSON object.
  16165. * @returns the JSON object
  16166. */
  16167. serialize(): any;
  16168. /**
  16169. * Parse properties from a JSON object
  16170. * @param serializationObject defines the JSON object
  16171. */
  16172. parse(serializationObject: any): void;
  16173. }
  16174. }
  16175. declare module BABYLON {
  16176. /**
  16177. * Interface representing a particle system in Babylon.js.
  16178. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16179. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16180. */
  16181. export interface IParticleSystem {
  16182. /**
  16183. * List of animations used by the particle system.
  16184. */
  16185. animations: Animation[];
  16186. /**
  16187. * The id of the Particle system.
  16188. */
  16189. id: string;
  16190. /**
  16191. * The name of the Particle system.
  16192. */
  16193. name: string;
  16194. /**
  16195. * The emitter represents the Mesh or position we are attaching the particle system to.
  16196. */
  16197. emitter: Nullable<AbstractMesh | Vector3>;
  16198. /**
  16199. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16200. */
  16201. isBillboardBased: boolean;
  16202. /**
  16203. * The rendering group used by the Particle system to chose when to render.
  16204. */
  16205. renderingGroupId: number;
  16206. /**
  16207. * The layer mask we are rendering the particles through.
  16208. */
  16209. layerMask: number;
  16210. /**
  16211. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16212. */
  16213. updateSpeed: number;
  16214. /**
  16215. * The amount of time the particle system is running (depends of the overall update speed).
  16216. */
  16217. targetStopDuration: number;
  16218. /**
  16219. * The texture used to render each particle. (this can be a spritesheet)
  16220. */
  16221. particleTexture: Nullable<Texture>;
  16222. /**
  16223. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16224. */
  16225. blendMode: number;
  16226. /**
  16227. * Minimum life time of emitting particles.
  16228. */
  16229. minLifeTime: number;
  16230. /**
  16231. * Maximum life time of emitting particles.
  16232. */
  16233. maxLifeTime: number;
  16234. /**
  16235. * Minimum Size of emitting particles.
  16236. */
  16237. minSize: number;
  16238. /**
  16239. * Maximum Size of emitting particles.
  16240. */
  16241. maxSize: number;
  16242. /**
  16243. * Minimum scale of emitting particles on X axis.
  16244. */
  16245. minScaleX: number;
  16246. /**
  16247. * Maximum scale of emitting particles on X axis.
  16248. */
  16249. maxScaleX: number;
  16250. /**
  16251. * Minimum scale of emitting particles on Y axis.
  16252. */
  16253. minScaleY: number;
  16254. /**
  16255. * Maximum scale of emitting particles on Y axis.
  16256. */
  16257. maxScaleY: number;
  16258. /**
  16259. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16260. */
  16261. color1: Color4;
  16262. /**
  16263. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16264. */
  16265. color2: Color4;
  16266. /**
  16267. * Color the particle will have at the end of its lifetime.
  16268. */
  16269. colorDead: Color4;
  16270. /**
  16271. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16272. */
  16273. emitRate: number;
  16274. /**
  16275. * You can use gravity if you want to give an orientation to your particles.
  16276. */
  16277. gravity: Vector3;
  16278. /**
  16279. * Minimum power of emitting particles.
  16280. */
  16281. minEmitPower: number;
  16282. /**
  16283. * Maximum power of emitting particles.
  16284. */
  16285. maxEmitPower: number;
  16286. /**
  16287. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16288. */
  16289. minAngularSpeed: number;
  16290. /**
  16291. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16292. */
  16293. maxAngularSpeed: number;
  16294. /**
  16295. * Gets or sets the minimal initial rotation in radians.
  16296. */
  16297. minInitialRotation: number;
  16298. /**
  16299. * Gets or sets the maximal initial rotation in radians.
  16300. */
  16301. maxInitialRotation: number;
  16302. /**
  16303. * The particle emitter type defines the emitter used by the particle system.
  16304. * It can be for example box, sphere, or cone...
  16305. */
  16306. particleEmitterType: Nullable<IParticleEmitterType>;
  16307. /**
  16308. * Defines the delay in milliseconds before starting the system (0 by default)
  16309. */
  16310. startDelay: number;
  16311. /**
  16312. * 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
  16313. */
  16314. preWarmCycles: number;
  16315. /**
  16316. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16317. */
  16318. preWarmStepOffset: number;
  16319. /**
  16320. * 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)
  16321. */
  16322. spriteCellChangeSpeed: number;
  16323. /**
  16324. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16325. */
  16326. startSpriteCellID: number;
  16327. /**
  16328. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16329. */
  16330. endSpriteCellID: number;
  16331. /**
  16332. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16333. */
  16334. spriteCellWidth: number;
  16335. /**
  16336. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16337. */
  16338. spriteCellHeight: number;
  16339. /**
  16340. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16341. */
  16342. spriteRandomStartCell: boolean;
  16343. /**
  16344. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16345. */
  16346. isAnimationSheetEnabled: boolean;
  16347. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16348. translationPivot: Vector2;
  16349. /**
  16350. * Gets or sets a texture used to add random noise to particle positions
  16351. */
  16352. noiseTexture: Nullable<BaseTexture>;
  16353. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16354. noiseStrength: Vector3;
  16355. /**
  16356. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16357. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16358. */
  16359. billboardMode: number;
  16360. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16361. limitVelocityDamping: number;
  16362. /**
  16363. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16364. */
  16365. beginAnimationOnStart: boolean;
  16366. /**
  16367. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16368. */
  16369. beginAnimationFrom: number;
  16370. /**
  16371. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16372. */
  16373. beginAnimationTo: number;
  16374. /**
  16375. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16376. */
  16377. beginAnimationLoop: boolean;
  16378. /**
  16379. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16380. */
  16381. disposeOnStop: boolean;
  16382. /**
  16383. * Gets the maximum number of particles active at the same time.
  16384. * @returns The max number of active particles.
  16385. */
  16386. getCapacity(): number;
  16387. /**
  16388. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16389. * @returns True if it has been started, otherwise false.
  16390. */
  16391. isStarted(): boolean;
  16392. /**
  16393. * Animates the particle system for this frame.
  16394. */
  16395. animate(): void;
  16396. /**
  16397. * Renders the particle system in its current state.
  16398. * @returns the current number of particles
  16399. */
  16400. render(): number;
  16401. /**
  16402. * Dispose the particle system and frees its associated resources.
  16403. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16404. */
  16405. dispose(disposeTexture?: boolean): void;
  16406. /**
  16407. * Clones the particle system.
  16408. * @param name The name of the cloned object
  16409. * @param newEmitter The new emitter to use
  16410. * @returns the cloned particle system
  16411. */
  16412. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16413. /**
  16414. * Serializes the particle system to a JSON object.
  16415. * @returns the JSON object
  16416. */
  16417. serialize(): any;
  16418. /**
  16419. * Rebuild the particle system
  16420. */
  16421. rebuild(): void;
  16422. /**
  16423. * Starts the particle system and begins to emit
  16424. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16425. */
  16426. start(delay?: number): void;
  16427. /**
  16428. * Stops the particle system.
  16429. */
  16430. stop(): void;
  16431. /**
  16432. * Remove all active particles
  16433. */
  16434. reset(): void;
  16435. /**
  16436. * Is this system ready to be used/rendered
  16437. * @return true if the system is ready
  16438. */
  16439. isReady(): boolean;
  16440. /**
  16441. * Adds a new color gradient
  16442. * @param gradient defines the gradient to use (between 0 and 1)
  16443. * @param color1 defines the color to affect to the specified gradient
  16444. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16445. * @returns the current particle system
  16446. */
  16447. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16448. /**
  16449. * Remove a specific color gradient
  16450. * @param gradient defines the gradient to remove
  16451. * @returns the current particle system
  16452. */
  16453. removeColorGradient(gradient: number): IParticleSystem;
  16454. /**
  16455. * Adds a new size gradient
  16456. * @param gradient defines the gradient to use (between 0 and 1)
  16457. * @param factor defines the size factor to affect to the specified gradient
  16458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16459. * @returns the current particle system
  16460. */
  16461. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16462. /**
  16463. * Remove a specific size gradient
  16464. * @param gradient defines the gradient to remove
  16465. * @returns the current particle system
  16466. */
  16467. removeSizeGradient(gradient: number): IParticleSystem;
  16468. /**
  16469. * Gets the current list of color gradients.
  16470. * You must use addColorGradient and removeColorGradient to udpate this list
  16471. * @returns the list of color gradients
  16472. */
  16473. getColorGradients(): Nullable<Array<ColorGradient>>;
  16474. /**
  16475. * Gets the current list of size gradients.
  16476. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16477. * @returns the list of size gradients
  16478. */
  16479. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16480. /**
  16481. * Gets the current list of angular speed gradients.
  16482. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16483. * @returns the list of angular speed gradients
  16484. */
  16485. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16486. /**
  16487. * Adds a new angular speed gradient
  16488. * @param gradient defines the gradient to use (between 0 and 1)
  16489. * @param factor defines the angular speed to affect to the specified gradient
  16490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16491. * @returns the current particle system
  16492. */
  16493. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16494. /**
  16495. * Remove a specific angular speed gradient
  16496. * @param gradient defines the gradient to remove
  16497. * @returns the current particle system
  16498. */
  16499. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16500. /**
  16501. * Gets the current list of velocity gradients.
  16502. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16503. * @returns the list of velocity gradients
  16504. */
  16505. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16506. /**
  16507. * Adds a new velocity gradient
  16508. * @param gradient defines the gradient to use (between 0 and 1)
  16509. * @param factor defines the velocity to affect to the specified gradient
  16510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16511. * @returns the current particle system
  16512. */
  16513. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16514. /**
  16515. * Remove a specific velocity gradient
  16516. * @param gradient defines the gradient to remove
  16517. * @returns the current particle system
  16518. */
  16519. removeVelocityGradient(gradient: number): IParticleSystem;
  16520. /**
  16521. * Gets the current list of limit velocity gradients.
  16522. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16523. * @returns the list of limit velocity gradients
  16524. */
  16525. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16526. /**
  16527. * Adds a new limit velocity gradient
  16528. * @param gradient defines the gradient to use (between 0 and 1)
  16529. * @param factor defines the limit velocity to affect to the specified gradient
  16530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16531. * @returns the current particle system
  16532. */
  16533. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16534. /**
  16535. * Remove a specific limit velocity gradient
  16536. * @param gradient defines the gradient to remove
  16537. * @returns the current particle system
  16538. */
  16539. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16540. /**
  16541. * Adds a new drag gradient
  16542. * @param gradient defines the gradient to use (between 0 and 1)
  16543. * @param factor defines the drag to affect to the specified gradient
  16544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16545. * @returns the current particle system
  16546. */
  16547. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16548. /**
  16549. * Remove a specific drag gradient
  16550. * @param gradient defines the gradient to remove
  16551. * @returns the current particle system
  16552. */
  16553. removeDragGradient(gradient: number): IParticleSystem;
  16554. /**
  16555. * Gets the current list of drag gradients.
  16556. * You must use addDragGradient and removeDragGradient to udpate this list
  16557. * @returns the list of drag gradients
  16558. */
  16559. getDragGradients(): Nullable<Array<FactorGradient>>;
  16560. /**
  16561. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16562. * @param gradient defines the gradient to use (between 0 and 1)
  16563. * @param factor defines the emit rate to affect to the specified gradient
  16564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16565. * @returns the current particle system
  16566. */
  16567. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16568. /**
  16569. * Remove a specific emit rate gradient
  16570. * @param gradient defines the gradient to remove
  16571. * @returns the current particle system
  16572. */
  16573. removeEmitRateGradient(gradient: number): IParticleSystem;
  16574. /**
  16575. * Gets the current list of emit rate gradients.
  16576. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16577. * @returns the list of emit rate gradients
  16578. */
  16579. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16580. /**
  16581. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16582. * @param gradient defines the gradient to use (between 0 and 1)
  16583. * @param factor defines the start size to affect to the specified gradient
  16584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16585. * @returns the current particle system
  16586. */
  16587. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16588. /**
  16589. * Remove a specific start size gradient
  16590. * @param gradient defines the gradient to remove
  16591. * @returns the current particle system
  16592. */
  16593. removeStartSizeGradient(gradient: number): IParticleSystem;
  16594. /**
  16595. * Gets the current list of start size gradients.
  16596. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16597. * @returns the list of start size gradients
  16598. */
  16599. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16600. /**
  16601. * Adds a new life time gradient
  16602. * @param gradient defines the gradient to use (between 0 and 1)
  16603. * @param factor defines the life time factor to affect to the specified gradient
  16604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16605. * @returns the current particle system
  16606. */
  16607. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16608. /**
  16609. * Remove a specific life time gradient
  16610. * @param gradient defines the gradient to remove
  16611. * @returns the current particle system
  16612. */
  16613. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16614. /**
  16615. * Gets the current list of life time gradients.
  16616. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16617. * @returns the list of life time gradients
  16618. */
  16619. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16620. /**
  16621. * Gets the current list of color gradients.
  16622. * You must use addColorGradient and removeColorGradient to udpate this list
  16623. * @returns the list of color gradients
  16624. */
  16625. getColorGradients(): Nullable<Array<ColorGradient>>;
  16626. /**
  16627. * Adds a new ramp gradient used to remap particle colors
  16628. * @param gradient defines the gradient to use (between 0 and 1)
  16629. * @param color defines the color to affect to the specified gradient
  16630. * @returns the current particle system
  16631. */
  16632. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16633. /**
  16634. * Gets the current list of ramp gradients.
  16635. * You must use addRampGradient and removeRampGradient to udpate this list
  16636. * @returns the list of ramp gradients
  16637. */
  16638. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16639. /** Gets or sets a boolean indicating that ramp gradients must be used
  16640. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16641. */
  16642. useRampGradients: boolean;
  16643. /**
  16644. * Adds a new color remap gradient
  16645. * @param gradient defines the gradient to use (between 0 and 1)
  16646. * @param min defines the color remap minimal range
  16647. * @param max defines the color remap maximal range
  16648. * @returns the current particle system
  16649. */
  16650. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16651. /**
  16652. * Gets the current list of color remap gradients.
  16653. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16654. * @returns the list of color remap gradients
  16655. */
  16656. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16657. /**
  16658. * Adds a new alpha remap gradient
  16659. * @param gradient defines the gradient to use (between 0 and 1)
  16660. * @param min defines the alpha remap minimal range
  16661. * @param max defines the alpha remap maximal range
  16662. * @returns the current particle system
  16663. */
  16664. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16665. /**
  16666. * Gets the current list of alpha remap gradients.
  16667. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16668. * @returns the list of alpha remap gradients
  16669. */
  16670. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16671. /**
  16672. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16673. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16674. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16675. * @returns the emitter
  16676. */
  16677. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16678. /**
  16679. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16680. * @param radius The radius of the hemisphere to emit from
  16681. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16682. * @returns the emitter
  16683. */
  16684. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16685. /**
  16686. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16687. * @param radius The radius of the sphere to emit from
  16688. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16689. * @returns the emitter
  16690. */
  16691. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16692. /**
  16693. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16694. * @param radius The radius of the sphere to emit from
  16695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16697. * @returns the emitter
  16698. */
  16699. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16700. /**
  16701. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16702. * @param radius The radius of the emission cylinder
  16703. * @param height The height of the emission cylinder
  16704. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16705. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16706. * @returns the emitter
  16707. */
  16708. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16709. /**
  16710. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16711. * @param radius The radius of the cylinder to emit from
  16712. * @param height The height of the emission cylinder
  16713. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16714. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16715. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16716. * @returns the emitter
  16717. */
  16718. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16719. /**
  16720. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16721. * @param radius The radius of the cone to emit from
  16722. * @param angle The base angle of the cone
  16723. * @returns the emitter
  16724. */
  16725. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16726. /**
  16727. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16730. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16731. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16732. * @returns the emitter
  16733. */
  16734. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16735. /**
  16736. * Get hosting scene
  16737. * @returns the scene
  16738. */
  16739. getScene(): Scene;
  16740. }
  16741. }
  16742. declare module BABYLON {
  16743. /**
  16744. * Creates an instance based on a source mesh.
  16745. */
  16746. export class InstancedMesh extends AbstractMesh {
  16747. private _sourceMesh;
  16748. private _currentLOD;
  16749. /** @hidden */
  16750. _indexInSourceMeshInstanceArray: number;
  16751. constructor(name: string, source: Mesh);
  16752. /**
  16753. * Returns the string "InstancedMesh".
  16754. */
  16755. getClassName(): string;
  16756. /** Gets the list of lights affecting that mesh */
  16757. readonly lightSources: Light[];
  16758. _resyncLightSources(): void;
  16759. _resyncLighSource(light: Light): void;
  16760. _removeLightSource(light: Light): void;
  16761. /**
  16762. * If the source mesh receives shadows
  16763. */
  16764. readonly receiveShadows: boolean;
  16765. /**
  16766. * The material of the source mesh
  16767. */
  16768. readonly material: Nullable<Material>;
  16769. /**
  16770. * Visibility of the source mesh
  16771. */
  16772. readonly visibility: number;
  16773. /**
  16774. * Skeleton of the source mesh
  16775. */
  16776. readonly skeleton: Nullable<Skeleton>;
  16777. /**
  16778. * Rendering ground id of the source mesh
  16779. */
  16780. renderingGroupId: number;
  16781. /**
  16782. * Returns the total number of vertices (integer).
  16783. */
  16784. getTotalVertices(): number;
  16785. /**
  16786. * Returns a positive integer : the total number of indices in this mesh geometry.
  16787. * @returns the numner of indices or zero if the mesh has no geometry.
  16788. */
  16789. getTotalIndices(): number;
  16790. /**
  16791. * The source mesh of the instance
  16792. */
  16793. readonly sourceMesh: Mesh;
  16794. /**
  16795. * Is this node ready to be used/rendered
  16796. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16797. * @return {boolean} is it ready
  16798. */
  16799. isReady(completeCheck?: boolean): boolean;
  16800. /**
  16801. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16802. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16803. * @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.
  16804. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16805. */
  16806. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16807. /**
  16808. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16809. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16810. * The `data` are either a numeric array either a Float32Array.
  16811. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16812. * 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).
  16813. * Note that a new underlying VertexBuffer object is created each call.
  16814. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16815. *
  16816. * Possible `kind` values :
  16817. * - VertexBuffer.PositionKind
  16818. * - VertexBuffer.UVKind
  16819. * - VertexBuffer.UV2Kind
  16820. * - VertexBuffer.UV3Kind
  16821. * - VertexBuffer.UV4Kind
  16822. * - VertexBuffer.UV5Kind
  16823. * - VertexBuffer.UV6Kind
  16824. * - VertexBuffer.ColorKind
  16825. * - VertexBuffer.MatricesIndicesKind
  16826. * - VertexBuffer.MatricesIndicesExtraKind
  16827. * - VertexBuffer.MatricesWeightsKind
  16828. * - VertexBuffer.MatricesWeightsExtraKind
  16829. *
  16830. * Returns the Mesh.
  16831. */
  16832. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16833. /**
  16834. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16835. * If the mesh has no geometry, it is simply returned as it is.
  16836. * The `data` are either a numeric array either a Float32Array.
  16837. * No new underlying VertexBuffer object is created.
  16838. * 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.
  16839. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16840. *
  16841. * Possible `kind` values :
  16842. * - VertexBuffer.PositionKind
  16843. * - VertexBuffer.UVKind
  16844. * - VertexBuffer.UV2Kind
  16845. * - VertexBuffer.UV3Kind
  16846. * - VertexBuffer.UV4Kind
  16847. * - VertexBuffer.UV5Kind
  16848. * - VertexBuffer.UV6Kind
  16849. * - VertexBuffer.ColorKind
  16850. * - VertexBuffer.MatricesIndicesKind
  16851. * - VertexBuffer.MatricesIndicesExtraKind
  16852. * - VertexBuffer.MatricesWeightsKind
  16853. * - VertexBuffer.MatricesWeightsExtraKind
  16854. *
  16855. * Returns the Mesh.
  16856. */
  16857. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16858. /**
  16859. * Sets the mesh indices.
  16860. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16861. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16862. * This method creates a new index buffer each call.
  16863. * Returns the Mesh.
  16864. */
  16865. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16866. /**
  16867. * Boolean : True if the mesh owns the requested kind of data.
  16868. */
  16869. isVerticesDataPresent(kind: string): boolean;
  16870. /**
  16871. * Returns an array of indices (IndicesArray).
  16872. */
  16873. getIndices(): Nullable<IndicesArray>;
  16874. readonly _positions: Nullable<Vector3[]>;
  16875. /**
  16876. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16877. * This means the mesh underlying bounding box and sphere are recomputed.
  16878. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16879. * @returns the current mesh
  16880. */
  16881. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16882. /** @hidden */
  16883. _preActivate(): InstancedMesh;
  16884. /** @hidden */
  16885. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16886. /** @hidden */
  16887. _postActivate(): void;
  16888. getWorldMatrix(): Matrix;
  16889. readonly isAnInstance: boolean;
  16890. /**
  16891. * Returns the current associated LOD AbstractMesh.
  16892. */
  16893. getLOD(camera: Camera): AbstractMesh;
  16894. /** @hidden */
  16895. _syncSubMeshes(): InstancedMesh;
  16896. /** @hidden */
  16897. _generatePointsArray(): boolean;
  16898. /**
  16899. * Creates a new InstancedMesh from the current mesh.
  16900. * - name (string) : the cloned mesh name
  16901. * - newParent (optional Node) : the optional Node to parent the clone to.
  16902. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16903. *
  16904. * Returns the clone.
  16905. */
  16906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16907. /**
  16908. * Disposes the InstancedMesh.
  16909. * Returns nothing.
  16910. */
  16911. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16912. }
  16913. }
  16914. declare module BABYLON {
  16915. /**
  16916. * Defines the options associated with the creation of a shader material.
  16917. */
  16918. export interface IShaderMaterialOptions {
  16919. /**
  16920. * Does the material work in alpha blend mode
  16921. */
  16922. needAlphaBlending: boolean;
  16923. /**
  16924. * Does the material work in alpha test mode
  16925. */
  16926. needAlphaTesting: boolean;
  16927. /**
  16928. * The list of attribute names used in the shader
  16929. */
  16930. attributes: string[];
  16931. /**
  16932. * The list of unifrom names used in the shader
  16933. */
  16934. uniforms: string[];
  16935. /**
  16936. * The list of UBO names used in the shader
  16937. */
  16938. uniformBuffers: string[];
  16939. /**
  16940. * The list of sampler names used in the shader
  16941. */
  16942. samplers: string[];
  16943. /**
  16944. * The list of defines used in the shader
  16945. */
  16946. defines: string[];
  16947. }
  16948. /**
  16949. * 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.
  16950. *
  16951. * This returned material effects how the mesh will look based on the code in the shaders.
  16952. *
  16953. * @see http://doc.babylonjs.com/how_to/shader_material
  16954. */
  16955. export class ShaderMaterial extends Material {
  16956. private _shaderPath;
  16957. private _options;
  16958. private _textures;
  16959. private _textureArrays;
  16960. private _floats;
  16961. private _ints;
  16962. private _floatsArrays;
  16963. private _colors3;
  16964. private _colors3Arrays;
  16965. private _colors4;
  16966. private _vectors2;
  16967. private _vectors3;
  16968. private _vectors4;
  16969. private _matrices;
  16970. private _matrices3x3;
  16971. private _matrices2x2;
  16972. private _vectors2Arrays;
  16973. private _vectors3Arrays;
  16974. private _cachedWorldViewMatrix;
  16975. private _renderId;
  16976. /**
  16977. * Instantiate a new shader material.
  16978. * 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.
  16979. * This returned material effects how the mesh will look based on the code in the shaders.
  16980. * @see http://doc.babylonjs.com/how_to/shader_material
  16981. * @param name Define the name of the material in the scene
  16982. * @param scene Define the scene the material belongs to
  16983. * @param shaderPath Defines the route to the shader code in one of three ways:
  16984. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16985. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16986. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16987. * @param options Define the options used to create the shader
  16988. */
  16989. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16990. /**
  16991. * Gets the options used to compile the shader.
  16992. * They can be modified to trigger a new compilation
  16993. */
  16994. readonly options: IShaderMaterialOptions;
  16995. /**
  16996. * Gets the current class name of the material e.g. "ShaderMaterial"
  16997. * Mainly use in serialization.
  16998. * @returns the class name
  16999. */
  17000. getClassName(): string;
  17001. /**
  17002. * Specifies if the material will require alpha blending
  17003. * @returns a boolean specifying if alpha blending is needed
  17004. */
  17005. needAlphaBlending(): boolean;
  17006. /**
  17007. * Specifies if this material should be rendered in alpha test mode
  17008. * @returns a boolean specifying if an alpha test is needed.
  17009. */
  17010. needAlphaTesting(): boolean;
  17011. private _checkUniform;
  17012. /**
  17013. * Set a texture in the shader.
  17014. * @param name Define the name of the uniform samplers as defined in the shader
  17015. * @param texture Define the texture to bind to this sampler
  17016. * @return the material itself allowing "fluent" like uniform updates
  17017. */
  17018. setTexture(name: string, texture: Texture): ShaderMaterial;
  17019. /**
  17020. * Set a texture array in the shader.
  17021. * @param name Define the name of the uniform sampler array as defined in the shader
  17022. * @param textures Define the list of textures to bind to this sampler
  17023. * @return the material itself allowing "fluent" like uniform updates
  17024. */
  17025. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17026. /**
  17027. * Set a float in the shader.
  17028. * @param name Define the name of the uniform as defined in the shader
  17029. * @param value Define the value to give to the uniform
  17030. * @return the material itself allowing "fluent" like uniform updates
  17031. */
  17032. setFloat(name: string, value: number): ShaderMaterial;
  17033. /**
  17034. * Set a int in the shader.
  17035. * @param name Define the name of the uniform as defined in the shader
  17036. * @param value Define the value to give to the uniform
  17037. * @return the material itself allowing "fluent" like uniform updates
  17038. */
  17039. setInt(name: string, value: number): ShaderMaterial;
  17040. /**
  17041. * Set an array of floats in the shader.
  17042. * @param name Define the name of the uniform as defined in the shader
  17043. * @param value Define the value to give to the uniform
  17044. * @return the material itself allowing "fluent" like uniform updates
  17045. */
  17046. setFloats(name: string, value: number[]): ShaderMaterial;
  17047. /**
  17048. * Set a vec3 in the shader from a Color3.
  17049. * @param name Define the name of the uniform as defined in the shader
  17050. * @param value Define the value to give to the uniform
  17051. * @return the material itself allowing "fluent" like uniform updates
  17052. */
  17053. setColor3(name: string, value: Color3): ShaderMaterial;
  17054. /**
  17055. * Set a vec3 array in the shader from a Color3 array.
  17056. * @param name Define the name of the uniform as defined in the shader
  17057. * @param value Define the value to give to the uniform
  17058. * @return the material itself allowing "fluent" like uniform updates
  17059. */
  17060. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17061. /**
  17062. * Set a vec4 in the shader from a Color4.
  17063. * @param name Define the name of the uniform as defined in the shader
  17064. * @param value Define the value to give to the uniform
  17065. * @return the material itself allowing "fluent" like uniform updates
  17066. */
  17067. setColor4(name: string, value: Color4): ShaderMaterial;
  17068. /**
  17069. * Set a vec2 in the shader from a Vector2.
  17070. * @param name Define the name of the uniform as defined in the shader
  17071. * @param value Define the value to give to the uniform
  17072. * @return the material itself allowing "fluent" like uniform updates
  17073. */
  17074. setVector2(name: string, value: Vector2): ShaderMaterial;
  17075. /**
  17076. * Set a vec3 in the shader from a Vector3.
  17077. * @param name Define the name of the uniform as defined in the shader
  17078. * @param value Define the value to give to the uniform
  17079. * @return the material itself allowing "fluent" like uniform updates
  17080. */
  17081. setVector3(name: string, value: Vector3): ShaderMaterial;
  17082. /**
  17083. * Set a vec4 in the shader from a Vector4.
  17084. * @param name Define the name of the uniform as defined in the shader
  17085. * @param value Define the value to give to the uniform
  17086. * @return the material itself allowing "fluent" like uniform updates
  17087. */
  17088. setVector4(name: string, value: Vector4): ShaderMaterial;
  17089. /**
  17090. * Set a mat4 in the shader from a Matrix.
  17091. * @param name Define the name of the uniform as defined in the shader
  17092. * @param value Define the value to give to the uniform
  17093. * @return the material itself allowing "fluent" like uniform updates
  17094. */
  17095. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17096. /**
  17097. * Set a mat3 in the shader from a Float32Array.
  17098. * @param name Define the name of the uniform as defined in the shader
  17099. * @param value Define the value to give to the uniform
  17100. * @return the material itself allowing "fluent" like uniform updates
  17101. */
  17102. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17103. /**
  17104. * Set a mat2 in the shader from a Float32Array.
  17105. * @param name Define the name of the uniform as defined in the shader
  17106. * @param value Define the value to give to the uniform
  17107. * @return the material itself allowing "fluent" like uniform updates
  17108. */
  17109. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17110. /**
  17111. * Set a vec2 array in the shader from a number array.
  17112. * @param name Define the name of the uniform as defined in the shader
  17113. * @param value Define the value to give to the uniform
  17114. * @return the material itself allowing "fluent" like uniform updates
  17115. */
  17116. setArray2(name: string, value: number[]): ShaderMaterial;
  17117. /**
  17118. * Set a vec3 array in the shader from a number array.
  17119. * @param name Define the name of the uniform as defined in the shader
  17120. * @param value Define the value to give to the uniform
  17121. * @return the material itself allowing "fluent" like uniform updates
  17122. */
  17123. setArray3(name: string, value: number[]): ShaderMaterial;
  17124. private _checkCache;
  17125. /**
  17126. * Specifies that the submesh is ready to be used
  17127. * @param mesh defines the mesh to check
  17128. * @param subMesh defines which submesh to check
  17129. * @param useInstances specifies that instances should be used
  17130. * @returns a boolean indicating that the submesh is ready or not
  17131. */
  17132. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17133. /**
  17134. * Checks if the material is ready to render the requested mesh
  17135. * @param mesh Define the mesh to render
  17136. * @param useInstances Define whether or not the material is used with instances
  17137. * @returns true if ready, otherwise false
  17138. */
  17139. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17140. /**
  17141. * Binds the world matrix to the material
  17142. * @param world defines the world transformation matrix
  17143. */
  17144. bindOnlyWorldMatrix(world: Matrix): void;
  17145. /**
  17146. * Binds the material to the mesh
  17147. * @param world defines the world transformation matrix
  17148. * @param mesh defines the mesh to bind the material to
  17149. */
  17150. bind(world: Matrix, mesh?: Mesh): void;
  17151. /**
  17152. * Gets the active textures from the material
  17153. * @returns an array of textures
  17154. */
  17155. getActiveTextures(): BaseTexture[];
  17156. /**
  17157. * Specifies if the material uses a texture
  17158. * @param texture defines the texture to check against the material
  17159. * @returns a boolean specifying if the material uses the texture
  17160. */
  17161. hasTexture(texture: BaseTexture): boolean;
  17162. /**
  17163. * Makes a duplicate of the material, and gives it a new name
  17164. * @param name defines the new name for the duplicated material
  17165. * @returns the cloned material
  17166. */
  17167. clone(name: string): ShaderMaterial;
  17168. /**
  17169. * Disposes the material
  17170. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17171. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17172. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17173. */
  17174. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17175. /**
  17176. * Serializes this material in a JSON representation
  17177. * @returns the serialized material object
  17178. */
  17179. serialize(): any;
  17180. /**
  17181. * Creates a shader material from parsed shader material data
  17182. * @param source defines the JSON represnetation of the material
  17183. * @param scene defines the hosting scene
  17184. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17185. * @returns a new material
  17186. */
  17187. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17188. }
  17189. }
  17190. declare module BABYLON {
  17191. /** @hidden */
  17192. export var colorPixelShader: {
  17193. name: string;
  17194. shader: string;
  17195. };
  17196. }
  17197. declare module BABYLON {
  17198. /** @hidden */
  17199. export var colorVertexShader: {
  17200. name: string;
  17201. shader: string;
  17202. };
  17203. }
  17204. declare module BABYLON {
  17205. /**
  17206. * Line mesh
  17207. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17208. */
  17209. export class LinesMesh extends Mesh {
  17210. /**
  17211. * If vertex color should be applied to the mesh
  17212. */
  17213. useVertexColor?: boolean | undefined;
  17214. /**
  17215. * If vertex alpha should be applied to the mesh
  17216. */
  17217. useVertexAlpha?: boolean | undefined;
  17218. /**
  17219. * Color of the line (Default: White)
  17220. */
  17221. color: Color3;
  17222. /**
  17223. * Alpha of the line (Default: 1)
  17224. */
  17225. alpha: number;
  17226. /**
  17227. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17228. * This margin is expressed in world space coordinates, so its value may vary.
  17229. * Default value is 0.1
  17230. */
  17231. intersectionThreshold: number;
  17232. private _colorShader;
  17233. /**
  17234. * Creates a new LinesMesh
  17235. * @param name defines the name
  17236. * @param scene defines the hosting scene
  17237. * @param parent defines the parent mesh if any
  17238. * @param source defines the optional source LinesMesh used to clone data from
  17239. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17240. * When false, achieved by calling a clone(), also passing False.
  17241. * This will make creation of children, recursive.
  17242. * @param useVertexColor defines if this LinesMesh supports vertex color
  17243. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17244. */
  17245. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17246. /**
  17247. * If vertex color should be applied to the mesh
  17248. */
  17249. useVertexColor?: boolean | undefined,
  17250. /**
  17251. * If vertex alpha should be applied to the mesh
  17252. */
  17253. useVertexAlpha?: boolean | undefined);
  17254. private _addClipPlaneDefine;
  17255. private _removeClipPlaneDefine;
  17256. isReady(): boolean;
  17257. /**
  17258. * Returns the string "LineMesh"
  17259. */
  17260. getClassName(): string;
  17261. /**
  17262. * @hidden
  17263. */
  17264. /**
  17265. * @hidden
  17266. */
  17267. material: Material;
  17268. /**
  17269. * @hidden
  17270. */
  17271. readonly checkCollisions: boolean;
  17272. /** @hidden */
  17273. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17274. /** @hidden */
  17275. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17276. /**
  17277. * Disposes of the line mesh
  17278. * @param doNotRecurse If children should be disposed
  17279. */
  17280. dispose(doNotRecurse?: boolean): void;
  17281. /**
  17282. * Returns a new LineMesh object cloned from the current one.
  17283. */
  17284. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17285. /**
  17286. * Creates a new InstancedLinesMesh object from the mesh model.
  17287. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17288. * @param name defines the name of the new instance
  17289. * @returns a new InstancedLinesMesh
  17290. */
  17291. createInstance(name: string): InstancedLinesMesh;
  17292. }
  17293. /**
  17294. * Creates an instance based on a source LinesMesh
  17295. */
  17296. export class InstancedLinesMesh extends InstancedMesh {
  17297. /**
  17298. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17299. * This margin is expressed in world space coordinates, so its value may vary.
  17300. * Initilized with the intersectionThreshold value of the source LinesMesh
  17301. */
  17302. intersectionThreshold: number;
  17303. constructor(name: string, source: LinesMesh);
  17304. /**
  17305. * Returns the string "InstancedLinesMesh".
  17306. */
  17307. getClassName(): string;
  17308. }
  17309. }
  17310. declare module BABYLON {
  17311. /** @hidden */
  17312. export var linePixelShader: {
  17313. name: string;
  17314. shader: string;
  17315. };
  17316. }
  17317. declare module BABYLON {
  17318. /** @hidden */
  17319. export var lineVertexShader: {
  17320. name: string;
  17321. shader: string;
  17322. };
  17323. }
  17324. declare module BABYLON {
  17325. interface AbstractMesh {
  17326. /**
  17327. * Gets the edgesRenderer associated with the mesh
  17328. */
  17329. edgesRenderer: Nullable<EdgesRenderer>;
  17330. }
  17331. interface LinesMesh {
  17332. /**
  17333. * Enables the edge rendering mode on the mesh.
  17334. * This mode makes the mesh edges visible
  17335. * @param epsilon defines the maximal distance between two angles to detect a face
  17336. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17337. * @returns the currentAbstractMesh
  17338. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17339. */
  17340. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17341. }
  17342. interface InstancedLinesMesh {
  17343. /**
  17344. * Enables the edge rendering mode on the mesh.
  17345. * This mode makes the mesh edges visible
  17346. * @param epsilon defines the maximal distance between two angles to detect a face
  17347. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17348. * @returns the current InstancedLinesMesh
  17349. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17350. */
  17351. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17352. }
  17353. /**
  17354. * Defines the minimum contract an Edges renderer should follow.
  17355. */
  17356. export interface IEdgesRenderer extends IDisposable {
  17357. /**
  17358. * Gets or sets a boolean indicating if the edgesRenderer is active
  17359. */
  17360. isEnabled: boolean;
  17361. /**
  17362. * Renders the edges of the attached mesh,
  17363. */
  17364. render(): void;
  17365. /**
  17366. * Checks wether or not the edges renderer is ready to render.
  17367. * @return true if ready, otherwise false.
  17368. */
  17369. isReady(): boolean;
  17370. }
  17371. /**
  17372. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17373. */
  17374. export class EdgesRenderer implements IEdgesRenderer {
  17375. /**
  17376. * Define the size of the edges with an orthographic camera
  17377. */
  17378. edgesWidthScalerForOrthographic: number;
  17379. /**
  17380. * Define the size of the edges with a perspective camera
  17381. */
  17382. edgesWidthScalerForPerspective: number;
  17383. protected _source: AbstractMesh;
  17384. protected _linesPositions: number[];
  17385. protected _linesNormals: number[];
  17386. protected _linesIndices: number[];
  17387. protected _epsilon: number;
  17388. protected _indicesCount: number;
  17389. protected _lineShader: ShaderMaterial;
  17390. protected _ib: DataBuffer;
  17391. protected _buffers: {
  17392. [key: string]: Nullable<VertexBuffer>;
  17393. };
  17394. protected _checkVerticesInsteadOfIndices: boolean;
  17395. private _meshRebuildObserver;
  17396. private _meshDisposeObserver;
  17397. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17398. isEnabled: boolean;
  17399. /**
  17400. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17401. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17402. * @param source Mesh used to create edges
  17403. * @param epsilon sum of angles in adjacency to check for edge
  17404. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17405. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17406. */
  17407. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17408. protected _prepareRessources(): void;
  17409. /** @hidden */
  17410. _rebuild(): void;
  17411. /**
  17412. * Releases the required resources for the edges renderer
  17413. */
  17414. dispose(): void;
  17415. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17416. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17417. /**
  17418. * Checks if the pair of p0 and p1 is en edge
  17419. * @param faceIndex
  17420. * @param edge
  17421. * @param faceNormals
  17422. * @param p0
  17423. * @param p1
  17424. * @private
  17425. */
  17426. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17427. /**
  17428. * push line into the position, normal and index buffer
  17429. * @protected
  17430. */
  17431. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17432. /**
  17433. * Generates lines edges from adjacencjes
  17434. * @private
  17435. */
  17436. _generateEdgesLines(): void;
  17437. /**
  17438. * Checks wether or not the edges renderer is ready to render.
  17439. * @return true if ready, otherwise false.
  17440. */
  17441. isReady(): boolean;
  17442. /**
  17443. * Renders the edges of the attached mesh,
  17444. */
  17445. render(): void;
  17446. }
  17447. /**
  17448. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17449. */
  17450. export class LineEdgesRenderer extends EdgesRenderer {
  17451. /**
  17452. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17453. * @param source LineMesh used to generate edges
  17454. * @param epsilon not important (specified angle for edge detection)
  17455. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17456. */
  17457. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17458. /**
  17459. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17460. */
  17461. _generateEdgesLines(): void;
  17462. }
  17463. }
  17464. declare module BABYLON {
  17465. /**
  17466. * This represents the object necessary to create a rendering group.
  17467. * This is exclusively used and created by the rendering manager.
  17468. * To modify the behavior, you use the available helpers in your scene or meshes.
  17469. * @hidden
  17470. */
  17471. export class RenderingGroup {
  17472. index: number;
  17473. private _scene;
  17474. private _opaqueSubMeshes;
  17475. private _transparentSubMeshes;
  17476. private _alphaTestSubMeshes;
  17477. private _depthOnlySubMeshes;
  17478. private _particleSystems;
  17479. private _spriteManagers;
  17480. private _opaqueSortCompareFn;
  17481. private _alphaTestSortCompareFn;
  17482. private _transparentSortCompareFn;
  17483. private _renderOpaque;
  17484. private _renderAlphaTest;
  17485. private _renderTransparent;
  17486. /** @hidden */
  17487. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17488. onBeforeTransparentRendering: () => void;
  17489. /**
  17490. * Set the opaque sort comparison function.
  17491. * If null the sub meshes will be render in the order they were created
  17492. */
  17493. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17494. /**
  17495. * Set the alpha test sort comparison function.
  17496. * If null the sub meshes will be render in the order they were created
  17497. */
  17498. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17499. /**
  17500. * Set the transparent sort comparison function.
  17501. * If null the sub meshes will be render in the order they were created
  17502. */
  17503. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17504. /**
  17505. * Creates a new rendering group.
  17506. * @param index The rendering group index
  17507. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17508. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17509. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17510. */
  17511. 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>);
  17512. /**
  17513. * Render all the sub meshes contained in the group.
  17514. * @param customRenderFunction Used to override the default render behaviour of the group.
  17515. * @returns true if rendered some submeshes.
  17516. */
  17517. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17518. /**
  17519. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17520. * @param subMeshes The submeshes to render
  17521. */
  17522. private renderOpaqueSorted;
  17523. /**
  17524. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17525. * @param subMeshes The submeshes to render
  17526. */
  17527. private renderAlphaTestSorted;
  17528. /**
  17529. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17530. * @param subMeshes The submeshes to render
  17531. */
  17532. private renderTransparentSorted;
  17533. /**
  17534. * Renders the submeshes in a specified order.
  17535. * @param subMeshes The submeshes to sort before render
  17536. * @param sortCompareFn The comparison function use to sort
  17537. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17538. * @param transparent Specifies to activate blending if true
  17539. */
  17540. private static renderSorted;
  17541. /**
  17542. * Renders the submeshes in the order they were dispatched (no sort applied).
  17543. * @param subMeshes The submeshes to render
  17544. */
  17545. private static renderUnsorted;
  17546. /**
  17547. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17548. * are rendered back to front if in the same alpha index.
  17549. *
  17550. * @param a The first submesh
  17551. * @param b The second submesh
  17552. * @returns The result of the comparison
  17553. */
  17554. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17555. /**
  17556. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17557. * are rendered back to front.
  17558. *
  17559. * @param a The first submesh
  17560. * @param b The second submesh
  17561. * @returns The result of the comparison
  17562. */
  17563. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17564. /**
  17565. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17566. * are rendered front to back (prevent overdraw).
  17567. *
  17568. * @param a The first submesh
  17569. * @param b The second submesh
  17570. * @returns The result of the comparison
  17571. */
  17572. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17573. /**
  17574. * Resets the different lists of submeshes to prepare a new frame.
  17575. */
  17576. prepare(): void;
  17577. dispose(): void;
  17578. /**
  17579. * Inserts the submesh in its correct queue depending on its material.
  17580. * @param subMesh The submesh to dispatch
  17581. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17582. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17583. */
  17584. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17585. dispatchSprites(spriteManager: ISpriteManager): void;
  17586. dispatchParticles(particleSystem: IParticleSystem): void;
  17587. private _renderParticles;
  17588. private _renderSprites;
  17589. }
  17590. }
  17591. declare module BABYLON {
  17592. /**
  17593. * Interface describing the different options available in the rendering manager
  17594. * regarding Auto Clear between groups.
  17595. */
  17596. export interface IRenderingManagerAutoClearSetup {
  17597. /**
  17598. * Defines whether or not autoclear is enable.
  17599. */
  17600. autoClear: boolean;
  17601. /**
  17602. * Defines whether or not to autoclear the depth buffer.
  17603. */
  17604. depth: boolean;
  17605. /**
  17606. * Defines whether or not to autoclear the stencil buffer.
  17607. */
  17608. stencil: boolean;
  17609. }
  17610. /**
  17611. * This class is used by the onRenderingGroupObservable
  17612. */
  17613. export class RenderingGroupInfo {
  17614. /**
  17615. * The Scene that being rendered
  17616. */
  17617. scene: Scene;
  17618. /**
  17619. * The camera currently used for the rendering pass
  17620. */
  17621. camera: Nullable<Camera>;
  17622. /**
  17623. * The ID of the renderingGroup being processed
  17624. */
  17625. renderingGroupId: number;
  17626. }
  17627. /**
  17628. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17629. * It is enable to manage the different groups as well as the different necessary sort functions.
  17630. * This should not be used directly aside of the few static configurations
  17631. */
  17632. export class RenderingManager {
  17633. /**
  17634. * The max id used for rendering groups (not included)
  17635. */
  17636. static MAX_RENDERINGGROUPS: number;
  17637. /**
  17638. * The min id used for rendering groups (included)
  17639. */
  17640. static MIN_RENDERINGGROUPS: number;
  17641. /**
  17642. * Used to globally prevent autoclearing scenes.
  17643. */
  17644. static AUTOCLEAR: boolean;
  17645. /**
  17646. * @hidden
  17647. */
  17648. _useSceneAutoClearSetup: boolean;
  17649. private _scene;
  17650. private _renderingGroups;
  17651. private _depthStencilBufferAlreadyCleaned;
  17652. private _autoClearDepthStencil;
  17653. private _customOpaqueSortCompareFn;
  17654. private _customAlphaTestSortCompareFn;
  17655. private _customTransparentSortCompareFn;
  17656. private _renderingGroupInfo;
  17657. /**
  17658. * Instantiates a new rendering group for a particular scene
  17659. * @param scene Defines the scene the groups belongs to
  17660. */
  17661. constructor(scene: Scene);
  17662. private _clearDepthStencilBuffer;
  17663. /**
  17664. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17665. * @hidden
  17666. */
  17667. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17668. /**
  17669. * Resets the different information of the group to prepare a new frame
  17670. * @hidden
  17671. */
  17672. reset(): void;
  17673. /**
  17674. * Dispose and release the group and its associated resources.
  17675. * @hidden
  17676. */
  17677. dispose(): void;
  17678. /**
  17679. * Clear the info related to rendering groups preventing retention points during dispose.
  17680. */
  17681. freeRenderingGroups(): void;
  17682. private _prepareRenderingGroup;
  17683. /**
  17684. * Add a sprite manager to the rendering manager in order to render it this frame.
  17685. * @param spriteManager Define the sprite manager to render
  17686. */
  17687. dispatchSprites(spriteManager: ISpriteManager): void;
  17688. /**
  17689. * Add a particle system to the rendering manager in order to render it this frame.
  17690. * @param particleSystem Define the particle system to render
  17691. */
  17692. dispatchParticles(particleSystem: IParticleSystem): void;
  17693. /**
  17694. * Add a submesh to the manager in order to render it this frame
  17695. * @param subMesh The submesh to dispatch
  17696. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17697. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17698. */
  17699. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17700. /**
  17701. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17702. * This allowed control for front to back rendering or reversly depending of the special needs.
  17703. *
  17704. * @param renderingGroupId The rendering group id corresponding to its index
  17705. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17706. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17707. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17708. */
  17709. 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;
  17710. /**
  17711. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17712. *
  17713. * @param renderingGroupId The rendering group id corresponding to its index
  17714. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17715. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17716. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17717. */
  17718. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17719. /**
  17720. * Gets the current auto clear configuration for one rendering group of the rendering
  17721. * manager.
  17722. * @param index the rendering group index to get the information for
  17723. * @returns The auto clear setup for the requested rendering group
  17724. */
  17725. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17726. }
  17727. }
  17728. declare module BABYLON {
  17729. /**
  17730. * This Helps creating a texture that will be created from a camera in your scene.
  17731. * It is basically a dynamic texture that could be used to create special effects for instance.
  17732. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17733. */
  17734. export class RenderTargetTexture extends Texture {
  17735. isCube: boolean;
  17736. /**
  17737. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17738. */
  17739. static readonly REFRESHRATE_RENDER_ONCE: number;
  17740. /**
  17741. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17742. */
  17743. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17744. /**
  17745. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17746. * the central point of your effect and can save a lot of performances.
  17747. */
  17748. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17749. /**
  17750. * Use this predicate to dynamically define the list of mesh you want to render.
  17751. * If set, the renderList property will be overwritten.
  17752. */
  17753. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17754. private _renderList;
  17755. /**
  17756. * Use this list to define the list of mesh you want to render.
  17757. */
  17758. renderList: Nullable<Array<AbstractMesh>>;
  17759. private _hookArray;
  17760. /**
  17761. * Define if particles should be rendered in your texture.
  17762. */
  17763. renderParticles: boolean;
  17764. /**
  17765. * Define if sprites should be rendered in your texture.
  17766. */
  17767. renderSprites: boolean;
  17768. /**
  17769. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17770. */
  17771. coordinatesMode: number;
  17772. /**
  17773. * Define the camera used to render the texture.
  17774. */
  17775. activeCamera: Nullable<Camera>;
  17776. /**
  17777. * Override the render function of the texture with your own one.
  17778. */
  17779. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17780. /**
  17781. * Define if camera post processes should be use while rendering the texture.
  17782. */
  17783. useCameraPostProcesses: boolean;
  17784. /**
  17785. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17786. */
  17787. ignoreCameraViewport: boolean;
  17788. private _postProcessManager;
  17789. private _postProcesses;
  17790. private _resizeObserver;
  17791. /**
  17792. * An event triggered when the texture is unbind.
  17793. */
  17794. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17795. /**
  17796. * An event triggered when the texture is unbind.
  17797. */
  17798. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17799. private _onAfterUnbindObserver;
  17800. /**
  17801. * Set a after unbind callback in the texture.
  17802. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17803. */
  17804. onAfterUnbind: () => void;
  17805. /**
  17806. * An event triggered before rendering the texture
  17807. */
  17808. onBeforeRenderObservable: Observable<number>;
  17809. private _onBeforeRenderObserver;
  17810. /**
  17811. * Set a before render callback in the texture.
  17812. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17813. */
  17814. onBeforeRender: (faceIndex: number) => void;
  17815. /**
  17816. * An event triggered after rendering the texture
  17817. */
  17818. onAfterRenderObservable: Observable<number>;
  17819. private _onAfterRenderObserver;
  17820. /**
  17821. * Set a after render callback in the texture.
  17822. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17823. */
  17824. onAfterRender: (faceIndex: number) => void;
  17825. /**
  17826. * An event triggered after the texture clear
  17827. */
  17828. onClearObservable: Observable<Engine>;
  17829. private _onClearObserver;
  17830. /**
  17831. * Set a clear callback in the texture.
  17832. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17833. */
  17834. onClear: (Engine: Engine) => void;
  17835. /**
  17836. * Define the clear color of the Render Target if it should be different from the scene.
  17837. */
  17838. clearColor: Color4;
  17839. protected _size: number | {
  17840. width: number;
  17841. height: number;
  17842. };
  17843. protected _initialSizeParameter: number | {
  17844. width: number;
  17845. height: number;
  17846. } | {
  17847. ratio: number;
  17848. };
  17849. protected _sizeRatio: Nullable<number>;
  17850. /** @hidden */
  17851. _generateMipMaps: boolean;
  17852. protected _renderingManager: RenderingManager;
  17853. /** @hidden */
  17854. _waitingRenderList: string[];
  17855. protected _doNotChangeAspectRatio: boolean;
  17856. protected _currentRefreshId: number;
  17857. protected _refreshRate: number;
  17858. protected _textureMatrix: Matrix;
  17859. protected _samples: number;
  17860. protected _renderTargetOptions: RenderTargetCreationOptions;
  17861. /**
  17862. * Gets render target creation options that were used.
  17863. */
  17864. readonly renderTargetOptions: RenderTargetCreationOptions;
  17865. protected _engine: Engine;
  17866. protected _onRatioRescale(): void;
  17867. /**
  17868. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17869. * It must define where the camera used to render the texture is set
  17870. */
  17871. boundingBoxPosition: Vector3;
  17872. private _boundingBoxSize;
  17873. /**
  17874. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17875. * When defined, the cubemap will switch to local mode
  17876. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17877. * @example https://www.babylonjs-playground.com/#RNASML
  17878. */
  17879. boundingBoxSize: Vector3;
  17880. /**
  17881. * In case the RTT has been created with a depth texture, get the associated
  17882. * depth texture.
  17883. * Otherwise, return null.
  17884. */
  17885. depthStencilTexture: Nullable<InternalTexture>;
  17886. /**
  17887. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17888. * or used a shadow, depth texture...
  17889. * @param name The friendly name of the texture
  17890. * @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)
  17891. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17892. * @param generateMipMaps True if mip maps need to be generated after render.
  17893. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17894. * @param type The type of the buffer in the RTT (int, half float, float...)
  17895. * @param isCube True if a cube texture needs to be created
  17896. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17897. * @param generateDepthBuffer True to generate a depth buffer
  17898. * @param generateStencilBuffer True to generate a stencil buffer
  17899. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17900. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17901. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17902. */
  17903. constructor(name: string, size: number | {
  17904. width: number;
  17905. height: number;
  17906. } | {
  17907. ratio: number;
  17908. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17909. /**
  17910. * Creates a depth stencil texture.
  17911. * This is only available in WebGL 2 or with the depth texture extension available.
  17912. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17913. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17914. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17915. */
  17916. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17917. private _processSizeParameter;
  17918. /**
  17919. * Define the number of samples to use in case of MSAA.
  17920. * It defaults to one meaning no MSAA has been enabled.
  17921. */
  17922. samples: number;
  17923. /**
  17924. * Resets the refresh counter of the texture and start bak from scratch.
  17925. * Could be useful to regenerate the texture if it is setup to render only once.
  17926. */
  17927. resetRefreshCounter(): void;
  17928. /**
  17929. * Define the refresh rate of the texture or the rendering frequency.
  17930. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17931. */
  17932. refreshRate: number;
  17933. /**
  17934. * Adds a post process to the render target rendering passes.
  17935. * @param postProcess define the post process to add
  17936. */
  17937. addPostProcess(postProcess: PostProcess): void;
  17938. /**
  17939. * Clear all the post processes attached to the render target
  17940. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17941. */
  17942. clearPostProcesses(dispose?: boolean): void;
  17943. /**
  17944. * Remove one of the post process from the list of attached post processes to the texture
  17945. * @param postProcess define the post process to remove from the list
  17946. */
  17947. removePostProcess(postProcess: PostProcess): void;
  17948. /** @hidden */
  17949. _shouldRender(): boolean;
  17950. /**
  17951. * Gets the actual render size of the texture.
  17952. * @returns the width of the render size
  17953. */
  17954. getRenderSize(): number;
  17955. /**
  17956. * Gets the actual render width of the texture.
  17957. * @returns the width of the render size
  17958. */
  17959. getRenderWidth(): number;
  17960. /**
  17961. * Gets the actual render height of the texture.
  17962. * @returns the height of the render size
  17963. */
  17964. getRenderHeight(): number;
  17965. /**
  17966. * Get if the texture can be rescaled or not.
  17967. */
  17968. readonly canRescale: boolean;
  17969. /**
  17970. * Resize the texture using a ratio.
  17971. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17972. */
  17973. scale(ratio: number): void;
  17974. /**
  17975. * Get the texture reflection matrix used to rotate/transform the reflection.
  17976. * @returns the reflection matrix
  17977. */
  17978. getReflectionTextureMatrix(): Matrix;
  17979. /**
  17980. * Resize the texture to a new desired size.
  17981. * Be carrefull as it will recreate all the data in the new texture.
  17982. * @param size Define the new size. It can be:
  17983. * - a number for squared texture,
  17984. * - an object containing { width: number, height: number }
  17985. * - or an object containing a ratio { ratio: number }
  17986. */
  17987. resize(size: number | {
  17988. width: number;
  17989. height: number;
  17990. } | {
  17991. ratio: number;
  17992. }): void;
  17993. /**
  17994. * Renders all the objects from the render list into the texture.
  17995. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17996. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17997. */
  17998. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17999. private _bestReflectionRenderTargetDimension;
  18000. /**
  18001. * @hidden
  18002. * @param faceIndex face index to bind to if this is a cubetexture
  18003. */
  18004. _bindFrameBuffer(faceIndex?: number): void;
  18005. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18006. private renderToTarget;
  18007. /**
  18008. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18009. * This allowed control for front to back rendering or reversly depending of the special needs.
  18010. *
  18011. * @param renderingGroupId The rendering group id corresponding to its index
  18012. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18013. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18014. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18015. */
  18016. 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;
  18017. /**
  18018. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18019. *
  18020. * @param renderingGroupId The rendering group id corresponding to its index
  18021. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18022. */
  18023. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18024. /**
  18025. * Clones the texture.
  18026. * @returns the cloned texture
  18027. */
  18028. clone(): RenderTargetTexture;
  18029. /**
  18030. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18031. * @returns The JSON representation of the texture
  18032. */
  18033. serialize(): any;
  18034. /**
  18035. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18036. */
  18037. disposeFramebufferObjects(): void;
  18038. /**
  18039. * Dispose the texture and release its associated resources.
  18040. */
  18041. dispose(): void;
  18042. /** @hidden */
  18043. _rebuild(): void;
  18044. /**
  18045. * Clear the info related to rendering groups preventing retention point in material dispose.
  18046. */
  18047. freeRenderingGroups(): void;
  18048. /**
  18049. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18050. * @returns the view count
  18051. */
  18052. getViewCount(): number;
  18053. }
  18054. }
  18055. declare module BABYLON {
  18056. /**
  18057. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18058. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18059. * You can then easily use it as a reflectionTexture on a flat surface.
  18060. * In case the surface is not a plane, please consider relying on reflection probes.
  18061. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18062. */
  18063. export class MirrorTexture extends RenderTargetTexture {
  18064. private scene;
  18065. /**
  18066. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18067. * 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.
  18068. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18069. */
  18070. mirrorPlane: Plane;
  18071. /**
  18072. * Define the blur ratio used to blur the reflection if needed.
  18073. */
  18074. blurRatio: number;
  18075. /**
  18076. * Define the adaptive blur kernel used to blur the reflection if needed.
  18077. * This will autocompute the closest best match for the `blurKernel`
  18078. */
  18079. adaptiveBlurKernel: number;
  18080. /**
  18081. * Define the blur kernel used to blur the reflection if needed.
  18082. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18083. */
  18084. blurKernel: number;
  18085. /**
  18086. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18087. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18088. */
  18089. blurKernelX: number;
  18090. /**
  18091. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18092. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18093. */
  18094. blurKernelY: number;
  18095. private _autoComputeBlurKernel;
  18096. protected _onRatioRescale(): void;
  18097. private _updateGammaSpace;
  18098. private _imageProcessingConfigChangeObserver;
  18099. private _transformMatrix;
  18100. private _mirrorMatrix;
  18101. private _savedViewMatrix;
  18102. private _blurX;
  18103. private _blurY;
  18104. private _adaptiveBlurKernel;
  18105. private _blurKernelX;
  18106. private _blurKernelY;
  18107. private _blurRatio;
  18108. /**
  18109. * Instantiates a Mirror Texture.
  18110. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18111. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18112. * You can then easily use it as a reflectionTexture on a flat surface.
  18113. * In case the surface is not a plane, please consider relying on reflection probes.
  18114. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18115. * @param name
  18116. * @param size
  18117. * @param scene
  18118. * @param generateMipMaps
  18119. * @param type
  18120. * @param samplingMode
  18121. * @param generateDepthBuffer
  18122. */
  18123. constructor(name: string, size: number | {
  18124. width: number;
  18125. height: number;
  18126. } | {
  18127. ratio: number;
  18128. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18129. private _preparePostProcesses;
  18130. /**
  18131. * Clone the mirror texture.
  18132. * @returns the cloned texture
  18133. */
  18134. clone(): MirrorTexture;
  18135. /**
  18136. * Serialize the texture to a JSON representation you could use in Parse later on
  18137. * @returns the serialized JSON representation
  18138. */
  18139. serialize(): any;
  18140. /**
  18141. * Dispose the texture and release its associated resources.
  18142. */
  18143. dispose(): void;
  18144. }
  18145. }
  18146. declare module BABYLON {
  18147. /**
  18148. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18149. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18150. */
  18151. export class Texture extends BaseTexture {
  18152. /** @hidden */
  18153. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18154. /** @hidden */
  18155. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18156. /** @hidden */
  18157. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18158. /** nearest is mag = nearest and min = nearest and mip = linear */
  18159. static readonly NEAREST_SAMPLINGMODE: number;
  18160. /** nearest is mag = nearest and min = nearest and mip = linear */
  18161. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18162. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18163. static readonly BILINEAR_SAMPLINGMODE: number;
  18164. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18165. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18166. /** Trilinear is mag = linear and min = linear and mip = linear */
  18167. static readonly TRILINEAR_SAMPLINGMODE: number;
  18168. /** Trilinear is mag = linear and min = linear and mip = linear */
  18169. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18170. /** mag = nearest and min = nearest and mip = nearest */
  18171. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18172. /** mag = nearest and min = linear and mip = nearest */
  18173. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18174. /** mag = nearest and min = linear and mip = linear */
  18175. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18176. /** mag = nearest and min = linear and mip = none */
  18177. static readonly NEAREST_LINEAR: number;
  18178. /** mag = nearest and min = nearest and mip = none */
  18179. static readonly NEAREST_NEAREST: number;
  18180. /** mag = linear and min = nearest and mip = nearest */
  18181. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18182. /** mag = linear and min = nearest and mip = linear */
  18183. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18184. /** mag = linear and min = linear and mip = none */
  18185. static readonly LINEAR_LINEAR: number;
  18186. /** mag = linear and min = nearest and mip = none */
  18187. static readonly LINEAR_NEAREST: number;
  18188. /** Explicit coordinates mode */
  18189. static readonly EXPLICIT_MODE: number;
  18190. /** Spherical coordinates mode */
  18191. static readonly SPHERICAL_MODE: number;
  18192. /** Planar coordinates mode */
  18193. static readonly PLANAR_MODE: number;
  18194. /** Cubic coordinates mode */
  18195. static readonly CUBIC_MODE: number;
  18196. /** Projection coordinates mode */
  18197. static readonly PROJECTION_MODE: number;
  18198. /** Inverse Cubic coordinates mode */
  18199. static readonly SKYBOX_MODE: number;
  18200. /** Inverse Cubic coordinates mode */
  18201. static readonly INVCUBIC_MODE: number;
  18202. /** Equirectangular coordinates mode */
  18203. static readonly EQUIRECTANGULAR_MODE: number;
  18204. /** Equirectangular Fixed coordinates mode */
  18205. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18206. /** Equirectangular Fixed Mirrored coordinates mode */
  18207. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18208. /** Texture is not repeating outside of 0..1 UVs */
  18209. static readonly CLAMP_ADDRESSMODE: number;
  18210. /** Texture is repeating outside of 0..1 UVs */
  18211. static readonly WRAP_ADDRESSMODE: number;
  18212. /** Texture is repeating and mirrored */
  18213. static readonly MIRROR_ADDRESSMODE: number;
  18214. /**
  18215. * 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
  18216. */
  18217. static UseSerializedUrlIfAny: boolean;
  18218. /**
  18219. * Define the url of the texture.
  18220. */
  18221. url: Nullable<string>;
  18222. /**
  18223. * Define an offset on the texture to offset the u coordinates of the UVs
  18224. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18225. */
  18226. uOffset: number;
  18227. /**
  18228. * Define an offset on the texture to offset the v coordinates of the UVs
  18229. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18230. */
  18231. vOffset: number;
  18232. /**
  18233. * Define an offset on the texture to scale the u coordinates of the UVs
  18234. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18235. */
  18236. uScale: number;
  18237. /**
  18238. * Define an offset on the texture to scale the v coordinates of the UVs
  18239. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18240. */
  18241. vScale: number;
  18242. /**
  18243. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18244. * @see http://doc.babylonjs.com/how_to/more_materials
  18245. */
  18246. uAng: number;
  18247. /**
  18248. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18249. * @see http://doc.babylonjs.com/how_to/more_materials
  18250. */
  18251. vAng: number;
  18252. /**
  18253. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18254. * @see http://doc.babylonjs.com/how_to/more_materials
  18255. */
  18256. wAng: number;
  18257. /**
  18258. * Defines the center of rotation (U)
  18259. */
  18260. uRotationCenter: number;
  18261. /**
  18262. * Defines the center of rotation (V)
  18263. */
  18264. vRotationCenter: number;
  18265. /**
  18266. * Defines the center of rotation (W)
  18267. */
  18268. wRotationCenter: number;
  18269. /**
  18270. * Are mip maps generated for this texture or not.
  18271. */
  18272. readonly noMipmap: boolean;
  18273. /**
  18274. * List of inspectable custom properties (used by the Inspector)
  18275. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18276. */
  18277. inspectableCustomProperties: Nullable<IInspectable[]>;
  18278. private _noMipmap;
  18279. /** @hidden */
  18280. _invertY: boolean;
  18281. private _rowGenerationMatrix;
  18282. private _cachedTextureMatrix;
  18283. private _projectionModeMatrix;
  18284. private _t0;
  18285. private _t1;
  18286. private _t2;
  18287. private _cachedUOffset;
  18288. private _cachedVOffset;
  18289. private _cachedUScale;
  18290. private _cachedVScale;
  18291. private _cachedUAng;
  18292. private _cachedVAng;
  18293. private _cachedWAng;
  18294. private _cachedProjectionMatrixId;
  18295. private _cachedCoordinatesMode;
  18296. /** @hidden */
  18297. protected _initialSamplingMode: number;
  18298. /** @hidden */
  18299. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18300. private _deleteBuffer;
  18301. protected _format: Nullable<number>;
  18302. private _delayedOnLoad;
  18303. private _delayedOnError;
  18304. /**
  18305. * Observable triggered once the texture has been loaded.
  18306. */
  18307. onLoadObservable: Observable<Texture>;
  18308. protected _isBlocking: boolean;
  18309. /**
  18310. * Is the texture preventing material to render while loading.
  18311. * If false, a default texture will be used instead of the loading one during the preparation step.
  18312. */
  18313. isBlocking: boolean;
  18314. /**
  18315. * Get the current sampling mode associated with the texture.
  18316. */
  18317. readonly samplingMode: number;
  18318. /**
  18319. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18320. */
  18321. readonly invertY: boolean;
  18322. /**
  18323. * Instantiates a new texture.
  18324. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18325. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18326. * @param url define the url of the picture to load as a texture
  18327. * @param scene define the scene the texture will belong to
  18328. * @param noMipmap define if the texture will require mip maps or not
  18329. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18330. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18331. * @param onLoad define a callback triggered when the texture has been loaded
  18332. * @param onError define a callback triggered when an error occurred during the loading session
  18333. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18334. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18335. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18336. */
  18337. 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);
  18338. /**
  18339. * Update the url (and optional buffer) of this texture if url was null during construction.
  18340. * @param url the url of the texture
  18341. * @param buffer the buffer of the texture (defaults to null)
  18342. * @param onLoad callback called when the texture is loaded (defaults to null)
  18343. */
  18344. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18345. /**
  18346. * Finish the loading sequence of a texture flagged as delayed load.
  18347. * @hidden
  18348. */
  18349. delayLoad(): void;
  18350. private _prepareRowForTextureGeneration;
  18351. /**
  18352. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18353. * @returns the transform matrix of the texture.
  18354. */
  18355. getTextureMatrix(): Matrix;
  18356. /**
  18357. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18358. * @returns The reflection texture transform
  18359. */
  18360. getReflectionTextureMatrix(): Matrix;
  18361. /**
  18362. * Clones the texture.
  18363. * @returns the cloned texture
  18364. */
  18365. clone(): Texture;
  18366. /**
  18367. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18368. * @returns The JSON representation of the texture
  18369. */
  18370. serialize(): any;
  18371. /**
  18372. * Get the current class name of the texture useful for serialization or dynamic coding.
  18373. * @returns "Texture"
  18374. */
  18375. getClassName(): string;
  18376. /**
  18377. * Dispose the texture and release its associated resources.
  18378. */
  18379. dispose(): void;
  18380. /**
  18381. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18382. * @param parsedTexture Define the JSON representation of the texture
  18383. * @param scene Define the scene the parsed texture should be instantiated in
  18384. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18385. * @returns The parsed texture if successful
  18386. */
  18387. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18388. /**
  18389. * Creates a texture from its base 64 representation.
  18390. * @param data Define the base64 payload without the data: prefix
  18391. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18392. * @param scene Define the scene the texture should belong to
  18393. * @param noMipmap Forces the texture to not create mip map information if true
  18394. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18395. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18396. * @param onLoad define a callback triggered when the texture has been loaded
  18397. * @param onError define a callback triggered when an error occurred during the loading session
  18398. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18399. * @returns the created texture
  18400. */
  18401. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18402. /**
  18403. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18404. * @param data Define the base64 payload without the data: prefix
  18405. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18406. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18407. * @param scene Define the scene the texture should belong to
  18408. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18409. * @param noMipmap Forces the texture to not create mip map information if true
  18410. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18411. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18412. * @param onLoad define a callback triggered when the texture has been loaded
  18413. * @param onError define a callback triggered when an error occurred during the loading session
  18414. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18415. * @returns the created texture
  18416. */
  18417. 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;
  18418. }
  18419. }
  18420. declare module BABYLON {
  18421. interface Engine {
  18422. /**
  18423. * Creates a raw texture
  18424. * @param data defines the data to store in the texture
  18425. * @param width defines the width of the texture
  18426. * @param height defines the height of the texture
  18427. * @param format defines the format of the data
  18428. * @param generateMipMaps defines if the engine should generate the mip levels
  18429. * @param invertY defines if data must be stored with Y axis inverted
  18430. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18431. * @param compression defines the compression used (null by default)
  18432. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18433. * @returns the raw texture inside an InternalTexture
  18434. */
  18435. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18436. /**
  18437. * Update a raw texture
  18438. * @param texture defines the texture to update
  18439. * @param data defines the data to store in the texture
  18440. * @param format defines the format of the data
  18441. * @param invertY defines if data must be stored with Y axis inverted
  18442. */
  18443. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18444. /**
  18445. * Update a raw texture
  18446. * @param texture defines the texture to update
  18447. * @param data defines the data to store in the texture
  18448. * @param format defines the format of the data
  18449. * @param invertY defines if data must be stored with Y axis inverted
  18450. * @param compression defines the compression used (null by default)
  18451. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18452. */
  18453. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18454. /**
  18455. * Creates a new raw cube texture
  18456. * @param data defines the array of data to use to create each face
  18457. * @param size defines the size of the textures
  18458. * @param format defines the format of the data
  18459. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18460. * @param generateMipMaps defines if the engine should generate the mip levels
  18461. * @param invertY defines if data must be stored with Y axis inverted
  18462. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18463. * @param compression defines the compression used (null by default)
  18464. * @returns the cube texture as an InternalTexture
  18465. */
  18466. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18467. /**
  18468. * Update a raw cube texture
  18469. * @param texture defines the texture to udpdate
  18470. * @param data defines the data to store
  18471. * @param format defines the data format
  18472. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18473. * @param invertY defines if data must be stored with Y axis inverted
  18474. */
  18475. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18476. /**
  18477. * Update a raw cube texture
  18478. * @param texture defines the texture to udpdate
  18479. * @param data defines the data to store
  18480. * @param format defines the data format
  18481. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18482. * @param invertY defines if data must be stored with Y axis inverted
  18483. * @param compression defines the compression used (null by default)
  18484. */
  18485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18486. /**
  18487. * Update a raw cube texture
  18488. * @param texture defines the texture to udpdate
  18489. * @param data defines the data to store
  18490. * @param format defines the data format
  18491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18492. * @param invertY defines if data must be stored with Y axis inverted
  18493. * @param compression defines the compression used (null by default)
  18494. * @param level defines which level of the texture to update
  18495. */
  18496. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18497. /**
  18498. * Creates a new raw cube texture from a specified url
  18499. * @param url defines the url where the data is located
  18500. * @param scene defines the current scene
  18501. * @param size defines the size of the textures
  18502. * @param format defines the format of the data
  18503. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18504. * @param noMipmap defines if the engine should avoid generating the mip levels
  18505. * @param callback defines a callback used to extract texture data from loaded data
  18506. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18507. * @param onLoad defines a callback called when texture is loaded
  18508. * @param onError defines a callback called if there is an error
  18509. * @returns the cube texture as an InternalTexture
  18510. */
  18511. 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>): InternalTexture;
  18512. /**
  18513. * Creates a new raw cube texture from a specified url
  18514. * @param url defines the url where the data is located
  18515. * @param scene defines the current scene
  18516. * @param size defines the size of the textures
  18517. * @param format defines the format of the data
  18518. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18519. * @param noMipmap defines if the engine should avoid generating the mip levels
  18520. * @param callback defines a callback used to extract texture data from loaded data
  18521. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18522. * @param onLoad defines a callback called when texture is loaded
  18523. * @param onError defines a callback called if there is an error
  18524. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18525. * @param invertY defines if data must be stored with Y axis inverted
  18526. * @returns the cube texture as an InternalTexture
  18527. */
  18528. 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;
  18529. /**
  18530. * Creates a new raw 3D texture
  18531. * @param data defines the data used to create the texture
  18532. * @param width defines the width of the texture
  18533. * @param height defines the height of the texture
  18534. * @param depth defines the depth of the texture
  18535. * @param format defines the format of the texture
  18536. * @param generateMipMaps defines if the engine must generate mip levels
  18537. * @param invertY defines if data must be stored with Y axis inverted
  18538. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18539. * @param compression defines the compressed used (can be null)
  18540. * @param textureType defines the compressed used (can be null)
  18541. * @returns a new raw 3D texture (stored in an InternalTexture)
  18542. */
  18543. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18544. /**
  18545. * Update a raw 3D texture
  18546. * @param texture defines the texture to update
  18547. * @param data defines the data to store
  18548. * @param format defines the data format
  18549. * @param invertY defines if data must be stored with Y axis inverted
  18550. */
  18551. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18552. /**
  18553. * Update a raw 3D texture
  18554. * @param texture defines the texture to update
  18555. * @param data defines the data to store
  18556. * @param format defines the data format
  18557. * @param invertY defines if data must be stored with Y axis inverted
  18558. * @param compression defines the used compression (can be null)
  18559. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18560. */
  18561. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18562. }
  18563. }
  18564. declare module BABYLON {
  18565. /**
  18566. * Raw texture can help creating a texture directly from an array of data.
  18567. * This can be super useful if you either get the data from an uncompressed source or
  18568. * if you wish to create your texture pixel by pixel.
  18569. */
  18570. export class RawTexture extends Texture {
  18571. /**
  18572. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18573. */
  18574. format: number;
  18575. private _engine;
  18576. /**
  18577. * Instantiates a new RawTexture.
  18578. * Raw texture can help creating a texture directly from an array of data.
  18579. * This can be super useful if you either get the data from an uncompressed source or
  18580. * if you wish to create your texture pixel by pixel.
  18581. * @param data define the array of data to use to create the texture
  18582. * @param width define the width of the texture
  18583. * @param height define the height of the texture
  18584. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18585. * @param scene define the scene the texture belongs to
  18586. * @param generateMipMaps define whether mip maps should be generated or not
  18587. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18588. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18589. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18590. */
  18591. constructor(data: ArrayBufferView, width: number, height: number,
  18592. /**
  18593. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18594. */
  18595. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18596. /**
  18597. * Updates the texture underlying data.
  18598. * @param data Define the new data of the texture
  18599. */
  18600. update(data: ArrayBufferView): void;
  18601. /**
  18602. * Creates a luminance texture from some data.
  18603. * @param data Define the texture data
  18604. * @param width Define the width of the texture
  18605. * @param height Define the height of the texture
  18606. * @param scene Define the scene the texture belongs to
  18607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18610. * @returns the luminance texture
  18611. */
  18612. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18613. /**
  18614. * Creates a luminance alpha texture from some data.
  18615. * @param data Define the texture data
  18616. * @param width Define the width of the texture
  18617. * @param height Define the height of the texture
  18618. * @param scene Define the scene the texture belongs to
  18619. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18622. * @returns the luminance alpha texture
  18623. */
  18624. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18625. /**
  18626. * Creates an alpha texture from some data.
  18627. * @param data Define the texture data
  18628. * @param width Define the width of the texture
  18629. * @param height Define the height of the texture
  18630. * @param scene Define the scene the texture belongs to
  18631. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18632. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18633. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18634. * @returns the alpha texture
  18635. */
  18636. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18637. /**
  18638. * Creates a RGB texture from some data.
  18639. * @param data Define the texture data
  18640. * @param width Define the width of the texture
  18641. * @param height Define the height of the texture
  18642. * @param scene Define the scene the texture belongs to
  18643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18646. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18647. * @returns the RGB alpha texture
  18648. */
  18649. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18650. /**
  18651. * Creates a RGBA texture from some data.
  18652. * @param data Define the texture data
  18653. * @param width Define the width of the texture
  18654. * @param height Define the height of the texture
  18655. * @param scene Define the scene the texture belongs to
  18656. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18657. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18658. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18659. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18660. * @returns the RGBA texture
  18661. */
  18662. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18663. /**
  18664. * Creates a R texture from some data.
  18665. * @param data Define the texture data
  18666. * @param width Define the width of the texture
  18667. * @param height Define the height of the texture
  18668. * @param scene Define the scene the texture belongs to
  18669. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18670. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18671. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18672. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18673. * @returns the R texture
  18674. */
  18675. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18676. }
  18677. }
  18678. declare module BABYLON {
  18679. /**
  18680. * Defines a runtime animation
  18681. */
  18682. export class RuntimeAnimation {
  18683. private _events;
  18684. /**
  18685. * The current frame of the runtime animation
  18686. */
  18687. private _currentFrame;
  18688. /**
  18689. * The animation used by the runtime animation
  18690. */
  18691. private _animation;
  18692. /**
  18693. * The target of the runtime animation
  18694. */
  18695. private _target;
  18696. /**
  18697. * The initiating animatable
  18698. */
  18699. private _host;
  18700. /**
  18701. * The original value of the runtime animation
  18702. */
  18703. private _originalValue;
  18704. /**
  18705. * The original blend value of the runtime animation
  18706. */
  18707. private _originalBlendValue;
  18708. /**
  18709. * The offsets cache of the runtime animation
  18710. */
  18711. private _offsetsCache;
  18712. /**
  18713. * The high limits cache of the runtime animation
  18714. */
  18715. private _highLimitsCache;
  18716. /**
  18717. * Specifies if the runtime animation has been stopped
  18718. */
  18719. private _stopped;
  18720. /**
  18721. * The blending factor of the runtime animation
  18722. */
  18723. private _blendingFactor;
  18724. /**
  18725. * The BabylonJS scene
  18726. */
  18727. private _scene;
  18728. /**
  18729. * The current value of the runtime animation
  18730. */
  18731. private _currentValue;
  18732. /** @hidden */
  18733. _animationState: _IAnimationState;
  18734. /**
  18735. * The active target of the runtime animation
  18736. */
  18737. private _activeTargets;
  18738. private _currentActiveTarget;
  18739. private _directTarget;
  18740. /**
  18741. * The target path of the runtime animation
  18742. */
  18743. private _targetPath;
  18744. /**
  18745. * The weight of the runtime animation
  18746. */
  18747. private _weight;
  18748. /**
  18749. * The ratio offset of the runtime animation
  18750. */
  18751. private _ratioOffset;
  18752. /**
  18753. * The previous delay of the runtime animation
  18754. */
  18755. private _previousDelay;
  18756. /**
  18757. * The previous ratio of the runtime animation
  18758. */
  18759. private _previousRatio;
  18760. private _enableBlending;
  18761. private _keys;
  18762. private _minFrame;
  18763. private _maxFrame;
  18764. private _minValue;
  18765. private _maxValue;
  18766. private _targetIsArray;
  18767. /**
  18768. * Gets the current frame of the runtime animation
  18769. */
  18770. readonly currentFrame: number;
  18771. /**
  18772. * Gets the weight of the runtime animation
  18773. */
  18774. readonly weight: number;
  18775. /**
  18776. * Gets the current value of the runtime animation
  18777. */
  18778. readonly currentValue: any;
  18779. /**
  18780. * Gets the target path of the runtime animation
  18781. */
  18782. readonly targetPath: string;
  18783. /**
  18784. * Gets the actual target of the runtime animation
  18785. */
  18786. readonly target: any;
  18787. /** @hidden */
  18788. _onLoop: () => void;
  18789. /**
  18790. * Create a new RuntimeAnimation object
  18791. * @param target defines the target of the animation
  18792. * @param animation defines the source animation object
  18793. * @param scene defines the hosting scene
  18794. * @param host defines the initiating Animatable
  18795. */
  18796. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18797. private _preparePath;
  18798. /**
  18799. * Gets the animation from the runtime animation
  18800. */
  18801. readonly animation: Animation;
  18802. /**
  18803. * Resets the runtime animation to the beginning
  18804. * @param restoreOriginal defines whether to restore the target property to the original value
  18805. */
  18806. reset(restoreOriginal?: boolean): void;
  18807. /**
  18808. * Specifies if the runtime animation is stopped
  18809. * @returns Boolean specifying if the runtime animation is stopped
  18810. */
  18811. isStopped(): boolean;
  18812. /**
  18813. * Disposes of the runtime animation
  18814. */
  18815. dispose(): void;
  18816. /**
  18817. * Apply the interpolated value to the target
  18818. * @param currentValue defines the value computed by the animation
  18819. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18820. */
  18821. setValue(currentValue: any, weight: number): void;
  18822. private _getOriginalValues;
  18823. private _setValue;
  18824. /**
  18825. * Gets the loop pmode of the runtime animation
  18826. * @returns Loop Mode
  18827. */
  18828. private _getCorrectLoopMode;
  18829. /**
  18830. * Move the current animation to a given frame
  18831. * @param frame defines the frame to move to
  18832. */
  18833. goToFrame(frame: number): void;
  18834. /**
  18835. * @hidden Internal use only
  18836. */
  18837. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18838. /**
  18839. * Execute the current animation
  18840. * @param delay defines the delay to add to the current frame
  18841. * @param from defines the lower bound of the animation range
  18842. * @param to defines the upper bound of the animation range
  18843. * @param loop defines if the current animation must loop
  18844. * @param speedRatio defines the current speed ratio
  18845. * @param weight defines the weight of the animation (default is -1 so no weight)
  18846. * @param onLoop optional callback called when animation loops
  18847. * @returns a boolean indicating if the animation is running
  18848. */
  18849. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18850. }
  18851. }
  18852. declare module BABYLON {
  18853. /**
  18854. * Class used to store an actual running animation
  18855. */
  18856. export class Animatable {
  18857. /** defines the target object */
  18858. target: any;
  18859. /** defines the starting frame number (default is 0) */
  18860. fromFrame: number;
  18861. /** defines the ending frame number (default is 100) */
  18862. toFrame: number;
  18863. /** defines if the animation must loop (default is false) */
  18864. loopAnimation: boolean;
  18865. /** defines a callback to call when animation ends if it is not looping */
  18866. onAnimationEnd?: (() => void) | null | undefined;
  18867. /** defines a callback to call when animation loops */
  18868. onAnimationLoop?: (() => void) | null | undefined;
  18869. private _localDelayOffset;
  18870. private _pausedDelay;
  18871. private _runtimeAnimations;
  18872. private _paused;
  18873. private _scene;
  18874. private _speedRatio;
  18875. private _weight;
  18876. private _syncRoot;
  18877. /**
  18878. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18879. * This will only apply for non looping animation (default is true)
  18880. */
  18881. disposeOnEnd: boolean;
  18882. /**
  18883. * Gets a boolean indicating if the animation has started
  18884. */
  18885. animationStarted: boolean;
  18886. /**
  18887. * Observer raised when the animation ends
  18888. */
  18889. onAnimationEndObservable: Observable<Animatable>;
  18890. /**
  18891. * Observer raised when the animation loops
  18892. */
  18893. onAnimationLoopObservable: Observable<Animatable>;
  18894. /**
  18895. * Gets the root Animatable used to synchronize and normalize animations
  18896. */
  18897. readonly syncRoot: Nullable<Animatable>;
  18898. /**
  18899. * Gets the current frame of the first RuntimeAnimation
  18900. * Used to synchronize Animatables
  18901. */
  18902. readonly masterFrame: number;
  18903. /**
  18904. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18905. */
  18906. weight: number;
  18907. /**
  18908. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18909. */
  18910. speedRatio: number;
  18911. /**
  18912. * Creates a new Animatable
  18913. * @param scene defines the hosting scene
  18914. * @param target defines the target object
  18915. * @param fromFrame defines the starting frame number (default is 0)
  18916. * @param toFrame defines the ending frame number (default is 100)
  18917. * @param loopAnimation defines if the animation must loop (default is false)
  18918. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18919. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18920. * @param animations defines a group of animation to add to the new Animatable
  18921. * @param onAnimationLoop defines a callback to call when animation loops
  18922. */
  18923. constructor(scene: Scene,
  18924. /** defines the target object */
  18925. target: any,
  18926. /** defines the starting frame number (default is 0) */
  18927. fromFrame?: number,
  18928. /** defines the ending frame number (default is 100) */
  18929. toFrame?: number,
  18930. /** defines if the animation must loop (default is false) */
  18931. loopAnimation?: boolean, speedRatio?: number,
  18932. /** defines a callback to call when animation ends if it is not looping */
  18933. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18934. /** defines a callback to call when animation loops */
  18935. onAnimationLoop?: (() => void) | null | undefined);
  18936. /**
  18937. * Synchronize and normalize current Animatable with a source Animatable
  18938. * This is useful when using animation weights and when animations are not of the same length
  18939. * @param root defines the root Animatable to synchronize with
  18940. * @returns the current Animatable
  18941. */
  18942. syncWith(root: Animatable): Animatable;
  18943. /**
  18944. * Gets the list of runtime animations
  18945. * @returns an array of RuntimeAnimation
  18946. */
  18947. getAnimations(): RuntimeAnimation[];
  18948. /**
  18949. * Adds more animations to the current animatable
  18950. * @param target defines the target of the animations
  18951. * @param animations defines the new animations to add
  18952. */
  18953. appendAnimations(target: any, animations: Animation[]): void;
  18954. /**
  18955. * Gets the source animation for a specific property
  18956. * @param property defines the propertyu to look for
  18957. * @returns null or the source animation for the given property
  18958. */
  18959. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18960. /**
  18961. * Gets the runtime animation for a specific property
  18962. * @param property defines the propertyu to look for
  18963. * @returns null or the runtime animation for the given property
  18964. */
  18965. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18966. /**
  18967. * Resets the animatable to its original state
  18968. */
  18969. reset(): void;
  18970. /**
  18971. * Allows the animatable to blend with current running animations
  18972. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18973. * @param blendingSpeed defines the blending speed to use
  18974. */
  18975. enableBlending(blendingSpeed: number): void;
  18976. /**
  18977. * Disable animation blending
  18978. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18979. */
  18980. disableBlending(): void;
  18981. /**
  18982. * Jump directly to a given frame
  18983. * @param frame defines the frame to jump to
  18984. */
  18985. goToFrame(frame: number): void;
  18986. /**
  18987. * Pause the animation
  18988. */
  18989. pause(): void;
  18990. /**
  18991. * Restart the animation
  18992. */
  18993. restart(): void;
  18994. private _raiseOnAnimationEnd;
  18995. /**
  18996. * Stop and delete the current animation
  18997. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18998. * @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)
  18999. */
  19000. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19001. /**
  19002. * Wait asynchronously for the animation to end
  19003. * @returns a promise which will be fullfilled when the animation ends
  19004. */
  19005. waitAsync(): Promise<Animatable>;
  19006. /** @hidden */
  19007. _animate(delay: number): boolean;
  19008. }
  19009. interface Scene {
  19010. /** @hidden */
  19011. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19012. /** @hidden */
  19013. _processLateAnimationBindingsForMatrices(holder: {
  19014. totalWeight: number;
  19015. animations: RuntimeAnimation[];
  19016. originalValue: Matrix;
  19017. }): any;
  19018. /** @hidden */
  19019. _processLateAnimationBindingsForQuaternions(holder: {
  19020. totalWeight: number;
  19021. animations: RuntimeAnimation[];
  19022. originalValue: Quaternion;
  19023. }, refQuaternion: Quaternion): Quaternion;
  19024. /** @hidden */
  19025. _processLateAnimationBindings(): void;
  19026. /**
  19027. * Will start the animation sequence of a given target
  19028. * @param target defines the target
  19029. * @param from defines from which frame should animation start
  19030. * @param to defines until which frame should animation run.
  19031. * @param weight defines the weight to apply to the animation (1.0 by default)
  19032. * @param loop defines if the animation loops
  19033. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19034. * @param onAnimationEnd defines the function to be executed when the animation ends
  19035. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19036. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19037. * @param onAnimationLoop defines the callback to call when an animation loops
  19038. * @returns the animatable object created for this animation
  19039. */
  19040. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19041. /**
  19042. * Will start the animation sequence of a given target
  19043. * @param target defines the target
  19044. * @param from defines from which frame should animation start
  19045. * @param to defines until which frame should animation run.
  19046. * @param loop defines if the animation loops
  19047. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19048. * @param onAnimationEnd defines the function to be executed when the animation ends
  19049. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19050. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19051. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19052. * @param onAnimationLoop defines the callback to call when an animation loops
  19053. * @returns the animatable object created for this animation
  19054. */
  19055. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19056. /**
  19057. * Will start the animation sequence of a given target and its hierarchy
  19058. * @param target defines the target
  19059. * @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.
  19060. * @param from defines from which frame should animation start
  19061. * @param to defines until which frame should animation run.
  19062. * @param loop defines if the animation loops
  19063. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19064. * @param onAnimationEnd defines the function to be executed when the animation ends
  19065. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19066. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19067. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19068. * @param onAnimationLoop defines the callback to call when an animation loops
  19069. * @returns the list of created animatables
  19070. */
  19071. 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[];
  19072. /**
  19073. * Begin a new animation on a given node
  19074. * @param target defines the target where the animation will take place
  19075. * @param animations defines the list of animations to start
  19076. * @param from defines the initial value
  19077. * @param to defines the final value
  19078. * @param loop defines if you want animation to loop (off by default)
  19079. * @param speedRatio defines the speed ratio to apply to all animations
  19080. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19081. * @param onAnimationLoop defines the callback to call when an animation loops
  19082. * @returns the list of created animatables
  19083. */
  19084. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19085. /**
  19086. * Begin a new animation on a given node and its hierarchy
  19087. * @param target defines the root node where the animation will take place
  19088. * @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.
  19089. * @param animations defines the list of animations to start
  19090. * @param from defines the initial value
  19091. * @param to defines the final value
  19092. * @param loop defines if you want animation to loop (off by default)
  19093. * @param speedRatio defines the speed ratio to apply to all animations
  19094. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19095. * @param onAnimationLoop defines the callback to call when an animation loops
  19096. * @returns the list of animatables created for all nodes
  19097. */
  19098. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19099. /**
  19100. * Gets the animatable associated with a specific target
  19101. * @param target defines the target of the animatable
  19102. * @returns the required animatable if found
  19103. */
  19104. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19105. /**
  19106. * Gets all animatables associated with a given target
  19107. * @param target defines the target to look animatables for
  19108. * @returns an array of Animatables
  19109. */
  19110. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19111. /**
  19112. * Stops and removes all animations that have been applied to the scene
  19113. */
  19114. stopAllAnimations(): void;
  19115. }
  19116. interface Bone {
  19117. /**
  19118. * Copy an animation range from another bone
  19119. * @param source defines the source bone
  19120. * @param rangeName defines the range name to copy
  19121. * @param frameOffset defines the frame offset
  19122. * @param rescaleAsRequired defines if rescaling must be applied if required
  19123. * @param skelDimensionsRatio defines the scaling ratio
  19124. * @returns true if operation was successful
  19125. */
  19126. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19127. }
  19128. }
  19129. declare module BABYLON {
  19130. /**
  19131. * Class used to handle skinning animations
  19132. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19133. */
  19134. export class Skeleton implements IAnimatable {
  19135. /** defines the skeleton name */
  19136. name: string;
  19137. /** defines the skeleton Id */
  19138. id: string;
  19139. /**
  19140. * Defines the list of child bones
  19141. */
  19142. bones: Bone[];
  19143. /**
  19144. * Defines an estimate of the dimension of the skeleton at rest
  19145. */
  19146. dimensionsAtRest: Vector3;
  19147. /**
  19148. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19149. */
  19150. needInitialSkinMatrix: boolean;
  19151. /**
  19152. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19153. */
  19154. overrideMesh: Nullable<AbstractMesh>;
  19155. /**
  19156. * Gets the list of animations attached to this skeleton
  19157. */
  19158. animations: Array<Animation>;
  19159. private _scene;
  19160. private _isDirty;
  19161. private _transformMatrices;
  19162. private _transformMatrixTexture;
  19163. private _meshesWithPoseMatrix;
  19164. private _animatables;
  19165. private _identity;
  19166. private _synchronizedWithMesh;
  19167. private _ranges;
  19168. private _lastAbsoluteTransformsUpdateId;
  19169. private _canUseTextureForBones;
  19170. private _uniqueId;
  19171. /** @hidden */
  19172. _numBonesWithLinkedTransformNode: number;
  19173. /** @hidden */
  19174. _hasWaitingData: Nullable<boolean>;
  19175. /**
  19176. * Specifies if the skeleton should be serialized
  19177. */
  19178. doNotSerialize: boolean;
  19179. private _useTextureToStoreBoneMatrices;
  19180. /**
  19181. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19182. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19183. */
  19184. useTextureToStoreBoneMatrices: boolean;
  19185. private _animationPropertiesOverride;
  19186. /**
  19187. * Gets or sets the animation properties override
  19188. */
  19189. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19190. /**
  19191. * List of inspectable custom properties (used by the Inspector)
  19192. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19193. */
  19194. inspectableCustomProperties: IInspectable[];
  19195. /**
  19196. * An observable triggered before computing the skeleton's matrices
  19197. */
  19198. onBeforeComputeObservable: Observable<Skeleton>;
  19199. /**
  19200. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19201. */
  19202. readonly isUsingTextureForMatrices: boolean;
  19203. /**
  19204. * Gets the unique ID of this skeleton
  19205. */
  19206. readonly uniqueId: number;
  19207. /**
  19208. * Creates a new skeleton
  19209. * @param name defines the skeleton name
  19210. * @param id defines the skeleton Id
  19211. * @param scene defines the hosting scene
  19212. */
  19213. constructor(
  19214. /** defines the skeleton name */
  19215. name: string,
  19216. /** defines the skeleton Id */
  19217. id: string, scene: Scene);
  19218. /**
  19219. * Gets the current object class name.
  19220. * @return the class name
  19221. */
  19222. getClassName(): string;
  19223. /**
  19224. * Returns an array containing the root bones
  19225. * @returns an array containing the root bones
  19226. */
  19227. getChildren(): Array<Bone>;
  19228. /**
  19229. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19230. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19231. * @returns a Float32Array containing matrices data
  19232. */
  19233. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19234. /**
  19235. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19236. * @returns a raw texture containing the data
  19237. */
  19238. getTransformMatrixTexture(): Nullable<RawTexture>;
  19239. /**
  19240. * Gets the current hosting scene
  19241. * @returns a scene object
  19242. */
  19243. getScene(): Scene;
  19244. /**
  19245. * Gets a string representing the current skeleton data
  19246. * @param fullDetails defines a boolean indicating if we want a verbose version
  19247. * @returns a string representing the current skeleton data
  19248. */
  19249. toString(fullDetails?: boolean): string;
  19250. /**
  19251. * Get bone's index searching by name
  19252. * @param name defines bone's name to search for
  19253. * @return the indice of the bone. Returns -1 if not found
  19254. */
  19255. getBoneIndexByName(name: string): number;
  19256. /**
  19257. * Creater a new animation range
  19258. * @param name defines the name of the range
  19259. * @param from defines the start key
  19260. * @param to defines the end key
  19261. */
  19262. createAnimationRange(name: string, from: number, to: number): void;
  19263. /**
  19264. * Delete a specific animation range
  19265. * @param name defines the name of the range
  19266. * @param deleteFrames defines if frames must be removed as well
  19267. */
  19268. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19269. /**
  19270. * Gets a specific animation range
  19271. * @param name defines the name of the range to look for
  19272. * @returns the requested animation range or null if not found
  19273. */
  19274. getAnimationRange(name: string): Nullable<AnimationRange>;
  19275. /**
  19276. * Gets the list of all animation ranges defined on this skeleton
  19277. * @returns an array
  19278. */
  19279. getAnimationRanges(): Nullable<AnimationRange>[];
  19280. /**
  19281. * Copy animation range from a source skeleton.
  19282. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19283. * @param source defines the source skeleton
  19284. * @param name defines the name of the range to copy
  19285. * @param rescaleAsRequired defines if rescaling must be applied if required
  19286. * @returns true if operation was successful
  19287. */
  19288. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19289. /**
  19290. * Forces the skeleton to go to rest pose
  19291. */
  19292. returnToRest(): void;
  19293. private _getHighestAnimationFrame;
  19294. /**
  19295. * Begin a specific animation range
  19296. * @param name defines the name of the range to start
  19297. * @param loop defines if looping must be turned on (false by default)
  19298. * @param speedRatio defines the speed ratio to apply (1 by default)
  19299. * @param onAnimationEnd defines a callback which will be called when animation will end
  19300. * @returns a new animatable
  19301. */
  19302. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19303. /** @hidden */
  19304. _markAsDirty(): void;
  19305. /** @hidden */
  19306. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19307. /** @hidden */
  19308. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19309. private _computeTransformMatrices;
  19310. /**
  19311. * Build all resources required to render a skeleton
  19312. */
  19313. prepare(): void;
  19314. /**
  19315. * Gets the list of animatables currently running for this skeleton
  19316. * @returns an array of animatables
  19317. */
  19318. getAnimatables(): IAnimatable[];
  19319. /**
  19320. * Clone the current skeleton
  19321. * @param name defines the name of the new skeleton
  19322. * @param id defines the id of the new skeleton
  19323. * @returns the new skeleton
  19324. */
  19325. clone(name: string, id: string): Skeleton;
  19326. /**
  19327. * Enable animation blending for this skeleton
  19328. * @param blendingSpeed defines the blending speed to apply
  19329. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19330. */
  19331. enableBlending(blendingSpeed?: number): void;
  19332. /**
  19333. * Releases all resources associated with the current skeleton
  19334. */
  19335. dispose(): void;
  19336. /**
  19337. * Serialize the skeleton in a JSON object
  19338. * @returns a JSON object
  19339. */
  19340. serialize(): any;
  19341. /**
  19342. * Creates a new skeleton from serialized data
  19343. * @param parsedSkeleton defines the serialized data
  19344. * @param scene defines the hosting scene
  19345. * @returns a new skeleton
  19346. */
  19347. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19348. /**
  19349. * Compute all node absolute transforms
  19350. * @param forceUpdate defines if computation must be done even if cache is up to date
  19351. */
  19352. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19353. /**
  19354. * Gets the root pose matrix
  19355. * @returns a matrix
  19356. */
  19357. getPoseMatrix(): Nullable<Matrix>;
  19358. /**
  19359. * Sorts bones per internal index
  19360. */
  19361. sortBones(): void;
  19362. private _sortBones;
  19363. }
  19364. }
  19365. declare module BABYLON {
  19366. /**
  19367. * Defines a target to use with MorphTargetManager
  19368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19369. */
  19370. export class MorphTarget implements IAnimatable {
  19371. /** defines the name of the target */
  19372. name: string;
  19373. /**
  19374. * Gets or sets the list of animations
  19375. */
  19376. animations: Animation[];
  19377. private _scene;
  19378. private _positions;
  19379. private _normals;
  19380. private _tangents;
  19381. private _influence;
  19382. /**
  19383. * Observable raised when the influence changes
  19384. */
  19385. onInfluenceChanged: Observable<boolean>;
  19386. /** @hidden */
  19387. _onDataLayoutChanged: Observable<void>;
  19388. /**
  19389. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19390. */
  19391. influence: number;
  19392. /**
  19393. * Gets or sets the id of the morph Target
  19394. */
  19395. id: string;
  19396. private _animationPropertiesOverride;
  19397. /**
  19398. * Gets or sets the animation properties override
  19399. */
  19400. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19401. /**
  19402. * Creates a new MorphTarget
  19403. * @param name defines the name of the target
  19404. * @param influence defines the influence to use
  19405. * @param scene defines the scene the morphtarget belongs to
  19406. */
  19407. constructor(
  19408. /** defines the name of the target */
  19409. name: string, influence?: number, scene?: Nullable<Scene>);
  19410. /**
  19411. * Gets a boolean defining if the target contains position data
  19412. */
  19413. readonly hasPositions: boolean;
  19414. /**
  19415. * Gets a boolean defining if the target contains normal data
  19416. */
  19417. readonly hasNormals: boolean;
  19418. /**
  19419. * Gets a boolean defining if the target contains tangent data
  19420. */
  19421. readonly hasTangents: boolean;
  19422. /**
  19423. * Affects position data to this target
  19424. * @param data defines the position data to use
  19425. */
  19426. setPositions(data: Nullable<FloatArray>): void;
  19427. /**
  19428. * Gets the position data stored in this target
  19429. * @returns a FloatArray containing the position data (or null if not present)
  19430. */
  19431. getPositions(): Nullable<FloatArray>;
  19432. /**
  19433. * Affects normal data to this target
  19434. * @param data defines the normal data to use
  19435. */
  19436. setNormals(data: Nullable<FloatArray>): void;
  19437. /**
  19438. * Gets the normal data stored in this target
  19439. * @returns a FloatArray containing the normal data (or null if not present)
  19440. */
  19441. getNormals(): Nullable<FloatArray>;
  19442. /**
  19443. * Affects tangent data to this target
  19444. * @param data defines the tangent data to use
  19445. */
  19446. setTangents(data: Nullable<FloatArray>): void;
  19447. /**
  19448. * Gets the tangent data stored in this target
  19449. * @returns a FloatArray containing the tangent data (or null if not present)
  19450. */
  19451. getTangents(): Nullable<FloatArray>;
  19452. /**
  19453. * Serializes the current target into a Serialization object
  19454. * @returns the serialized object
  19455. */
  19456. serialize(): any;
  19457. /**
  19458. * Returns the string "MorphTarget"
  19459. * @returns "MorphTarget"
  19460. */
  19461. getClassName(): string;
  19462. /**
  19463. * Creates a new target from serialized data
  19464. * @param serializationObject defines the serialized data to use
  19465. * @returns a new MorphTarget
  19466. */
  19467. static Parse(serializationObject: any): MorphTarget;
  19468. /**
  19469. * Creates a MorphTarget from mesh data
  19470. * @param mesh defines the source mesh
  19471. * @param name defines the name to use for the new target
  19472. * @param influence defines the influence to attach to the target
  19473. * @returns a new MorphTarget
  19474. */
  19475. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19476. }
  19477. }
  19478. declare module BABYLON {
  19479. /**
  19480. * This class is used to deform meshes using morphing between different targets
  19481. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19482. */
  19483. export class MorphTargetManager {
  19484. private _targets;
  19485. private _targetInfluenceChangedObservers;
  19486. private _targetDataLayoutChangedObservers;
  19487. private _activeTargets;
  19488. private _scene;
  19489. private _influences;
  19490. private _supportsNormals;
  19491. private _supportsTangents;
  19492. private _vertexCount;
  19493. private _uniqueId;
  19494. private _tempInfluences;
  19495. /**
  19496. * Creates a new MorphTargetManager
  19497. * @param scene defines the current scene
  19498. */
  19499. constructor(scene?: Nullable<Scene>);
  19500. /**
  19501. * Gets the unique ID of this manager
  19502. */
  19503. readonly uniqueId: number;
  19504. /**
  19505. * Gets the number of vertices handled by this manager
  19506. */
  19507. readonly vertexCount: number;
  19508. /**
  19509. * Gets a boolean indicating if this manager supports morphing of normals
  19510. */
  19511. readonly supportsNormals: boolean;
  19512. /**
  19513. * Gets a boolean indicating if this manager supports morphing of tangents
  19514. */
  19515. readonly supportsTangents: boolean;
  19516. /**
  19517. * Gets the number of targets stored in this manager
  19518. */
  19519. readonly numTargets: number;
  19520. /**
  19521. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19522. */
  19523. readonly numInfluencers: number;
  19524. /**
  19525. * Gets the list of influences (one per target)
  19526. */
  19527. readonly influences: Float32Array;
  19528. /**
  19529. * Gets the active target at specified index. An active target is a target with an influence > 0
  19530. * @param index defines the index to check
  19531. * @returns the requested target
  19532. */
  19533. getActiveTarget(index: number): MorphTarget;
  19534. /**
  19535. * Gets the target at specified index
  19536. * @param index defines the index to check
  19537. * @returns the requested target
  19538. */
  19539. getTarget(index: number): MorphTarget;
  19540. /**
  19541. * Add a new target to this manager
  19542. * @param target defines the target to add
  19543. */
  19544. addTarget(target: MorphTarget): void;
  19545. /**
  19546. * Removes a target from the manager
  19547. * @param target defines the target to remove
  19548. */
  19549. removeTarget(target: MorphTarget): void;
  19550. /**
  19551. * Serializes the current manager into a Serialization object
  19552. * @returns the serialized object
  19553. */
  19554. serialize(): any;
  19555. private _syncActiveTargets;
  19556. /**
  19557. * Syncrhonize the targets with all the meshes using this morph target manager
  19558. */
  19559. synchronize(): void;
  19560. /**
  19561. * Creates a new MorphTargetManager from serialized data
  19562. * @param serializationObject defines the serialized data
  19563. * @param scene defines the hosting scene
  19564. * @returns the new MorphTargetManager
  19565. */
  19566. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19567. }
  19568. }
  19569. declare module BABYLON {
  19570. /**
  19571. * Class used to represent a specific level of detail of a mesh
  19572. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19573. */
  19574. export class MeshLODLevel {
  19575. /** Defines the distance where this level should star being displayed */
  19576. distance: number;
  19577. /** Defines the mesh to use to render this level */
  19578. mesh: Nullable<Mesh>;
  19579. /**
  19580. * Creates a new LOD level
  19581. * @param distance defines the distance where this level should star being displayed
  19582. * @param mesh defines the mesh to use to render this level
  19583. */
  19584. constructor(
  19585. /** Defines the distance where this level should star being displayed */
  19586. distance: number,
  19587. /** Defines the mesh to use to render this level */
  19588. mesh: Nullable<Mesh>);
  19589. }
  19590. }
  19591. declare module BABYLON {
  19592. /**
  19593. * Mesh representing the gorund
  19594. */
  19595. export class GroundMesh extends Mesh {
  19596. /** If octree should be generated */
  19597. generateOctree: boolean;
  19598. private _heightQuads;
  19599. /** @hidden */
  19600. _subdivisionsX: number;
  19601. /** @hidden */
  19602. _subdivisionsY: number;
  19603. /** @hidden */
  19604. _width: number;
  19605. /** @hidden */
  19606. _height: number;
  19607. /** @hidden */
  19608. _minX: number;
  19609. /** @hidden */
  19610. _maxX: number;
  19611. /** @hidden */
  19612. _minZ: number;
  19613. /** @hidden */
  19614. _maxZ: number;
  19615. constructor(name: string, scene: Scene);
  19616. /**
  19617. * "GroundMesh"
  19618. * @returns "GroundMesh"
  19619. */
  19620. getClassName(): string;
  19621. /**
  19622. * The minimum of x and y subdivisions
  19623. */
  19624. readonly subdivisions: number;
  19625. /**
  19626. * X subdivisions
  19627. */
  19628. readonly subdivisionsX: number;
  19629. /**
  19630. * Y subdivisions
  19631. */
  19632. readonly subdivisionsY: number;
  19633. /**
  19634. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19635. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19636. * @param chunksCount the number of subdivisions for x and y
  19637. * @param octreeBlocksSize (Default: 32)
  19638. */
  19639. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19640. /**
  19641. * Returns a height (y) value in the Worl system :
  19642. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19643. * @param x x coordinate
  19644. * @param z z coordinate
  19645. * @returns the ground y position if (x, z) are outside the ground surface.
  19646. */
  19647. getHeightAtCoordinates(x: number, z: number): number;
  19648. /**
  19649. * Returns a normalized vector (Vector3) orthogonal to the ground
  19650. * at the ground coordinates (x, z) expressed in the World system.
  19651. * @param x x coordinate
  19652. * @param z z coordinate
  19653. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19654. */
  19655. getNormalAtCoordinates(x: number, z: number): Vector3;
  19656. /**
  19657. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19658. * at the ground coordinates (x, z) expressed in the World system.
  19659. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19660. * @param x x coordinate
  19661. * @param z z coordinate
  19662. * @param ref vector to store the result
  19663. * @returns the GroundMesh.
  19664. */
  19665. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19666. /**
  19667. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19668. * if the ground has been updated.
  19669. * This can be used in the render loop.
  19670. * @returns the GroundMesh.
  19671. */
  19672. updateCoordinateHeights(): GroundMesh;
  19673. private _getFacetAt;
  19674. private _initHeightQuads;
  19675. private _computeHeightQuads;
  19676. /**
  19677. * Serializes this ground mesh
  19678. * @param serializationObject object to write serialization to
  19679. */
  19680. serialize(serializationObject: any): void;
  19681. /**
  19682. * Parses a serialized ground mesh
  19683. * @param parsedMesh the serialized mesh
  19684. * @param scene the scene to create the ground mesh in
  19685. * @returns the created ground mesh
  19686. */
  19687. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19688. }
  19689. }
  19690. declare module BABYLON {
  19691. /**
  19692. * Interface for Physics-Joint data
  19693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19694. */
  19695. export interface PhysicsJointData {
  19696. /**
  19697. * The main pivot of the joint
  19698. */
  19699. mainPivot?: Vector3;
  19700. /**
  19701. * The connected pivot of the joint
  19702. */
  19703. connectedPivot?: Vector3;
  19704. /**
  19705. * The main axis of the joint
  19706. */
  19707. mainAxis?: Vector3;
  19708. /**
  19709. * The connected axis of the joint
  19710. */
  19711. connectedAxis?: Vector3;
  19712. /**
  19713. * The collision of the joint
  19714. */
  19715. collision?: boolean;
  19716. /**
  19717. * Native Oimo/Cannon/Energy data
  19718. */
  19719. nativeParams?: any;
  19720. }
  19721. /**
  19722. * This is a holder class for the physics joint created by the physics plugin
  19723. * It holds a set of functions to control the underlying joint
  19724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19725. */
  19726. export class PhysicsJoint {
  19727. /**
  19728. * The type of the physics joint
  19729. */
  19730. type: number;
  19731. /**
  19732. * The data for the physics joint
  19733. */
  19734. jointData: PhysicsJointData;
  19735. private _physicsJoint;
  19736. protected _physicsPlugin: IPhysicsEnginePlugin;
  19737. /**
  19738. * Initializes the physics joint
  19739. * @param type The type of the physics joint
  19740. * @param jointData The data for the physics joint
  19741. */
  19742. constructor(
  19743. /**
  19744. * The type of the physics joint
  19745. */
  19746. type: number,
  19747. /**
  19748. * The data for the physics joint
  19749. */
  19750. jointData: PhysicsJointData);
  19751. /**
  19752. * Gets the physics joint
  19753. */
  19754. /**
  19755. * Sets the physics joint
  19756. */
  19757. physicsJoint: any;
  19758. /**
  19759. * Sets the physics plugin
  19760. */
  19761. physicsPlugin: IPhysicsEnginePlugin;
  19762. /**
  19763. * Execute a function that is physics-plugin specific.
  19764. * @param {Function} func the function that will be executed.
  19765. * It accepts two parameters: the physics world and the physics joint
  19766. */
  19767. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19768. /**
  19769. * Distance-Joint type
  19770. */
  19771. static DistanceJoint: number;
  19772. /**
  19773. * Hinge-Joint type
  19774. */
  19775. static HingeJoint: number;
  19776. /**
  19777. * Ball-and-Socket joint type
  19778. */
  19779. static BallAndSocketJoint: number;
  19780. /**
  19781. * Wheel-Joint type
  19782. */
  19783. static WheelJoint: number;
  19784. /**
  19785. * Slider-Joint type
  19786. */
  19787. static SliderJoint: number;
  19788. /**
  19789. * Prismatic-Joint type
  19790. */
  19791. static PrismaticJoint: number;
  19792. /**
  19793. * Universal-Joint type
  19794. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19795. */
  19796. static UniversalJoint: number;
  19797. /**
  19798. * Hinge-Joint 2 type
  19799. */
  19800. static Hinge2Joint: number;
  19801. /**
  19802. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19803. */
  19804. static PointToPointJoint: number;
  19805. /**
  19806. * Spring-Joint type
  19807. */
  19808. static SpringJoint: number;
  19809. /**
  19810. * Lock-Joint type
  19811. */
  19812. static LockJoint: number;
  19813. }
  19814. /**
  19815. * A class representing a physics distance joint
  19816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19817. */
  19818. export class DistanceJoint extends PhysicsJoint {
  19819. /**
  19820. *
  19821. * @param jointData The data for the Distance-Joint
  19822. */
  19823. constructor(jointData: DistanceJointData);
  19824. /**
  19825. * Update the predefined distance.
  19826. * @param maxDistance The maximum preferred distance
  19827. * @param minDistance The minimum preferred distance
  19828. */
  19829. updateDistance(maxDistance: number, minDistance?: number): void;
  19830. }
  19831. /**
  19832. * Represents a Motor-Enabled Joint
  19833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19834. */
  19835. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19836. /**
  19837. * Initializes the Motor-Enabled Joint
  19838. * @param type The type of the joint
  19839. * @param jointData The physica joint data for the joint
  19840. */
  19841. constructor(type: number, jointData: PhysicsJointData);
  19842. /**
  19843. * Set the motor values.
  19844. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19845. * @param force the force to apply
  19846. * @param maxForce max force for this motor.
  19847. */
  19848. setMotor(force?: number, maxForce?: number): void;
  19849. /**
  19850. * Set the motor's limits.
  19851. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19852. * @param upperLimit The upper limit of the motor
  19853. * @param lowerLimit The lower limit of the motor
  19854. */
  19855. setLimit(upperLimit: number, lowerLimit?: number): void;
  19856. }
  19857. /**
  19858. * This class represents a single physics Hinge-Joint
  19859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19860. */
  19861. export class HingeJoint extends MotorEnabledJoint {
  19862. /**
  19863. * Initializes the Hinge-Joint
  19864. * @param jointData The joint data for the Hinge-Joint
  19865. */
  19866. constructor(jointData: PhysicsJointData);
  19867. /**
  19868. * Set the motor values.
  19869. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19870. * @param {number} force the force to apply
  19871. * @param {number} maxForce max force for this motor.
  19872. */
  19873. setMotor(force?: number, maxForce?: number): void;
  19874. /**
  19875. * Set the motor's limits.
  19876. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19877. * @param upperLimit The upper limit of the motor
  19878. * @param lowerLimit The lower limit of the motor
  19879. */
  19880. setLimit(upperLimit: number, lowerLimit?: number): void;
  19881. }
  19882. /**
  19883. * This class represents a dual hinge physics joint (same as wheel joint)
  19884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19885. */
  19886. export class Hinge2Joint extends MotorEnabledJoint {
  19887. /**
  19888. * Initializes the Hinge2-Joint
  19889. * @param jointData The joint data for the Hinge2-Joint
  19890. */
  19891. constructor(jointData: PhysicsJointData);
  19892. /**
  19893. * Set the motor values.
  19894. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19895. * @param {number} targetSpeed the speed the motor is to reach
  19896. * @param {number} maxForce max force for this motor.
  19897. * @param {motorIndex} the motor's index, 0 or 1.
  19898. */
  19899. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19900. /**
  19901. * Set the motor limits.
  19902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19903. * @param {number} upperLimit the upper limit
  19904. * @param {number} lowerLimit lower limit
  19905. * @param {motorIndex} the motor's index, 0 or 1.
  19906. */
  19907. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19908. }
  19909. /**
  19910. * Interface for a motor enabled joint
  19911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19912. */
  19913. export interface IMotorEnabledJoint {
  19914. /**
  19915. * Physics joint
  19916. */
  19917. physicsJoint: any;
  19918. /**
  19919. * Sets the motor of the motor-enabled joint
  19920. * @param force The force of the motor
  19921. * @param maxForce The maximum force of the motor
  19922. * @param motorIndex The index of the motor
  19923. */
  19924. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19925. /**
  19926. * Sets the limit of the motor
  19927. * @param upperLimit The upper limit of the motor
  19928. * @param lowerLimit The lower limit of the motor
  19929. * @param motorIndex The index of the motor
  19930. */
  19931. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19932. }
  19933. /**
  19934. * Joint data for a Distance-Joint
  19935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19936. */
  19937. export interface DistanceJointData extends PhysicsJointData {
  19938. /**
  19939. * Max distance the 2 joint objects can be apart
  19940. */
  19941. maxDistance: number;
  19942. }
  19943. /**
  19944. * Joint data from a spring joint
  19945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19946. */
  19947. export interface SpringJointData extends PhysicsJointData {
  19948. /**
  19949. * Length of the spring
  19950. */
  19951. length: number;
  19952. /**
  19953. * Stiffness of the spring
  19954. */
  19955. stiffness: number;
  19956. /**
  19957. * Damping of the spring
  19958. */
  19959. damping: number;
  19960. /** this callback will be called when applying the force to the impostors. */
  19961. forceApplicationCallback: () => void;
  19962. }
  19963. }
  19964. declare module BABYLON {
  19965. /**
  19966. * Holds the data for the raycast result
  19967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19968. */
  19969. export class PhysicsRaycastResult {
  19970. private _hasHit;
  19971. private _hitDistance;
  19972. private _hitNormalWorld;
  19973. private _hitPointWorld;
  19974. private _rayFromWorld;
  19975. private _rayToWorld;
  19976. /**
  19977. * Gets if there was a hit
  19978. */
  19979. readonly hasHit: boolean;
  19980. /**
  19981. * Gets the distance from the hit
  19982. */
  19983. readonly hitDistance: number;
  19984. /**
  19985. * Gets the hit normal/direction in the world
  19986. */
  19987. readonly hitNormalWorld: Vector3;
  19988. /**
  19989. * Gets the hit point in the world
  19990. */
  19991. readonly hitPointWorld: Vector3;
  19992. /**
  19993. * Gets the ray "start point" of the ray in the world
  19994. */
  19995. readonly rayFromWorld: Vector3;
  19996. /**
  19997. * Gets the ray "end point" of the ray in the world
  19998. */
  19999. readonly rayToWorld: Vector3;
  20000. /**
  20001. * Sets the hit data (normal & point in world space)
  20002. * @param hitNormalWorld defines the normal in world space
  20003. * @param hitPointWorld defines the point in world space
  20004. */
  20005. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20006. /**
  20007. * Sets the distance from the start point to the hit point
  20008. * @param distance
  20009. */
  20010. setHitDistance(distance: number): void;
  20011. /**
  20012. * Calculates the distance manually
  20013. */
  20014. calculateHitDistance(): void;
  20015. /**
  20016. * Resets all the values to default
  20017. * @param from The from point on world space
  20018. * @param to The to point on world space
  20019. */
  20020. reset(from?: Vector3, to?: Vector3): void;
  20021. }
  20022. /**
  20023. * Interface for the size containing width and height
  20024. */
  20025. interface IXYZ {
  20026. /**
  20027. * X
  20028. */
  20029. x: number;
  20030. /**
  20031. * Y
  20032. */
  20033. y: number;
  20034. /**
  20035. * Z
  20036. */
  20037. z: number;
  20038. }
  20039. }
  20040. declare module BABYLON {
  20041. /**
  20042. * Interface used to describe a physics joint
  20043. */
  20044. export interface PhysicsImpostorJoint {
  20045. /** Defines the main impostor to which the joint is linked */
  20046. mainImpostor: PhysicsImpostor;
  20047. /** Defines the impostor that is connected to the main impostor using this joint */
  20048. connectedImpostor: PhysicsImpostor;
  20049. /** Defines the joint itself */
  20050. joint: PhysicsJoint;
  20051. }
  20052. /** @hidden */
  20053. export interface IPhysicsEnginePlugin {
  20054. world: any;
  20055. name: string;
  20056. setGravity(gravity: Vector3): void;
  20057. setTimeStep(timeStep: number): void;
  20058. getTimeStep(): number;
  20059. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20060. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20061. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20062. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20063. removePhysicsBody(impostor: PhysicsImpostor): void;
  20064. generateJoint(joint: PhysicsImpostorJoint): void;
  20065. removeJoint(joint: PhysicsImpostorJoint): void;
  20066. isSupported(): boolean;
  20067. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20068. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20069. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20070. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20071. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20072. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20073. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20074. getBodyMass(impostor: PhysicsImpostor): number;
  20075. getBodyFriction(impostor: PhysicsImpostor): number;
  20076. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20077. getBodyRestitution(impostor: PhysicsImpostor): number;
  20078. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20079. getBodyPressure?(impostor: PhysicsImpostor): number;
  20080. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20081. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20082. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20083. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20084. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20085. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20086. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20087. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20088. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20089. sleepBody(impostor: PhysicsImpostor): void;
  20090. wakeUpBody(impostor: PhysicsImpostor): void;
  20091. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20092. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20093. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20094. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20095. getRadius(impostor: PhysicsImpostor): number;
  20096. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20097. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20098. dispose(): void;
  20099. }
  20100. /**
  20101. * Interface used to define a physics engine
  20102. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20103. */
  20104. export interface IPhysicsEngine {
  20105. /**
  20106. * Gets the gravity vector used by the simulation
  20107. */
  20108. gravity: Vector3;
  20109. /**
  20110. * Sets the gravity vector used by the simulation
  20111. * @param gravity defines the gravity vector to use
  20112. */
  20113. setGravity(gravity: Vector3): void;
  20114. /**
  20115. * Set the time step of the physics engine.
  20116. * Default is 1/60.
  20117. * To slow it down, enter 1/600 for example.
  20118. * To speed it up, 1/30
  20119. * @param newTimeStep the new timestep to apply to this world.
  20120. */
  20121. setTimeStep(newTimeStep: number): void;
  20122. /**
  20123. * Get the time step of the physics engine.
  20124. * @returns the current time step
  20125. */
  20126. getTimeStep(): number;
  20127. /**
  20128. * Release all resources
  20129. */
  20130. dispose(): void;
  20131. /**
  20132. * Gets the name of the current physics plugin
  20133. * @returns the name of the plugin
  20134. */
  20135. getPhysicsPluginName(): string;
  20136. /**
  20137. * Adding a new impostor for the impostor tracking.
  20138. * This will be done by the impostor itself.
  20139. * @param impostor the impostor to add
  20140. */
  20141. addImpostor(impostor: PhysicsImpostor): void;
  20142. /**
  20143. * Remove an impostor from the engine.
  20144. * This impostor and its mesh will not longer be updated by the physics engine.
  20145. * @param impostor the impostor to remove
  20146. */
  20147. removeImpostor(impostor: PhysicsImpostor): void;
  20148. /**
  20149. * Add a joint to the physics engine
  20150. * @param mainImpostor defines the main impostor to which the joint is added.
  20151. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20152. * @param joint defines the joint that will connect both impostors.
  20153. */
  20154. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20155. /**
  20156. * Removes a joint from the simulation
  20157. * @param mainImpostor defines the impostor used with the joint
  20158. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20159. * @param joint defines the joint to remove
  20160. */
  20161. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20162. /**
  20163. * Gets the current plugin used to run the simulation
  20164. * @returns current plugin
  20165. */
  20166. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20167. /**
  20168. * Gets the list of physic impostors
  20169. * @returns an array of PhysicsImpostor
  20170. */
  20171. getImpostors(): Array<PhysicsImpostor>;
  20172. /**
  20173. * Gets the impostor for a physics enabled object
  20174. * @param object defines the object impersonated by the impostor
  20175. * @returns the PhysicsImpostor or null if not found
  20176. */
  20177. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20178. /**
  20179. * Gets the impostor for a physics body object
  20180. * @param body defines physics body used by the impostor
  20181. * @returns the PhysicsImpostor or null if not found
  20182. */
  20183. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20184. /**
  20185. * Does a raycast in the physics world
  20186. * @param from when should the ray start?
  20187. * @param to when should the ray end?
  20188. * @returns PhysicsRaycastResult
  20189. */
  20190. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20191. /**
  20192. * Called by the scene. No need to call it.
  20193. * @param delta defines the timespam between frames
  20194. */
  20195. _step(delta: number): void;
  20196. }
  20197. }
  20198. declare module BABYLON {
  20199. /**
  20200. * The interface for the physics imposter parameters
  20201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20202. */
  20203. export interface PhysicsImpostorParameters {
  20204. /**
  20205. * The mass of the physics imposter
  20206. */
  20207. mass: number;
  20208. /**
  20209. * The friction of the physics imposter
  20210. */
  20211. friction?: number;
  20212. /**
  20213. * The coefficient of restitution of the physics imposter
  20214. */
  20215. restitution?: number;
  20216. /**
  20217. * The native options of the physics imposter
  20218. */
  20219. nativeOptions?: any;
  20220. /**
  20221. * Specifies if the parent should be ignored
  20222. */
  20223. ignoreParent?: boolean;
  20224. /**
  20225. * Specifies if bi-directional transformations should be disabled
  20226. */
  20227. disableBidirectionalTransformation?: boolean;
  20228. /**
  20229. * The pressure inside the physics imposter, soft object only
  20230. */
  20231. pressure?: number;
  20232. /**
  20233. * The stiffness the physics imposter, soft object only
  20234. */
  20235. stiffness?: number;
  20236. /**
  20237. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20238. */
  20239. velocityIterations?: number;
  20240. /**
  20241. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20242. */
  20243. positionIterations?: number;
  20244. /**
  20245. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20246. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20247. * Add to fix multiple points
  20248. */
  20249. fixedPoints?: number;
  20250. /**
  20251. * The collision margin around a soft object
  20252. */
  20253. margin?: number;
  20254. /**
  20255. * The collision margin around a soft object
  20256. */
  20257. damping?: number;
  20258. /**
  20259. * The path for a rope based on an extrusion
  20260. */
  20261. path?: any;
  20262. /**
  20263. * The shape of an extrusion used for a rope based on an extrusion
  20264. */
  20265. shape?: any;
  20266. }
  20267. /**
  20268. * Interface for a physics-enabled object
  20269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20270. */
  20271. export interface IPhysicsEnabledObject {
  20272. /**
  20273. * The position of the physics-enabled object
  20274. */
  20275. position: Vector3;
  20276. /**
  20277. * The rotation of the physics-enabled object
  20278. */
  20279. rotationQuaternion: Nullable<Quaternion>;
  20280. /**
  20281. * The scale of the physics-enabled object
  20282. */
  20283. scaling: Vector3;
  20284. /**
  20285. * The rotation of the physics-enabled object
  20286. */
  20287. rotation?: Vector3;
  20288. /**
  20289. * The parent of the physics-enabled object
  20290. */
  20291. parent?: any;
  20292. /**
  20293. * The bounding info of the physics-enabled object
  20294. * @returns The bounding info of the physics-enabled object
  20295. */
  20296. getBoundingInfo(): BoundingInfo;
  20297. /**
  20298. * Computes the world matrix
  20299. * @param force Specifies if the world matrix should be computed by force
  20300. * @returns A world matrix
  20301. */
  20302. computeWorldMatrix(force: boolean): Matrix;
  20303. /**
  20304. * Gets the world matrix
  20305. * @returns A world matrix
  20306. */
  20307. getWorldMatrix?(): Matrix;
  20308. /**
  20309. * Gets the child meshes
  20310. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20311. * @returns An array of abstract meshes
  20312. */
  20313. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20314. /**
  20315. * Gets the vertex data
  20316. * @param kind The type of vertex data
  20317. * @returns A nullable array of numbers, or a float32 array
  20318. */
  20319. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20320. /**
  20321. * Gets the indices from the mesh
  20322. * @returns A nullable array of index arrays
  20323. */
  20324. getIndices?(): Nullable<IndicesArray>;
  20325. /**
  20326. * Gets the scene from the mesh
  20327. * @returns the indices array or null
  20328. */
  20329. getScene?(): Scene;
  20330. /**
  20331. * Gets the absolute position from the mesh
  20332. * @returns the absolute position
  20333. */
  20334. getAbsolutePosition(): Vector3;
  20335. /**
  20336. * Gets the absolute pivot point from the mesh
  20337. * @returns the absolute pivot point
  20338. */
  20339. getAbsolutePivotPoint(): Vector3;
  20340. /**
  20341. * Rotates the mesh
  20342. * @param axis The axis of rotation
  20343. * @param amount The amount of rotation
  20344. * @param space The space of the rotation
  20345. * @returns The rotation transform node
  20346. */
  20347. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20348. /**
  20349. * Translates the mesh
  20350. * @param axis The axis of translation
  20351. * @param distance The distance of translation
  20352. * @param space The space of the translation
  20353. * @returns The transform node
  20354. */
  20355. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20356. /**
  20357. * Sets the absolute position of the mesh
  20358. * @param absolutePosition The absolute position of the mesh
  20359. * @returns The transform node
  20360. */
  20361. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20362. /**
  20363. * Gets the class name of the mesh
  20364. * @returns The class name
  20365. */
  20366. getClassName(): string;
  20367. }
  20368. /**
  20369. * Represents a physics imposter
  20370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20371. */
  20372. export class PhysicsImpostor {
  20373. /**
  20374. * The physics-enabled object used as the physics imposter
  20375. */
  20376. object: IPhysicsEnabledObject;
  20377. /**
  20378. * The type of the physics imposter
  20379. */
  20380. type: number;
  20381. private _options;
  20382. private _scene?;
  20383. /**
  20384. * The default object size of the imposter
  20385. */
  20386. static DEFAULT_OBJECT_SIZE: Vector3;
  20387. /**
  20388. * The identity quaternion of the imposter
  20389. */
  20390. static IDENTITY_QUATERNION: Quaternion;
  20391. /** @hidden */
  20392. _pluginData: any;
  20393. private _physicsEngine;
  20394. private _physicsBody;
  20395. private _bodyUpdateRequired;
  20396. private _onBeforePhysicsStepCallbacks;
  20397. private _onAfterPhysicsStepCallbacks;
  20398. /** @hidden */
  20399. _onPhysicsCollideCallbacks: Array<{
  20400. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20401. otherImpostors: Array<PhysicsImpostor>;
  20402. }>;
  20403. private _deltaPosition;
  20404. private _deltaRotation;
  20405. private _deltaRotationConjugated;
  20406. /** hidden */
  20407. _isFromLine: boolean;
  20408. private _parent;
  20409. private _isDisposed;
  20410. private static _tmpVecs;
  20411. private static _tmpQuat;
  20412. /**
  20413. * Specifies if the physics imposter is disposed
  20414. */
  20415. readonly isDisposed: boolean;
  20416. /**
  20417. * Gets the mass of the physics imposter
  20418. */
  20419. mass: number;
  20420. /**
  20421. * Gets the coefficient of friction
  20422. */
  20423. /**
  20424. * Sets the coefficient of friction
  20425. */
  20426. friction: number;
  20427. /**
  20428. * Gets the coefficient of restitution
  20429. */
  20430. /**
  20431. * Sets the coefficient of restitution
  20432. */
  20433. restitution: number;
  20434. /**
  20435. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20436. */
  20437. /**
  20438. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20439. */
  20440. pressure: number;
  20441. /**
  20442. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20443. */
  20444. /**
  20445. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20446. */
  20447. stiffness: number;
  20448. /**
  20449. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20450. */
  20451. /**
  20452. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20453. */
  20454. velocityIterations: number;
  20455. /**
  20456. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20457. */
  20458. /**
  20459. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20460. */
  20461. positionIterations: number;
  20462. /**
  20463. * The unique id of the physics imposter
  20464. * set by the physics engine when adding this impostor to the array
  20465. */
  20466. uniqueId: number;
  20467. /**
  20468. * @hidden
  20469. */
  20470. soft: boolean;
  20471. /**
  20472. * @hidden
  20473. */
  20474. segments: number;
  20475. private _joints;
  20476. /**
  20477. * Initializes the physics imposter
  20478. * @param object The physics-enabled object used as the physics imposter
  20479. * @param type The type of the physics imposter
  20480. * @param _options The options for the physics imposter
  20481. * @param _scene The Babylon scene
  20482. */
  20483. constructor(
  20484. /**
  20485. * The physics-enabled object used as the physics imposter
  20486. */
  20487. object: IPhysicsEnabledObject,
  20488. /**
  20489. * The type of the physics imposter
  20490. */
  20491. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20492. /**
  20493. * This function will completly initialize this impostor.
  20494. * It will create a new body - but only if this mesh has no parent.
  20495. * If it has, this impostor will not be used other than to define the impostor
  20496. * of the child mesh.
  20497. * @hidden
  20498. */
  20499. _init(): void;
  20500. private _getPhysicsParent;
  20501. /**
  20502. * Should a new body be generated.
  20503. * @returns boolean specifying if body initialization is required
  20504. */
  20505. isBodyInitRequired(): boolean;
  20506. /**
  20507. * Sets the updated scaling
  20508. * @param updated Specifies if the scaling is updated
  20509. */
  20510. setScalingUpdated(): void;
  20511. /**
  20512. * Force a regeneration of this or the parent's impostor's body.
  20513. * Use under cautious - This will remove all joints already implemented.
  20514. */
  20515. forceUpdate(): void;
  20516. /**
  20517. * Gets the body that holds this impostor. Either its own, or its parent.
  20518. */
  20519. /**
  20520. * Set the physics body. Used mainly by the physics engine/plugin
  20521. */
  20522. physicsBody: any;
  20523. /**
  20524. * Get the parent of the physics imposter
  20525. * @returns Physics imposter or null
  20526. */
  20527. /**
  20528. * Sets the parent of the physics imposter
  20529. */
  20530. parent: Nullable<PhysicsImpostor>;
  20531. /**
  20532. * Resets the update flags
  20533. */
  20534. resetUpdateFlags(): void;
  20535. /**
  20536. * Gets the object extend size
  20537. * @returns the object extend size
  20538. */
  20539. getObjectExtendSize(): Vector3;
  20540. /**
  20541. * Gets the object center
  20542. * @returns The object center
  20543. */
  20544. getObjectCenter(): Vector3;
  20545. /**
  20546. * Get a specific parametes from the options parameter
  20547. * @param paramName The object parameter name
  20548. * @returns The object parameter
  20549. */
  20550. getParam(paramName: string): any;
  20551. /**
  20552. * Sets a specific parameter in the options given to the physics plugin
  20553. * @param paramName The parameter name
  20554. * @param value The value of the parameter
  20555. */
  20556. setParam(paramName: string, value: number): void;
  20557. /**
  20558. * Specifically change the body's mass option. Won't recreate the physics body object
  20559. * @param mass The mass of the physics imposter
  20560. */
  20561. setMass(mass: number): void;
  20562. /**
  20563. * Gets the linear velocity
  20564. * @returns linear velocity or null
  20565. */
  20566. getLinearVelocity(): Nullable<Vector3>;
  20567. /**
  20568. * Sets the linear velocity
  20569. * @param velocity linear velocity or null
  20570. */
  20571. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20572. /**
  20573. * Gets the angular velocity
  20574. * @returns angular velocity or null
  20575. */
  20576. getAngularVelocity(): Nullable<Vector3>;
  20577. /**
  20578. * Sets the angular velocity
  20579. * @param velocity The velocity or null
  20580. */
  20581. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20582. /**
  20583. * Execute a function with the physics plugin native code
  20584. * Provide a function the will have two variables - the world object and the physics body object
  20585. * @param func The function to execute with the physics plugin native code
  20586. */
  20587. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20588. /**
  20589. * Register a function that will be executed before the physics world is stepping forward
  20590. * @param func The function to execute before the physics world is stepped forward
  20591. */
  20592. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20593. /**
  20594. * Unregister a function that will be executed before the physics world is stepping forward
  20595. * @param func The function to execute before the physics world is stepped forward
  20596. */
  20597. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20598. /**
  20599. * Register a function that will be executed after the physics step
  20600. * @param func The function to execute after physics step
  20601. */
  20602. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20603. /**
  20604. * Unregisters a function that will be executed after the physics step
  20605. * @param func The function to execute after physics step
  20606. */
  20607. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20608. /**
  20609. * register a function that will be executed when this impostor collides against a different body
  20610. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20611. * @param func Callback that is executed on collision
  20612. */
  20613. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20614. /**
  20615. * Unregisters the physics imposter on contact
  20616. * @param collideAgainst The physics object to collide against
  20617. * @param func Callback to execute on collision
  20618. */
  20619. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20620. private _tmpQuat;
  20621. private _tmpQuat2;
  20622. /**
  20623. * Get the parent rotation
  20624. * @returns The parent rotation
  20625. */
  20626. getParentsRotation(): Quaternion;
  20627. /**
  20628. * this function is executed by the physics engine.
  20629. */
  20630. beforeStep: () => void;
  20631. /**
  20632. * this function is executed by the physics engine
  20633. */
  20634. afterStep: () => void;
  20635. /**
  20636. * Legacy collision detection event support
  20637. */
  20638. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20639. /**
  20640. * event and body object due to cannon's event-based architecture.
  20641. */
  20642. onCollide: (e: {
  20643. body: any;
  20644. }) => void;
  20645. /**
  20646. * Apply a force
  20647. * @param force The force to apply
  20648. * @param contactPoint The contact point for the force
  20649. * @returns The physics imposter
  20650. */
  20651. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20652. /**
  20653. * Apply an impulse
  20654. * @param force The impulse force
  20655. * @param contactPoint The contact point for the impulse force
  20656. * @returns The physics imposter
  20657. */
  20658. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20659. /**
  20660. * A help function to create a joint
  20661. * @param otherImpostor A physics imposter used to create a joint
  20662. * @param jointType The type of joint
  20663. * @param jointData The data for the joint
  20664. * @returns The physics imposter
  20665. */
  20666. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20667. /**
  20668. * Add a joint to this impostor with a different impostor
  20669. * @param otherImpostor A physics imposter used to add a joint
  20670. * @param joint The joint to add
  20671. * @returns The physics imposter
  20672. */
  20673. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20674. /**
  20675. * Add an anchor to a cloth impostor
  20676. * @param otherImpostor rigid impostor to anchor to
  20677. * @param width ratio across width from 0 to 1
  20678. * @param height ratio up height from 0 to 1
  20679. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20680. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20681. * @returns impostor the soft imposter
  20682. */
  20683. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20684. /**
  20685. * Add a hook to a rope impostor
  20686. * @param otherImpostor rigid impostor to anchor to
  20687. * @param length ratio across rope from 0 to 1
  20688. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20689. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20690. * @returns impostor the rope imposter
  20691. */
  20692. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20693. /**
  20694. * Will keep this body still, in a sleep mode.
  20695. * @returns the physics imposter
  20696. */
  20697. sleep(): PhysicsImpostor;
  20698. /**
  20699. * Wake the body up.
  20700. * @returns The physics imposter
  20701. */
  20702. wakeUp(): PhysicsImpostor;
  20703. /**
  20704. * Clones the physics imposter
  20705. * @param newObject The physics imposter clones to this physics-enabled object
  20706. * @returns A nullable physics imposter
  20707. */
  20708. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20709. /**
  20710. * Disposes the physics imposter
  20711. */
  20712. dispose(): void;
  20713. /**
  20714. * Sets the delta position
  20715. * @param position The delta position amount
  20716. */
  20717. setDeltaPosition(position: Vector3): void;
  20718. /**
  20719. * Sets the delta rotation
  20720. * @param rotation The delta rotation amount
  20721. */
  20722. setDeltaRotation(rotation: Quaternion): void;
  20723. /**
  20724. * Gets the box size of the physics imposter and stores the result in the input parameter
  20725. * @param result Stores the box size
  20726. * @returns The physics imposter
  20727. */
  20728. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20729. /**
  20730. * Gets the radius of the physics imposter
  20731. * @returns Radius of the physics imposter
  20732. */
  20733. getRadius(): number;
  20734. /**
  20735. * Sync a bone with this impostor
  20736. * @param bone The bone to sync to the impostor.
  20737. * @param boneMesh The mesh that the bone is influencing.
  20738. * @param jointPivot The pivot of the joint / bone in local space.
  20739. * @param distToJoint Optional distance from the impostor to the joint.
  20740. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20741. */
  20742. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20743. /**
  20744. * Sync impostor to a bone
  20745. * @param bone The bone that the impostor will be synced to.
  20746. * @param boneMesh The mesh that the bone is influencing.
  20747. * @param jointPivot The pivot of the joint / bone in local space.
  20748. * @param distToJoint Optional distance from the impostor to the joint.
  20749. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20750. * @param boneAxis Optional vector3 axis the bone is aligned with
  20751. */
  20752. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20753. /**
  20754. * No-Imposter type
  20755. */
  20756. static NoImpostor: number;
  20757. /**
  20758. * Sphere-Imposter type
  20759. */
  20760. static SphereImpostor: number;
  20761. /**
  20762. * Box-Imposter type
  20763. */
  20764. static BoxImpostor: number;
  20765. /**
  20766. * Plane-Imposter type
  20767. */
  20768. static PlaneImpostor: number;
  20769. /**
  20770. * Mesh-imposter type
  20771. */
  20772. static MeshImpostor: number;
  20773. /**
  20774. * Cylinder-Imposter type
  20775. */
  20776. static CylinderImpostor: number;
  20777. /**
  20778. * Particle-Imposter type
  20779. */
  20780. static ParticleImpostor: number;
  20781. /**
  20782. * Heightmap-Imposter type
  20783. */
  20784. static HeightmapImpostor: number;
  20785. /**
  20786. * ConvexHull-Impostor type (Ammo.js plugin only)
  20787. */
  20788. static ConvexHullImpostor: number;
  20789. /**
  20790. * Rope-Imposter type
  20791. */
  20792. static RopeImpostor: number;
  20793. /**
  20794. * Cloth-Imposter type
  20795. */
  20796. static ClothImpostor: number;
  20797. /**
  20798. * Softbody-Imposter type
  20799. */
  20800. static SoftbodyImpostor: number;
  20801. }
  20802. }
  20803. declare module BABYLON {
  20804. /**
  20805. * @hidden
  20806. **/
  20807. export class _CreationDataStorage {
  20808. closePath?: boolean;
  20809. closeArray?: boolean;
  20810. idx: number[];
  20811. dashSize: number;
  20812. gapSize: number;
  20813. path3D: Path3D;
  20814. pathArray: Vector3[][];
  20815. arc: number;
  20816. radius: number;
  20817. cap: number;
  20818. tessellation: number;
  20819. }
  20820. /**
  20821. * @hidden
  20822. **/
  20823. class _InstanceDataStorage {
  20824. visibleInstances: any;
  20825. batchCache: _InstancesBatch;
  20826. instancesBufferSize: number;
  20827. instancesBuffer: Nullable<Buffer>;
  20828. instancesData: Float32Array;
  20829. overridenInstanceCount: number;
  20830. isFrozen: boolean;
  20831. previousBatch: _InstancesBatch;
  20832. hardwareInstancedRendering: boolean;
  20833. sideOrientation: number;
  20834. }
  20835. /**
  20836. * @hidden
  20837. **/
  20838. export class _InstancesBatch {
  20839. mustReturn: boolean;
  20840. visibleInstances: Nullable<InstancedMesh[]>[];
  20841. renderSelf: boolean[];
  20842. hardwareInstancedRendering: boolean[];
  20843. }
  20844. /**
  20845. * Class used to represent renderable models
  20846. */
  20847. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20848. /**
  20849. * Mesh side orientation : usually the external or front surface
  20850. */
  20851. static readonly FRONTSIDE: number;
  20852. /**
  20853. * Mesh side orientation : usually the internal or back surface
  20854. */
  20855. static readonly BACKSIDE: number;
  20856. /**
  20857. * Mesh side orientation : both internal and external or front and back surfaces
  20858. */
  20859. static readonly DOUBLESIDE: number;
  20860. /**
  20861. * Mesh side orientation : by default, `FRONTSIDE`
  20862. */
  20863. static readonly DEFAULTSIDE: number;
  20864. /**
  20865. * Mesh cap setting : no cap
  20866. */
  20867. static readonly NO_CAP: number;
  20868. /**
  20869. * Mesh cap setting : one cap at the beginning of the mesh
  20870. */
  20871. static readonly CAP_START: number;
  20872. /**
  20873. * Mesh cap setting : one cap at the end of the mesh
  20874. */
  20875. static readonly CAP_END: number;
  20876. /**
  20877. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20878. */
  20879. static readonly CAP_ALL: number;
  20880. /**
  20881. * Gets the default side orientation.
  20882. * @param orientation the orientation to value to attempt to get
  20883. * @returns the default orientation
  20884. * @hidden
  20885. */
  20886. static _GetDefaultSideOrientation(orientation?: number): number;
  20887. private _internalMeshDataInfo;
  20888. /**
  20889. * An event triggered before rendering the mesh
  20890. */
  20891. readonly onBeforeRenderObservable: Observable<Mesh>;
  20892. /**
  20893. * An event triggered before binding the mesh
  20894. */
  20895. readonly onBeforeBindObservable: Observable<Mesh>;
  20896. /**
  20897. * An event triggered after rendering the mesh
  20898. */
  20899. readonly onAfterRenderObservable: Observable<Mesh>;
  20900. /**
  20901. * An event triggered before drawing the mesh
  20902. */
  20903. readonly onBeforeDrawObservable: Observable<Mesh>;
  20904. private _onBeforeDrawObserver;
  20905. /**
  20906. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20907. */
  20908. onBeforeDraw: () => void;
  20909. /**
  20910. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20911. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20912. */
  20913. delayLoadState: number;
  20914. /**
  20915. * Gets the list of instances created from this mesh
  20916. * it is not supposed to be modified manually.
  20917. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20918. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20919. */
  20920. instances: InstancedMesh[];
  20921. /**
  20922. * Gets the file containing delay loading data for this mesh
  20923. */
  20924. delayLoadingFile: string;
  20925. /** @hidden */
  20926. _binaryInfo: any;
  20927. /**
  20928. * User defined function used to change how LOD level selection is done
  20929. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20930. */
  20931. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20932. /**
  20933. * Gets or sets the morph target manager
  20934. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20935. */
  20936. morphTargetManager: Nullable<MorphTargetManager>;
  20937. /** @hidden */
  20938. _creationDataStorage: Nullable<_CreationDataStorage>;
  20939. /** @hidden */
  20940. _geometry: Nullable<Geometry>;
  20941. /** @hidden */
  20942. _delayInfo: Array<string>;
  20943. /** @hidden */
  20944. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20945. /** @hidden */
  20946. _instanceDataStorage: _InstanceDataStorage;
  20947. private _effectiveMaterial;
  20948. /** @hidden */
  20949. _shouldGenerateFlatShading: boolean;
  20950. /** @hidden */
  20951. _originalBuilderSideOrientation: number;
  20952. /**
  20953. * Use this property to change the original side orientation defined at construction time
  20954. */
  20955. overrideMaterialSideOrientation: Nullable<number>;
  20956. /**
  20957. * Gets the source mesh (the one used to clone this one from)
  20958. */
  20959. readonly source: Nullable<Mesh>;
  20960. /**
  20961. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20962. */
  20963. isUnIndexed: boolean;
  20964. /**
  20965. * @constructor
  20966. * @param name The value used by scene.getMeshByName() to do a lookup.
  20967. * @param scene The scene to add this mesh to.
  20968. * @param parent The parent of this mesh, if it has one
  20969. * @param source An optional Mesh from which geometry is shared, cloned.
  20970. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20971. * When false, achieved by calling a clone(), also passing False.
  20972. * This will make creation of children, recursive.
  20973. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20974. */
  20975. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20976. /**
  20977. * Gets the class name
  20978. * @returns the string "Mesh".
  20979. */
  20980. getClassName(): string;
  20981. /** @hidden */
  20982. readonly _isMesh: boolean;
  20983. /**
  20984. * Returns a description of this mesh
  20985. * @param fullDetails define if full details about this mesh must be used
  20986. * @returns a descriptive string representing this mesh
  20987. */
  20988. toString(fullDetails?: boolean): string;
  20989. /** @hidden */
  20990. _unBindEffect(): void;
  20991. /**
  20992. * Gets a boolean indicating if this mesh has LOD
  20993. */
  20994. readonly hasLODLevels: boolean;
  20995. /**
  20996. * Gets the list of MeshLODLevel associated with the current mesh
  20997. * @returns an array of MeshLODLevel
  20998. */
  20999. getLODLevels(): MeshLODLevel[];
  21000. private _sortLODLevels;
  21001. /**
  21002. * Add a mesh as LOD level triggered at the given distance.
  21003. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21004. * @param distance The distance from the center of the object to show this level
  21005. * @param mesh The mesh to be added as LOD level (can be null)
  21006. * @return This mesh (for chaining)
  21007. */
  21008. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21009. /**
  21010. * Returns the LOD level mesh at the passed distance or null if not found.
  21011. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21012. * @param distance The distance from the center of the object to show this level
  21013. * @returns a Mesh or `null`
  21014. */
  21015. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21016. /**
  21017. * Remove a mesh from the LOD array
  21018. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21019. * @param mesh defines the mesh to be removed
  21020. * @return This mesh (for chaining)
  21021. */
  21022. removeLODLevel(mesh: Mesh): Mesh;
  21023. /**
  21024. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21025. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21026. * @param camera defines the camera to use to compute distance
  21027. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21028. * @return This mesh (for chaining)
  21029. */
  21030. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21031. /**
  21032. * Gets the mesh internal Geometry object
  21033. */
  21034. readonly geometry: Nullable<Geometry>;
  21035. /**
  21036. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21037. * @returns the total number of vertices
  21038. */
  21039. getTotalVertices(): number;
  21040. /**
  21041. * Returns the content of an associated vertex buffer
  21042. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21043. * - VertexBuffer.PositionKind
  21044. * - VertexBuffer.UVKind
  21045. * - VertexBuffer.UV2Kind
  21046. * - VertexBuffer.UV3Kind
  21047. * - VertexBuffer.UV4Kind
  21048. * - VertexBuffer.UV5Kind
  21049. * - VertexBuffer.UV6Kind
  21050. * - VertexBuffer.ColorKind
  21051. * - VertexBuffer.MatricesIndicesKind
  21052. * - VertexBuffer.MatricesIndicesExtraKind
  21053. * - VertexBuffer.MatricesWeightsKind
  21054. * - VertexBuffer.MatricesWeightsExtraKind
  21055. * @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
  21056. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21057. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21058. */
  21059. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21060. /**
  21061. * Returns the mesh VertexBuffer object from the requested `kind`
  21062. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21063. * - VertexBuffer.PositionKind
  21064. * - VertexBuffer.UVKind
  21065. * - VertexBuffer.UV2Kind
  21066. * - VertexBuffer.UV3Kind
  21067. * - VertexBuffer.UV4Kind
  21068. * - VertexBuffer.UV5Kind
  21069. * - VertexBuffer.UV6Kind
  21070. * - VertexBuffer.ColorKind
  21071. * - VertexBuffer.MatricesIndicesKind
  21072. * - VertexBuffer.MatricesIndicesExtraKind
  21073. * - VertexBuffer.MatricesWeightsKind
  21074. * - VertexBuffer.MatricesWeightsExtraKind
  21075. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21076. */
  21077. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21078. /**
  21079. * Tests if a specific vertex buffer is associated with this mesh
  21080. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21081. * - VertexBuffer.PositionKind
  21082. * - VertexBuffer.UVKind
  21083. * - VertexBuffer.UV2Kind
  21084. * - VertexBuffer.UV3Kind
  21085. * - VertexBuffer.UV4Kind
  21086. * - VertexBuffer.UV5Kind
  21087. * - VertexBuffer.UV6Kind
  21088. * - VertexBuffer.ColorKind
  21089. * - VertexBuffer.MatricesIndicesKind
  21090. * - VertexBuffer.MatricesIndicesExtraKind
  21091. * - VertexBuffer.MatricesWeightsKind
  21092. * - VertexBuffer.MatricesWeightsExtraKind
  21093. * @returns a boolean
  21094. */
  21095. isVerticesDataPresent(kind: string): boolean;
  21096. /**
  21097. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21098. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21099. * - VertexBuffer.PositionKind
  21100. * - VertexBuffer.UVKind
  21101. * - VertexBuffer.UV2Kind
  21102. * - VertexBuffer.UV3Kind
  21103. * - VertexBuffer.UV4Kind
  21104. * - VertexBuffer.UV5Kind
  21105. * - VertexBuffer.UV6Kind
  21106. * - VertexBuffer.ColorKind
  21107. * - VertexBuffer.MatricesIndicesKind
  21108. * - VertexBuffer.MatricesIndicesExtraKind
  21109. * - VertexBuffer.MatricesWeightsKind
  21110. * - VertexBuffer.MatricesWeightsExtraKind
  21111. * @returns a boolean
  21112. */
  21113. isVertexBufferUpdatable(kind: string): boolean;
  21114. /**
  21115. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21116. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21117. * - VertexBuffer.PositionKind
  21118. * - VertexBuffer.UVKind
  21119. * - VertexBuffer.UV2Kind
  21120. * - VertexBuffer.UV3Kind
  21121. * - VertexBuffer.UV4Kind
  21122. * - VertexBuffer.UV5Kind
  21123. * - VertexBuffer.UV6Kind
  21124. * - VertexBuffer.ColorKind
  21125. * - VertexBuffer.MatricesIndicesKind
  21126. * - VertexBuffer.MatricesIndicesExtraKind
  21127. * - VertexBuffer.MatricesWeightsKind
  21128. * - VertexBuffer.MatricesWeightsExtraKind
  21129. * @returns an array of strings
  21130. */
  21131. getVerticesDataKinds(): string[];
  21132. /**
  21133. * Returns a positive integer : the total number of indices in this mesh geometry.
  21134. * @returns the numner of indices or zero if the mesh has no geometry.
  21135. */
  21136. getTotalIndices(): number;
  21137. /**
  21138. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21139. * @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.
  21140. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21141. * @returns the indices array or an empty array if the mesh has no geometry
  21142. */
  21143. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21144. readonly isBlocked: boolean;
  21145. /**
  21146. * Determine if the current mesh is ready to be rendered
  21147. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21148. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21149. * @returns true if all associated assets are ready (material, textures, shaders)
  21150. */
  21151. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21152. /**
  21153. * 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.
  21154. */
  21155. readonly areNormalsFrozen: boolean;
  21156. /**
  21157. * 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.
  21158. * @returns the current mesh
  21159. */
  21160. freezeNormals(): Mesh;
  21161. /**
  21162. * 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
  21163. * @returns the current mesh
  21164. */
  21165. unfreezeNormals(): Mesh;
  21166. /**
  21167. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21168. */
  21169. overridenInstanceCount: number;
  21170. /** @hidden */
  21171. _preActivate(): Mesh;
  21172. /** @hidden */
  21173. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21174. /** @hidden */
  21175. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21176. /**
  21177. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21178. * This means the mesh underlying bounding box and sphere are recomputed.
  21179. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21180. * @returns the current mesh
  21181. */
  21182. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21183. /** @hidden */
  21184. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21185. /**
  21186. * This function will subdivide the mesh into multiple submeshes
  21187. * @param count defines the expected number of submeshes
  21188. */
  21189. subdivide(count: number): void;
  21190. /**
  21191. * Copy a FloatArray into a specific associated vertex buffer
  21192. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21193. * - VertexBuffer.PositionKind
  21194. * - VertexBuffer.UVKind
  21195. * - VertexBuffer.UV2Kind
  21196. * - VertexBuffer.UV3Kind
  21197. * - VertexBuffer.UV4Kind
  21198. * - VertexBuffer.UV5Kind
  21199. * - VertexBuffer.UV6Kind
  21200. * - VertexBuffer.ColorKind
  21201. * - VertexBuffer.MatricesIndicesKind
  21202. * - VertexBuffer.MatricesIndicesExtraKind
  21203. * - VertexBuffer.MatricesWeightsKind
  21204. * - VertexBuffer.MatricesWeightsExtraKind
  21205. * @param data defines the data source
  21206. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21207. * @param stride defines the data stride size (can be null)
  21208. * @returns the current mesh
  21209. */
  21210. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21211. /**
  21212. * Flags an associated vertex buffer as updatable
  21213. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21214. * - VertexBuffer.PositionKind
  21215. * - VertexBuffer.UVKind
  21216. * - VertexBuffer.UV2Kind
  21217. * - VertexBuffer.UV3Kind
  21218. * - VertexBuffer.UV4Kind
  21219. * - VertexBuffer.UV5Kind
  21220. * - VertexBuffer.UV6Kind
  21221. * - VertexBuffer.ColorKind
  21222. * - VertexBuffer.MatricesIndicesKind
  21223. * - VertexBuffer.MatricesIndicesExtraKind
  21224. * - VertexBuffer.MatricesWeightsKind
  21225. * - VertexBuffer.MatricesWeightsExtraKind
  21226. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21227. */
  21228. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21229. /**
  21230. * Sets the mesh global Vertex Buffer
  21231. * @param buffer defines the buffer to use
  21232. * @returns the current mesh
  21233. */
  21234. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21235. /**
  21236. * Update a specific associated vertex buffer
  21237. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21238. * - VertexBuffer.PositionKind
  21239. * - VertexBuffer.UVKind
  21240. * - VertexBuffer.UV2Kind
  21241. * - VertexBuffer.UV3Kind
  21242. * - VertexBuffer.UV4Kind
  21243. * - VertexBuffer.UV5Kind
  21244. * - VertexBuffer.UV6Kind
  21245. * - VertexBuffer.ColorKind
  21246. * - VertexBuffer.MatricesIndicesKind
  21247. * - VertexBuffer.MatricesIndicesExtraKind
  21248. * - VertexBuffer.MatricesWeightsKind
  21249. * - VertexBuffer.MatricesWeightsExtraKind
  21250. * @param data defines the data source
  21251. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21252. * @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)
  21253. * @returns the current mesh
  21254. */
  21255. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21256. /**
  21257. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21258. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21259. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21260. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21261. * @returns the current mesh
  21262. */
  21263. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21264. /**
  21265. * Creates a un-shared specific occurence of the geometry for the mesh.
  21266. * @returns the current mesh
  21267. */
  21268. makeGeometryUnique(): Mesh;
  21269. /**
  21270. * Set the index buffer of this mesh
  21271. * @param indices defines the source data
  21272. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21273. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21274. * @returns the current mesh
  21275. */
  21276. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21277. /**
  21278. * Update the current index buffer
  21279. * @param indices defines the source data
  21280. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21281. * @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)
  21282. * @returns the current mesh
  21283. */
  21284. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21285. /**
  21286. * Invert the geometry to move from a right handed system to a left handed one.
  21287. * @returns the current mesh
  21288. */
  21289. toLeftHanded(): Mesh;
  21290. /** @hidden */
  21291. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21292. /** @hidden */
  21293. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21294. /**
  21295. * Registers for this mesh a javascript function called just before the rendering process
  21296. * @param func defines the function to call before rendering this mesh
  21297. * @returns the current mesh
  21298. */
  21299. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21300. /**
  21301. * Disposes a previously registered javascript function called before the rendering
  21302. * @param func defines the function to remove
  21303. * @returns the current mesh
  21304. */
  21305. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21306. /**
  21307. * Registers for this mesh a javascript function called just after the rendering is complete
  21308. * @param func defines the function to call after rendering this mesh
  21309. * @returns the current mesh
  21310. */
  21311. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21312. /**
  21313. * Disposes a previously registered javascript function called after the rendering.
  21314. * @param func defines the function to remove
  21315. * @returns the current mesh
  21316. */
  21317. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21318. /** @hidden */
  21319. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21320. /** @hidden */
  21321. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21322. /** @hidden */
  21323. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21324. /** @hidden */
  21325. _freeze(): void;
  21326. /** @hidden */
  21327. _unFreeze(): void;
  21328. /**
  21329. * 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
  21330. * @param subMesh defines the subMesh to render
  21331. * @param enableAlphaMode defines if alpha mode can be changed
  21332. * @returns the current mesh
  21333. */
  21334. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21335. private _onBeforeDraw;
  21336. /**
  21337. * Renormalize the mesh and patch it up if there are no weights
  21338. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21339. * However in the case of zero weights then we set just a single influence to 1.
  21340. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21341. */
  21342. cleanMatrixWeights(): void;
  21343. private normalizeSkinFourWeights;
  21344. private normalizeSkinWeightsAndExtra;
  21345. /**
  21346. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21347. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21348. * the user know there was an issue with importing the mesh
  21349. * @returns a validation object with skinned, valid and report string
  21350. */
  21351. validateSkinning(): {
  21352. skinned: boolean;
  21353. valid: boolean;
  21354. report: string;
  21355. };
  21356. /** @hidden */
  21357. _checkDelayState(): Mesh;
  21358. private _queueLoad;
  21359. /**
  21360. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21361. * A mesh is in the frustum if its bounding box intersects the frustum
  21362. * @param frustumPlanes defines the frustum to test
  21363. * @returns true if the mesh is in the frustum planes
  21364. */
  21365. isInFrustum(frustumPlanes: Plane[]): boolean;
  21366. /**
  21367. * Sets the mesh material by the material or multiMaterial `id` property
  21368. * @param id is a string identifying the material or the multiMaterial
  21369. * @returns the current mesh
  21370. */
  21371. setMaterialByID(id: string): Mesh;
  21372. /**
  21373. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21374. * @returns an array of IAnimatable
  21375. */
  21376. getAnimatables(): IAnimatable[];
  21377. /**
  21378. * Modifies the mesh geometry according to the passed transformation matrix.
  21379. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21380. * The mesh normals are modified using the same transformation.
  21381. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21382. * @param transform defines the transform matrix to use
  21383. * @see http://doc.babylonjs.com/resources/baking_transformations
  21384. * @returns the current mesh
  21385. */
  21386. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21387. /**
  21388. * Modifies the mesh geometry according to its own current World Matrix.
  21389. * The mesh World Matrix is then reset.
  21390. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21391. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21392. * @see http://doc.babylonjs.com/resources/baking_transformations
  21393. * @returns the current mesh
  21394. */
  21395. bakeCurrentTransformIntoVertices(): Mesh;
  21396. /** @hidden */
  21397. readonly _positions: Nullable<Vector3[]>;
  21398. /** @hidden */
  21399. _resetPointsArrayCache(): Mesh;
  21400. /** @hidden */
  21401. _generatePointsArray(): boolean;
  21402. /**
  21403. * Returns a new Mesh object generated from the current mesh properties.
  21404. * This method must not get confused with createInstance()
  21405. * @param name is a string, the name given to the new mesh
  21406. * @param newParent can be any Node object (default `null`)
  21407. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21408. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21409. * @returns a new mesh
  21410. */
  21411. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21412. /**
  21413. * Releases resources associated with this mesh.
  21414. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21415. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21416. */
  21417. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21418. /**
  21419. * Modifies the mesh geometry according to a displacement map.
  21420. * 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.
  21421. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21422. * @param url is a string, the URL from the image file is to be downloaded.
  21423. * @param minHeight is the lower limit of the displacement.
  21424. * @param maxHeight is the upper limit of the displacement.
  21425. * @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.
  21426. * @param uvOffset is an optional vector2 used to offset UV.
  21427. * @param uvScale is an optional vector2 used to scale UV.
  21428. * @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.
  21429. * @returns the Mesh.
  21430. */
  21431. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21432. /**
  21433. * Modifies the mesh geometry according to a displacementMap buffer.
  21434. * 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.
  21435. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21436. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21437. * @param heightMapWidth is the width of the buffer image.
  21438. * @param heightMapHeight is the height of the buffer image.
  21439. * @param minHeight is the lower limit of the displacement.
  21440. * @param maxHeight is the upper limit of the displacement.
  21441. * @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.
  21442. * @param uvOffset is an optional vector2 used to offset UV.
  21443. * @param uvScale is an optional vector2 used to scale UV.
  21444. * @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.
  21445. * @returns the Mesh.
  21446. */
  21447. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21448. /**
  21449. * Modify the mesh to get a flat shading rendering.
  21450. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21451. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21452. * @returns current mesh
  21453. */
  21454. convertToFlatShadedMesh(): Mesh;
  21455. /**
  21456. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21457. * In other words, more vertices, no more indices and a single bigger VBO.
  21458. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21459. * @returns current mesh
  21460. */
  21461. convertToUnIndexedMesh(): Mesh;
  21462. /**
  21463. * Inverses facet orientations.
  21464. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21465. * @param flipNormals will also inverts the normals
  21466. * @returns current mesh
  21467. */
  21468. flipFaces(flipNormals?: boolean): Mesh;
  21469. /**
  21470. * Increase the number of facets and hence vertices in a mesh
  21471. * Vertex normals are interpolated from existing vertex normals
  21472. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21473. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21474. */
  21475. increaseVertices(numberPerEdge: number): void;
  21476. /**
  21477. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21478. * This will undo any application of covertToFlatShadedMesh
  21479. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21480. */
  21481. forceSharedVertices(): void;
  21482. /** @hidden */
  21483. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21484. /** @hidden */
  21485. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21486. /**
  21487. * Creates a new InstancedMesh object from the mesh model.
  21488. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21489. * @param name defines the name of the new instance
  21490. * @returns a new InstancedMesh
  21491. */
  21492. createInstance(name: string): InstancedMesh;
  21493. /**
  21494. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21495. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21496. * @returns the current mesh
  21497. */
  21498. synchronizeInstances(): Mesh;
  21499. /**
  21500. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21501. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21502. * This should be used together with the simplification to avoid disappearing triangles.
  21503. * @param successCallback an optional success callback to be called after the optimization finished.
  21504. * @returns the current mesh
  21505. */
  21506. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21507. /**
  21508. * Serialize current mesh
  21509. * @param serializationObject defines the object which will receive the serialization data
  21510. */
  21511. serialize(serializationObject: any): void;
  21512. /** @hidden */
  21513. _syncGeometryWithMorphTargetManager(): void;
  21514. /** @hidden */
  21515. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21516. /**
  21517. * Returns a new Mesh object parsed from the source provided.
  21518. * @param parsedMesh is the source
  21519. * @param scene defines the hosting scene
  21520. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21521. * @returns a new Mesh
  21522. */
  21523. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21524. /**
  21525. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21526. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21527. * @param name defines the name of the mesh to create
  21528. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21529. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21530. * @param closePath creates a seam between the first and the last points of each path of the path array
  21531. * @param offset is taken in account only if the `pathArray` is containing a single path
  21532. * @param scene defines the hosting scene
  21533. * @param updatable defines if the mesh must be flagged as updatable
  21534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21535. * @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)
  21536. * @returns a new Mesh
  21537. */
  21538. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21539. /**
  21540. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21541. * @param name defines the name of the mesh to create
  21542. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21543. * @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
  21544. * @param scene defines the hosting scene
  21545. * @param updatable defines if the mesh must be flagged as updatable
  21546. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21547. * @returns a new Mesh
  21548. */
  21549. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21550. /**
  21551. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21552. * @param name defines the name of the mesh to create
  21553. * @param size sets the size (float) of each box side (default 1)
  21554. * @param scene defines the hosting scene
  21555. * @param updatable defines if the mesh must be flagged as updatable
  21556. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21557. * @returns a new Mesh
  21558. */
  21559. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21560. /**
  21561. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21562. * @param name defines the name of the mesh to create
  21563. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21564. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21565. * @param scene defines the hosting scene
  21566. * @param updatable defines if the mesh must be flagged as updatable
  21567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21568. * @returns a new Mesh
  21569. */
  21570. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21571. /**
  21572. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21573. * @param name defines the name of the mesh to create
  21574. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21575. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21576. * @param scene defines the hosting scene
  21577. * @returns a new Mesh
  21578. */
  21579. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21580. /**
  21581. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21582. * @param name defines the name of the mesh to create
  21583. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21584. * @param diameterTop set the top cap diameter (floats, default 1)
  21585. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21586. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21587. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21588. * @param scene defines the hosting scene
  21589. * @param updatable defines if the mesh must be flagged as updatable
  21590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21591. * @returns a new Mesh
  21592. */
  21593. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21594. /**
  21595. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21596. * @param name defines the name of the mesh to create
  21597. * @param diameter sets the diameter size (float) of the torus (default 1)
  21598. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21599. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21600. * @param scene defines the hosting scene
  21601. * @param updatable defines if the mesh must be flagged as updatable
  21602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21603. * @returns a new Mesh
  21604. */
  21605. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21606. /**
  21607. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21608. * @param name defines the name of the mesh to create
  21609. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21610. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21611. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21612. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21613. * @param p the number of windings on X axis (positive integers, default 2)
  21614. * @param q the number of windings on Y axis (positive integers, default 3)
  21615. * @param scene defines the hosting scene
  21616. * @param updatable defines if the mesh must be flagged as updatable
  21617. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21618. * @returns a new Mesh
  21619. */
  21620. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21621. /**
  21622. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21623. * @param name defines the name of the mesh to create
  21624. * @param points is an array successive Vector3
  21625. * @param scene defines the hosting scene
  21626. * @param updatable defines if the mesh must be flagged as updatable
  21627. * @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).
  21628. * @returns a new Mesh
  21629. */
  21630. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21631. /**
  21632. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21633. * @param name defines the name of the mesh to create
  21634. * @param points is an array successive Vector3
  21635. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21636. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21637. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21638. * @param scene defines the hosting scene
  21639. * @param updatable defines if the mesh must be flagged as updatable
  21640. * @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)
  21641. * @returns a new Mesh
  21642. */
  21643. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21644. /**
  21645. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21646. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21647. * 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.
  21648. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21649. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21650. * Remember you can only change the shape positions, not their number when updating a polygon.
  21651. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21652. * @param name defines the name of the mesh to create
  21653. * @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
  21654. * @param scene defines the hosting scene
  21655. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21656. * @param updatable defines if the mesh must be flagged as updatable
  21657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21658. * @param earcutInjection can be used to inject your own earcut reference
  21659. * @returns a new Mesh
  21660. */
  21661. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21662. /**
  21663. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21664. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21665. * @param name defines the name of the mesh to create
  21666. * @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
  21667. * @param depth defines the height of extrusion
  21668. * @param scene defines the hosting scene
  21669. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21670. * @param updatable defines if the mesh must be flagged as updatable
  21671. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21672. * @param earcutInjection can be used to inject your own earcut reference
  21673. * @returns a new Mesh
  21674. */
  21675. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21676. /**
  21677. * Creates an extruded shape mesh.
  21678. * 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
  21679. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21680. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21681. * @param name defines the name of the mesh to create
  21682. * @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
  21683. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21684. * @param scale is the value to scale the shape
  21685. * @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
  21686. * @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
  21687. * @param scene defines the hosting scene
  21688. * @param updatable defines if the mesh must be flagged as updatable
  21689. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21690. * @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)
  21691. * @returns a new Mesh
  21692. */
  21693. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21694. /**
  21695. * Creates an custom extruded shape mesh.
  21696. * The custom extrusion is a parametric shape.
  21697. * It has no predefined shape. Its final shape will depend on the input parameters.
  21698. * Please consider using the same method from the MeshBuilder class instead
  21699. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21700. * @param name defines the name of the mesh to create
  21701. * @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
  21702. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21703. * @param scaleFunction is a custom Javascript function called on each path point
  21704. * @param rotationFunction is a custom Javascript function called on each path point
  21705. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21706. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21707. * @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
  21708. * @param scene defines the hosting scene
  21709. * @param updatable defines if the mesh must be flagged as updatable
  21710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21711. * @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)
  21712. * @returns a new Mesh
  21713. */
  21714. 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;
  21715. /**
  21716. * Creates lathe mesh.
  21717. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21718. * Please consider using the same method from the MeshBuilder class instead
  21719. * @param name defines the name of the mesh to create
  21720. * @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
  21721. * @param radius is the radius value of the lathe
  21722. * @param tessellation is the side number of the lathe.
  21723. * @param scene defines the hosting scene
  21724. * @param updatable defines if the mesh must be flagged as updatable
  21725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21726. * @returns a new Mesh
  21727. */
  21728. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21729. /**
  21730. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21731. * @param name defines the name of the mesh to create
  21732. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21733. * @param scene defines the hosting scene
  21734. * @param updatable defines if the mesh must be flagged as updatable
  21735. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21736. * @returns a new Mesh
  21737. */
  21738. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21739. /**
  21740. * Creates a ground mesh.
  21741. * Please consider using the same method from the MeshBuilder class instead
  21742. * @param name defines the name of the mesh to create
  21743. * @param width set the width of the ground
  21744. * @param height set the height of the ground
  21745. * @param subdivisions sets the number of subdivisions per side
  21746. * @param scene defines the hosting scene
  21747. * @param updatable defines if the mesh must be flagged as updatable
  21748. * @returns a new Mesh
  21749. */
  21750. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21751. /**
  21752. * Creates a tiled ground mesh.
  21753. * Please consider using the same method from the MeshBuilder class instead
  21754. * @param name defines the name of the mesh to create
  21755. * @param xmin set the ground minimum X coordinate
  21756. * @param zmin set the ground minimum Y coordinate
  21757. * @param xmax set the ground maximum X coordinate
  21758. * @param zmax set the ground maximum Z coordinate
  21759. * @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
  21760. * @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
  21761. * @param scene defines the hosting scene
  21762. * @param updatable defines if the mesh must be flagged as updatable
  21763. * @returns a new Mesh
  21764. */
  21765. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21766. w: number;
  21767. h: number;
  21768. }, precision: {
  21769. w: number;
  21770. h: number;
  21771. }, scene: Scene, updatable?: boolean): Mesh;
  21772. /**
  21773. * Creates a ground mesh from a height map.
  21774. * Please consider using the same method from the MeshBuilder class instead
  21775. * @see http://doc.babylonjs.com/babylon101/height_map
  21776. * @param name defines the name of the mesh to create
  21777. * @param url sets the URL of the height map image resource
  21778. * @param width set the ground width size
  21779. * @param height set the ground height size
  21780. * @param subdivisions sets the number of subdivision per side
  21781. * @param minHeight is the minimum altitude on the ground
  21782. * @param maxHeight is the maximum altitude on the ground
  21783. * @param scene defines the hosting scene
  21784. * @param updatable defines if the mesh must be flagged as updatable
  21785. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21786. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21787. * @returns a new Mesh
  21788. */
  21789. 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;
  21790. /**
  21791. * Creates a tube mesh.
  21792. * The tube is a parametric shape.
  21793. * It has no predefined shape. Its final shape will depend on the input parameters.
  21794. * Please consider using the same method from the MeshBuilder class instead
  21795. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21796. * @param name defines the name of the mesh to create
  21797. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21798. * @param radius sets the tube radius size
  21799. * @param tessellation is the number of sides on the tubular surface
  21800. * @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
  21801. * @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
  21802. * @param scene defines the hosting scene
  21803. * @param updatable defines if the mesh must be flagged as updatable
  21804. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21805. * @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)
  21806. * @returns a new Mesh
  21807. */
  21808. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21809. (i: number, distance: number): number;
  21810. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21811. /**
  21812. * Creates a polyhedron mesh.
  21813. * Please consider using the same method from the MeshBuilder class instead.
  21814. * * 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
  21815. * * The parameter `size` (positive float, default 1) sets the polygon size
  21816. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21817. * * 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`
  21818. * * 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
  21819. * * 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)`)
  21820. * * 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
  21821. * * 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
  21822. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21823. * * 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
  21824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21825. * @param name defines the name of the mesh to create
  21826. * @param options defines the options used to create the mesh
  21827. * @param scene defines the hosting scene
  21828. * @returns a new Mesh
  21829. */
  21830. static CreatePolyhedron(name: string, options: {
  21831. type?: number;
  21832. size?: number;
  21833. sizeX?: number;
  21834. sizeY?: number;
  21835. sizeZ?: number;
  21836. custom?: any;
  21837. faceUV?: Vector4[];
  21838. faceColors?: Color4[];
  21839. updatable?: boolean;
  21840. sideOrientation?: number;
  21841. }, scene: Scene): Mesh;
  21842. /**
  21843. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21844. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21845. * * 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`)
  21846. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21847. * * 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
  21848. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21849. * * 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
  21850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21851. * @param name defines the name of the mesh
  21852. * @param options defines the options used to create the mesh
  21853. * @param scene defines the hosting scene
  21854. * @returns a new Mesh
  21855. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21856. */
  21857. static CreateIcoSphere(name: string, options: {
  21858. radius?: number;
  21859. flat?: boolean;
  21860. subdivisions?: number;
  21861. sideOrientation?: number;
  21862. updatable?: boolean;
  21863. }, scene: Scene): Mesh;
  21864. /**
  21865. * Creates a decal mesh.
  21866. * Please consider using the same method from the MeshBuilder class instead.
  21867. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21868. * @param name defines the name of the mesh
  21869. * @param sourceMesh defines the mesh receiving the decal
  21870. * @param position sets the position of the decal in world coordinates
  21871. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21872. * @param size sets the decal scaling
  21873. * @param angle sets the angle to rotate the decal
  21874. * @returns a new Mesh
  21875. */
  21876. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21877. /**
  21878. * Prepare internal position array for software CPU skinning
  21879. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21880. */
  21881. setPositionsForCPUSkinning(): Float32Array;
  21882. /**
  21883. * Prepare internal normal array for software CPU skinning
  21884. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21885. */
  21886. setNormalsForCPUSkinning(): Float32Array;
  21887. /**
  21888. * Updates the vertex buffer by applying transformation from the bones
  21889. * @param skeleton defines the skeleton to apply to current mesh
  21890. * @returns the current mesh
  21891. */
  21892. applySkeleton(skeleton: Skeleton): Mesh;
  21893. /**
  21894. * 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
  21895. * @param meshes defines the list of meshes to scan
  21896. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21897. */
  21898. static MinMax(meshes: AbstractMesh[]): {
  21899. min: Vector3;
  21900. max: Vector3;
  21901. };
  21902. /**
  21903. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21904. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21905. * @returns a vector3
  21906. */
  21907. static Center(meshesOrMinMaxVector: {
  21908. min: Vector3;
  21909. max: Vector3;
  21910. } | AbstractMesh[]): Vector3;
  21911. /**
  21912. * Merge the array of meshes into a single mesh for performance reasons.
  21913. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21914. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21915. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21916. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21917. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21918. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21919. * @returns a new mesh
  21920. */
  21921. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21922. /** @hidden */
  21923. addInstance(instance: InstancedMesh): void;
  21924. /** @hidden */
  21925. removeInstance(instance: InstancedMesh): void;
  21926. }
  21927. }
  21928. declare module BABYLON {
  21929. /**
  21930. * Base class for the main features of a material in Babylon.js
  21931. */
  21932. export class Material implements IAnimatable {
  21933. /**
  21934. * Returns the triangle fill mode
  21935. */
  21936. static readonly TriangleFillMode: number;
  21937. /**
  21938. * Returns the wireframe mode
  21939. */
  21940. static readonly WireFrameFillMode: number;
  21941. /**
  21942. * Returns the point fill mode
  21943. */
  21944. static readonly PointFillMode: number;
  21945. /**
  21946. * Returns the point list draw mode
  21947. */
  21948. static readonly PointListDrawMode: number;
  21949. /**
  21950. * Returns the line list draw mode
  21951. */
  21952. static readonly LineListDrawMode: number;
  21953. /**
  21954. * Returns the line loop draw mode
  21955. */
  21956. static readonly LineLoopDrawMode: number;
  21957. /**
  21958. * Returns the line strip draw mode
  21959. */
  21960. static readonly LineStripDrawMode: number;
  21961. /**
  21962. * Returns the triangle strip draw mode
  21963. */
  21964. static readonly TriangleStripDrawMode: number;
  21965. /**
  21966. * Returns the triangle fan draw mode
  21967. */
  21968. static readonly TriangleFanDrawMode: number;
  21969. /**
  21970. * Stores the clock-wise side orientation
  21971. */
  21972. static readonly ClockWiseSideOrientation: number;
  21973. /**
  21974. * Stores the counter clock-wise side orientation
  21975. */
  21976. static readonly CounterClockWiseSideOrientation: number;
  21977. /**
  21978. * The dirty texture flag value
  21979. */
  21980. static readonly TextureDirtyFlag: number;
  21981. /**
  21982. * The dirty light flag value
  21983. */
  21984. static readonly LightDirtyFlag: number;
  21985. /**
  21986. * The dirty fresnel flag value
  21987. */
  21988. static readonly FresnelDirtyFlag: number;
  21989. /**
  21990. * The dirty attribute flag value
  21991. */
  21992. static readonly AttributesDirtyFlag: number;
  21993. /**
  21994. * The dirty misc flag value
  21995. */
  21996. static readonly MiscDirtyFlag: number;
  21997. /**
  21998. * The all dirty flag value
  21999. */
  22000. static readonly AllDirtyFlag: number;
  22001. /**
  22002. * The ID of the material
  22003. */
  22004. id: string;
  22005. /**
  22006. * Gets or sets the unique id of the material
  22007. */
  22008. uniqueId: number;
  22009. /**
  22010. * The name of the material
  22011. */
  22012. name: string;
  22013. /**
  22014. * Gets or sets user defined metadata
  22015. */
  22016. metadata: any;
  22017. /**
  22018. * For internal use only. Please do not use.
  22019. */
  22020. reservedDataStore: any;
  22021. /**
  22022. * Specifies if the ready state should be checked on each call
  22023. */
  22024. checkReadyOnEveryCall: boolean;
  22025. /**
  22026. * Specifies if the ready state should be checked once
  22027. */
  22028. checkReadyOnlyOnce: boolean;
  22029. /**
  22030. * The state of the material
  22031. */
  22032. state: string;
  22033. /**
  22034. * The alpha value of the material
  22035. */
  22036. protected _alpha: number;
  22037. /**
  22038. * List of inspectable custom properties (used by the Inspector)
  22039. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22040. */
  22041. inspectableCustomProperties: IInspectable[];
  22042. /**
  22043. * Sets the alpha value of the material
  22044. */
  22045. /**
  22046. * Gets the alpha value of the material
  22047. */
  22048. alpha: number;
  22049. /**
  22050. * Specifies if back face culling is enabled
  22051. */
  22052. protected _backFaceCulling: boolean;
  22053. /**
  22054. * Sets the back-face culling state
  22055. */
  22056. /**
  22057. * Gets the back-face culling state
  22058. */
  22059. backFaceCulling: boolean;
  22060. /**
  22061. * Stores the value for side orientation
  22062. */
  22063. sideOrientation: number;
  22064. /**
  22065. * Callback triggered when the material is compiled
  22066. */
  22067. onCompiled: Nullable<(effect: Effect) => void>;
  22068. /**
  22069. * Callback triggered when an error occurs
  22070. */
  22071. onError: Nullable<(effect: Effect, errors: string) => void>;
  22072. /**
  22073. * Callback triggered to get the render target textures
  22074. */
  22075. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22076. /**
  22077. * Gets a boolean indicating that current material needs to register RTT
  22078. */
  22079. readonly hasRenderTargetTextures: boolean;
  22080. /**
  22081. * Specifies if the material should be serialized
  22082. */
  22083. doNotSerialize: boolean;
  22084. /**
  22085. * @hidden
  22086. */
  22087. _storeEffectOnSubMeshes: boolean;
  22088. /**
  22089. * Stores the animations for the material
  22090. */
  22091. animations: Nullable<Array<Animation>>;
  22092. /**
  22093. * An event triggered when the material is disposed
  22094. */
  22095. onDisposeObservable: Observable<Material>;
  22096. /**
  22097. * An observer which watches for dispose events
  22098. */
  22099. private _onDisposeObserver;
  22100. private _onUnBindObservable;
  22101. /**
  22102. * Called during a dispose event
  22103. */
  22104. onDispose: () => void;
  22105. private _onBindObservable;
  22106. /**
  22107. * An event triggered when the material is bound
  22108. */
  22109. readonly onBindObservable: Observable<AbstractMesh>;
  22110. /**
  22111. * An observer which watches for bind events
  22112. */
  22113. private _onBindObserver;
  22114. /**
  22115. * Called during a bind event
  22116. */
  22117. onBind: (Mesh: AbstractMesh) => void;
  22118. /**
  22119. * An event triggered when the material is unbound
  22120. */
  22121. readonly onUnBindObservable: Observable<Material>;
  22122. /**
  22123. * Stores the value of the alpha mode
  22124. */
  22125. private _alphaMode;
  22126. /**
  22127. * Sets the value of the alpha mode.
  22128. *
  22129. * | Value | Type | Description |
  22130. * | --- | --- | --- |
  22131. * | 0 | ALPHA_DISABLE | |
  22132. * | 1 | ALPHA_ADD | |
  22133. * | 2 | ALPHA_COMBINE | |
  22134. * | 3 | ALPHA_SUBTRACT | |
  22135. * | 4 | ALPHA_MULTIPLY | |
  22136. * | 5 | ALPHA_MAXIMIZED | |
  22137. * | 6 | ALPHA_ONEONE | |
  22138. * | 7 | ALPHA_PREMULTIPLIED | |
  22139. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22140. * | 9 | ALPHA_INTERPOLATE | |
  22141. * | 10 | ALPHA_SCREENMODE | |
  22142. *
  22143. */
  22144. /**
  22145. * Gets the value of the alpha mode
  22146. */
  22147. alphaMode: number;
  22148. /**
  22149. * Stores the state of the need depth pre-pass value
  22150. */
  22151. private _needDepthPrePass;
  22152. /**
  22153. * Sets the need depth pre-pass value
  22154. */
  22155. /**
  22156. * Gets the depth pre-pass value
  22157. */
  22158. needDepthPrePass: boolean;
  22159. /**
  22160. * Specifies if depth writing should be disabled
  22161. */
  22162. disableDepthWrite: boolean;
  22163. /**
  22164. * Specifies if depth writing should be forced
  22165. */
  22166. forceDepthWrite: boolean;
  22167. /**
  22168. * Specifies if there should be a separate pass for culling
  22169. */
  22170. separateCullingPass: boolean;
  22171. /**
  22172. * Stores the state specifing if fog should be enabled
  22173. */
  22174. private _fogEnabled;
  22175. /**
  22176. * Sets the state for enabling fog
  22177. */
  22178. /**
  22179. * Gets the value of the fog enabled state
  22180. */
  22181. fogEnabled: boolean;
  22182. /**
  22183. * Stores the size of points
  22184. */
  22185. pointSize: number;
  22186. /**
  22187. * Stores the z offset value
  22188. */
  22189. zOffset: number;
  22190. /**
  22191. * Gets a value specifying if wireframe mode is enabled
  22192. */
  22193. /**
  22194. * Sets the state of wireframe mode
  22195. */
  22196. wireframe: boolean;
  22197. /**
  22198. * Gets the value specifying if point clouds are enabled
  22199. */
  22200. /**
  22201. * Sets the state of point cloud mode
  22202. */
  22203. pointsCloud: boolean;
  22204. /**
  22205. * Gets the material fill mode
  22206. */
  22207. /**
  22208. * Sets the material fill mode
  22209. */
  22210. fillMode: number;
  22211. /**
  22212. * @hidden
  22213. * Stores the effects for the material
  22214. */
  22215. _effect: Nullable<Effect>;
  22216. /**
  22217. * @hidden
  22218. * Specifies if the material was previously ready
  22219. */
  22220. _wasPreviouslyReady: boolean;
  22221. /**
  22222. * Specifies if uniform buffers should be used
  22223. */
  22224. private _useUBO;
  22225. /**
  22226. * Stores a reference to the scene
  22227. */
  22228. private _scene;
  22229. /**
  22230. * Stores the fill mode state
  22231. */
  22232. private _fillMode;
  22233. /**
  22234. * Specifies if the depth write state should be cached
  22235. */
  22236. private _cachedDepthWriteState;
  22237. /**
  22238. * Stores the uniform buffer
  22239. */
  22240. protected _uniformBuffer: UniformBuffer;
  22241. /** @hidden */
  22242. _indexInSceneMaterialArray: number;
  22243. /** @hidden */
  22244. meshMap: Nullable<{
  22245. [id: string]: AbstractMesh | undefined;
  22246. }>;
  22247. /**
  22248. * Creates a material instance
  22249. * @param name defines the name of the material
  22250. * @param scene defines the scene to reference
  22251. * @param doNotAdd specifies if the material should be added to the scene
  22252. */
  22253. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22254. /**
  22255. * Returns a string representation of the current material
  22256. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22257. * @returns a string with material information
  22258. */
  22259. toString(fullDetails?: boolean): string;
  22260. /**
  22261. * Gets the class name of the material
  22262. * @returns a string with the class name of the material
  22263. */
  22264. getClassName(): string;
  22265. /**
  22266. * Specifies if updates for the material been locked
  22267. */
  22268. readonly isFrozen: boolean;
  22269. /**
  22270. * Locks updates for the material
  22271. */
  22272. freeze(): void;
  22273. /**
  22274. * Unlocks updates for the material
  22275. */
  22276. unfreeze(): void;
  22277. /**
  22278. * Specifies if the material is ready to be used
  22279. * @param mesh defines the mesh to check
  22280. * @param useInstances specifies if instances should be used
  22281. * @returns a boolean indicating if the material is ready to be used
  22282. */
  22283. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22284. /**
  22285. * Specifies that the submesh is ready to be used
  22286. * @param mesh defines the mesh to check
  22287. * @param subMesh defines which submesh to check
  22288. * @param useInstances specifies that instances should be used
  22289. * @returns a boolean indicating that the submesh is ready or not
  22290. */
  22291. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22292. /**
  22293. * Returns the material effect
  22294. * @returns the effect associated with the material
  22295. */
  22296. getEffect(): Nullable<Effect>;
  22297. /**
  22298. * Returns the current scene
  22299. * @returns a Scene
  22300. */
  22301. getScene(): Scene;
  22302. /**
  22303. * Specifies if the material will require alpha blending
  22304. * @returns a boolean specifying if alpha blending is needed
  22305. */
  22306. needAlphaBlending(): boolean;
  22307. /**
  22308. * Specifies if the mesh will require alpha blending
  22309. * @param mesh defines the mesh to check
  22310. * @returns a boolean specifying if alpha blending is needed for the mesh
  22311. */
  22312. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22313. /**
  22314. * Specifies if this material should be rendered in alpha test mode
  22315. * @returns a boolean specifying if an alpha test is needed.
  22316. */
  22317. needAlphaTesting(): boolean;
  22318. /**
  22319. * Gets the texture used for the alpha test
  22320. * @returns the texture to use for alpha testing
  22321. */
  22322. getAlphaTestTexture(): Nullable<BaseTexture>;
  22323. /**
  22324. * Marks the material to indicate that it needs to be re-calculated
  22325. */
  22326. markDirty(): void;
  22327. /** @hidden */
  22328. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22329. /**
  22330. * Binds the material to the mesh
  22331. * @param world defines the world transformation matrix
  22332. * @param mesh defines the mesh to bind the material to
  22333. */
  22334. bind(world: Matrix, mesh?: Mesh): void;
  22335. /**
  22336. * Binds the submesh to the material
  22337. * @param world defines the world transformation matrix
  22338. * @param mesh defines the mesh containing the submesh
  22339. * @param subMesh defines the submesh to bind the material to
  22340. */
  22341. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22342. /**
  22343. * Binds the world matrix to the material
  22344. * @param world defines the world transformation matrix
  22345. */
  22346. bindOnlyWorldMatrix(world: Matrix): void;
  22347. /**
  22348. * Binds the scene's uniform buffer to the effect.
  22349. * @param effect defines the effect to bind to the scene uniform buffer
  22350. * @param sceneUbo defines the uniform buffer storing scene data
  22351. */
  22352. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22353. /**
  22354. * Binds the view matrix to the effect
  22355. * @param effect defines the effect to bind the view matrix to
  22356. */
  22357. bindView(effect: Effect): void;
  22358. /**
  22359. * Binds the view projection matrix to the effect
  22360. * @param effect defines the effect to bind the view projection matrix to
  22361. */
  22362. bindViewProjection(effect: Effect): void;
  22363. /**
  22364. * Specifies if material alpha testing should be turned on for the mesh
  22365. * @param mesh defines the mesh to check
  22366. */
  22367. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22368. /**
  22369. * Processes to execute after binding the material to a mesh
  22370. * @param mesh defines the rendered mesh
  22371. */
  22372. protected _afterBind(mesh?: Mesh): void;
  22373. /**
  22374. * Unbinds the material from the mesh
  22375. */
  22376. unbind(): void;
  22377. /**
  22378. * Gets the active textures from the material
  22379. * @returns an array of textures
  22380. */
  22381. getActiveTextures(): BaseTexture[];
  22382. /**
  22383. * Specifies if the material uses a texture
  22384. * @param texture defines the texture to check against the material
  22385. * @returns a boolean specifying if the material uses the texture
  22386. */
  22387. hasTexture(texture: BaseTexture): boolean;
  22388. /**
  22389. * Makes a duplicate of the material, and gives it a new name
  22390. * @param name defines the new name for the duplicated material
  22391. * @returns the cloned material
  22392. */
  22393. clone(name: string): Nullable<Material>;
  22394. /**
  22395. * Gets the meshes bound to the material
  22396. * @returns an array of meshes bound to the material
  22397. */
  22398. getBindedMeshes(): AbstractMesh[];
  22399. /**
  22400. * Force shader compilation
  22401. * @param mesh defines the mesh associated with this material
  22402. * @param onCompiled defines a function to execute once the material is compiled
  22403. * @param options defines the options to configure the compilation
  22404. */
  22405. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22406. clipPlane: boolean;
  22407. }>): void;
  22408. /**
  22409. * Force shader compilation
  22410. * @param mesh defines the mesh that will use this material
  22411. * @param options defines additional options for compiling the shaders
  22412. * @returns a promise that resolves when the compilation completes
  22413. */
  22414. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22415. clipPlane: boolean;
  22416. }>): Promise<void>;
  22417. private static readonly _ImageProcessingDirtyCallBack;
  22418. private static readonly _TextureDirtyCallBack;
  22419. private static readonly _FresnelDirtyCallBack;
  22420. private static readonly _MiscDirtyCallBack;
  22421. private static readonly _LightsDirtyCallBack;
  22422. private static readonly _AttributeDirtyCallBack;
  22423. private static _FresnelAndMiscDirtyCallBack;
  22424. private static _TextureAndMiscDirtyCallBack;
  22425. private static readonly _DirtyCallbackArray;
  22426. private static readonly _RunDirtyCallBacks;
  22427. /**
  22428. * Marks a define in the material to indicate that it needs to be re-computed
  22429. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22430. */
  22431. markAsDirty(flag: number): void;
  22432. /**
  22433. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22434. * @param func defines a function which checks material defines against the submeshes
  22435. */
  22436. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22437. /**
  22438. * Indicates that image processing needs to be re-calculated for all submeshes
  22439. */
  22440. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22441. /**
  22442. * Indicates that textures need to be re-calculated for all submeshes
  22443. */
  22444. protected _markAllSubMeshesAsTexturesDirty(): void;
  22445. /**
  22446. * Indicates that fresnel needs to be re-calculated for all submeshes
  22447. */
  22448. protected _markAllSubMeshesAsFresnelDirty(): void;
  22449. /**
  22450. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22451. */
  22452. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22453. /**
  22454. * Indicates that lights need to be re-calculated for all submeshes
  22455. */
  22456. protected _markAllSubMeshesAsLightsDirty(): void;
  22457. /**
  22458. * Indicates that attributes need to be re-calculated for all submeshes
  22459. */
  22460. protected _markAllSubMeshesAsAttributesDirty(): void;
  22461. /**
  22462. * Indicates that misc needs to be re-calculated for all submeshes
  22463. */
  22464. protected _markAllSubMeshesAsMiscDirty(): void;
  22465. /**
  22466. * Indicates that textures and misc need to be re-calculated for all submeshes
  22467. */
  22468. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22469. /**
  22470. * Disposes the material
  22471. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22472. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22473. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22474. */
  22475. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22476. /** @hidden */
  22477. private releaseVertexArrayObject;
  22478. /**
  22479. * Serializes this material
  22480. * @returns the serialized material object
  22481. */
  22482. serialize(): any;
  22483. /**
  22484. * Creates a material from parsed material data
  22485. * @param parsedMaterial defines parsed material data
  22486. * @param scene defines the hosting scene
  22487. * @param rootUrl defines the root URL to use to load textures
  22488. * @returns a new material
  22489. */
  22490. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22491. }
  22492. }
  22493. declare module BABYLON {
  22494. /**
  22495. * Base class for submeshes
  22496. */
  22497. export class BaseSubMesh {
  22498. /** @hidden */
  22499. _materialDefines: Nullable<MaterialDefines>;
  22500. /** @hidden */
  22501. _materialEffect: Nullable<Effect>;
  22502. /**
  22503. * Gets associated effect
  22504. */
  22505. readonly effect: Nullable<Effect>;
  22506. /**
  22507. * Sets associated effect (effect used to render this submesh)
  22508. * @param effect defines the effect to associate with
  22509. * @param defines defines the set of defines used to compile this effect
  22510. */
  22511. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22512. }
  22513. /**
  22514. * Defines a subdivision inside a mesh
  22515. */
  22516. export class SubMesh extends BaseSubMesh implements ICullable {
  22517. /** the material index to use */
  22518. materialIndex: number;
  22519. /** vertex index start */
  22520. verticesStart: number;
  22521. /** vertices count */
  22522. verticesCount: number;
  22523. /** index start */
  22524. indexStart: number;
  22525. /** indices count */
  22526. indexCount: number;
  22527. /** @hidden */
  22528. _linesIndexCount: number;
  22529. private _mesh;
  22530. private _renderingMesh;
  22531. private _boundingInfo;
  22532. private _linesIndexBuffer;
  22533. /** @hidden */
  22534. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22535. /** @hidden */
  22536. _trianglePlanes: Plane[];
  22537. /** @hidden */
  22538. _lastColliderTransformMatrix: Nullable<Matrix>;
  22539. /** @hidden */
  22540. _renderId: number;
  22541. /** @hidden */
  22542. _alphaIndex: number;
  22543. /** @hidden */
  22544. _distanceToCamera: number;
  22545. /** @hidden */
  22546. _id: number;
  22547. private _currentMaterial;
  22548. /**
  22549. * Add a new submesh to a mesh
  22550. * @param materialIndex defines the material index to use
  22551. * @param verticesStart defines vertex index start
  22552. * @param verticesCount defines vertices count
  22553. * @param indexStart defines index start
  22554. * @param indexCount defines indices count
  22555. * @param mesh defines the parent mesh
  22556. * @param renderingMesh defines an optional rendering mesh
  22557. * @param createBoundingBox defines if bounding box should be created for this submesh
  22558. * @returns the new submesh
  22559. */
  22560. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22561. /**
  22562. * Creates a new submesh
  22563. * @param materialIndex defines the material index to use
  22564. * @param verticesStart defines vertex index start
  22565. * @param verticesCount defines vertices count
  22566. * @param indexStart defines index start
  22567. * @param indexCount defines indices count
  22568. * @param mesh defines the parent mesh
  22569. * @param renderingMesh defines an optional rendering mesh
  22570. * @param createBoundingBox defines if bounding box should be created for this submesh
  22571. */
  22572. constructor(
  22573. /** the material index to use */
  22574. materialIndex: number,
  22575. /** vertex index start */
  22576. verticesStart: number,
  22577. /** vertices count */
  22578. verticesCount: number,
  22579. /** index start */
  22580. indexStart: number,
  22581. /** indices count */
  22582. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22583. /**
  22584. * Returns true if this submesh covers the entire parent mesh
  22585. * @ignorenaming
  22586. */
  22587. readonly IsGlobal: boolean;
  22588. /**
  22589. * Returns the submesh BoudingInfo object
  22590. * @returns current bounding info (or mesh's one if the submesh is global)
  22591. */
  22592. getBoundingInfo(): BoundingInfo;
  22593. /**
  22594. * Sets the submesh BoundingInfo
  22595. * @param boundingInfo defines the new bounding info to use
  22596. * @returns the SubMesh
  22597. */
  22598. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22599. /**
  22600. * Returns the mesh of the current submesh
  22601. * @return the parent mesh
  22602. */
  22603. getMesh(): AbstractMesh;
  22604. /**
  22605. * Returns the rendering mesh of the submesh
  22606. * @returns the rendering mesh (could be different from parent mesh)
  22607. */
  22608. getRenderingMesh(): Mesh;
  22609. /**
  22610. * Returns the submesh material
  22611. * @returns null or the current material
  22612. */
  22613. getMaterial(): Nullable<Material>;
  22614. /**
  22615. * Sets a new updated BoundingInfo object to the submesh
  22616. * @param data defines an optional position array to use to determine the bounding info
  22617. * @returns the SubMesh
  22618. */
  22619. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22620. /** @hidden */
  22621. _checkCollision(collider: Collider): boolean;
  22622. /**
  22623. * Updates the submesh BoundingInfo
  22624. * @param world defines the world matrix to use to update the bounding info
  22625. * @returns the submesh
  22626. */
  22627. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22628. /**
  22629. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22630. * @param frustumPlanes defines the frustum planes
  22631. * @returns true if the submesh is intersecting with the frustum
  22632. */
  22633. isInFrustum(frustumPlanes: Plane[]): boolean;
  22634. /**
  22635. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22636. * @param frustumPlanes defines the frustum planes
  22637. * @returns true if the submesh is inside the frustum
  22638. */
  22639. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22640. /**
  22641. * Renders the submesh
  22642. * @param enableAlphaMode defines if alpha needs to be used
  22643. * @returns the submesh
  22644. */
  22645. render(enableAlphaMode: boolean): SubMesh;
  22646. /**
  22647. * @hidden
  22648. */
  22649. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22650. /**
  22651. * Checks if the submesh intersects with a ray
  22652. * @param ray defines the ray to test
  22653. * @returns true is the passed ray intersects the submesh bounding box
  22654. */
  22655. canIntersects(ray: Ray): boolean;
  22656. /**
  22657. * Intersects current submesh with a ray
  22658. * @param ray defines the ray to test
  22659. * @param positions defines mesh's positions array
  22660. * @param indices defines mesh's indices array
  22661. * @param fastCheck defines if only bounding info should be used
  22662. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22663. * @returns intersection info or null if no intersection
  22664. */
  22665. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22666. /** @hidden */
  22667. private _intersectLines;
  22668. /** @hidden */
  22669. private _intersectUnIndexedLines;
  22670. /** @hidden */
  22671. private _intersectTriangles;
  22672. /** @hidden */
  22673. private _intersectUnIndexedTriangles;
  22674. /** @hidden */
  22675. _rebuild(): void;
  22676. /**
  22677. * Creates a new submesh from the passed mesh
  22678. * @param newMesh defines the new hosting mesh
  22679. * @param newRenderingMesh defines an optional rendering mesh
  22680. * @returns the new submesh
  22681. */
  22682. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22683. /**
  22684. * Release associated resources
  22685. */
  22686. dispose(): void;
  22687. /**
  22688. * Gets the class name
  22689. * @returns the string "SubMesh".
  22690. */
  22691. getClassName(): string;
  22692. /**
  22693. * Creates a new submesh from indices data
  22694. * @param materialIndex the index of the main mesh material
  22695. * @param startIndex the index where to start the copy in the mesh indices array
  22696. * @param indexCount the number of indices to copy then from the startIndex
  22697. * @param mesh the main mesh to create the submesh from
  22698. * @param renderingMesh the optional rendering mesh
  22699. * @returns a new submesh
  22700. */
  22701. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22702. }
  22703. }
  22704. declare module BABYLON {
  22705. /**
  22706. * Class used to store geometry data (vertex buffers + index buffer)
  22707. */
  22708. export class Geometry implements IGetSetVerticesData {
  22709. /**
  22710. * Gets or sets the ID of the geometry
  22711. */
  22712. id: string;
  22713. /**
  22714. * Gets or sets the unique ID of the geometry
  22715. */
  22716. uniqueId: number;
  22717. /**
  22718. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22719. */
  22720. delayLoadState: number;
  22721. /**
  22722. * Gets the file containing the data to load when running in delay load state
  22723. */
  22724. delayLoadingFile: Nullable<string>;
  22725. /**
  22726. * Callback called when the geometry is updated
  22727. */
  22728. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22729. private _scene;
  22730. private _engine;
  22731. private _meshes;
  22732. private _totalVertices;
  22733. /** @hidden */
  22734. _indices: IndicesArray;
  22735. /** @hidden */
  22736. _vertexBuffers: {
  22737. [key: string]: VertexBuffer;
  22738. };
  22739. private _isDisposed;
  22740. private _extend;
  22741. private _boundingBias;
  22742. /** @hidden */
  22743. _delayInfo: Array<string>;
  22744. private _indexBuffer;
  22745. private _indexBufferIsUpdatable;
  22746. /** @hidden */
  22747. _boundingInfo: Nullable<BoundingInfo>;
  22748. /** @hidden */
  22749. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22750. /** @hidden */
  22751. _softwareSkinningFrameId: number;
  22752. private _vertexArrayObjects;
  22753. private _updatable;
  22754. /** @hidden */
  22755. _positions: Nullable<Vector3[]>;
  22756. /**
  22757. * 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
  22758. */
  22759. /**
  22760. * 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
  22761. */
  22762. boundingBias: Vector2;
  22763. /**
  22764. * Static function used to attach a new empty geometry to a mesh
  22765. * @param mesh defines the mesh to attach the geometry to
  22766. * @returns the new Geometry
  22767. */
  22768. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22769. /**
  22770. * Creates a new geometry
  22771. * @param id defines the unique ID
  22772. * @param scene defines the hosting scene
  22773. * @param vertexData defines the VertexData used to get geometry data
  22774. * @param updatable defines if geometry must be updatable (false by default)
  22775. * @param mesh defines the mesh that will be associated with the geometry
  22776. */
  22777. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22778. /**
  22779. * Gets the current extend of the geometry
  22780. */
  22781. readonly extend: {
  22782. minimum: Vector3;
  22783. maximum: Vector3;
  22784. };
  22785. /**
  22786. * Gets the hosting scene
  22787. * @returns the hosting Scene
  22788. */
  22789. getScene(): Scene;
  22790. /**
  22791. * Gets the hosting engine
  22792. * @returns the hosting Engine
  22793. */
  22794. getEngine(): Engine;
  22795. /**
  22796. * Defines if the geometry is ready to use
  22797. * @returns true if the geometry is ready to be used
  22798. */
  22799. isReady(): boolean;
  22800. /**
  22801. * Gets a value indicating that the geometry should not be serialized
  22802. */
  22803. readonly doNotSerialize: boolean;
  22804. /** @hidden */
  22805. _rebuild(): void;
  22806. /**
  22807. * Affects all geometry data in one call
  22808. * @param vertexData defines the geometry data
  22809. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22810. */
  22811. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22812. /**
  22813. * Set specific vertex data
  22814. * @param kind defines the data kind (Position, normal, etc...)
  22815. * @param data defines the vertex data to use
  22816. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22817. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22818. */
  22819. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22820. /**
  22821. * Removes a specific vertex data
  22822. * @param kind defines the data kind (Position, normal, etc...)
  22823. */
  22824. removeVerticesData(kind: string): void;
  22825. /**
  22826. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22827. * @param buffer defines the vertex buffer to use
  22828. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22829. */
  22830. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22831. /**
  22832. * Update a specific vertex buffer
  22833. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22834. * It will do nothing if the buffer is not updatable
  22835. * @param kind defines the data kind (Position, normal, etc...)
  22836. * @param data defines the data to use
  22837. * @param offset defines the offset in the target buffer where to store the data
  22838. * @param useBytes set to true if the offset is in bytes
  22839. */
  22840. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22841. /**
  22842. * Update a specific vertex buffer
  22843. * This function will create a new buffer if the current one is not updatable
  22844. * @param kind defines the data kind (Position, normal, etc...)
  22845. * @param data defines the data to use
  22846. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22847. */
  22848. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22849. private _updateBoundingInfo;
  22850. /** @hidden */
  22851. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22852. /**
  22853. * Gets total number of vertices
  22854. * @returns the total number of vertices
  22855. */
  22856. getTotalVertices(): number;
  22857. /**
  22858. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22859. * @param kind defines the data kind (Position, normal, etc...)
  22860. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22861. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22862. * @returns a float array containing vertex data
  22863. */
  22864. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22865. /**
  22866. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22867. * @param kind defines the data kind (Position, normal, etc...)
  22868. * @returns true if the vertex buffer with the specified kind is updatable
  22869. */
  22870. isVertexBufferUpdatable(kind: string): boolean;
  22871. /**
  22872. * Gets a specific vertex buffer
  22873. * @param kind defines the data kind (Position, normal, etc...)
  22874. * @returns a VertexBuffer
  22875. */
  22876. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22877. /**
  22878. * Returns all vertex buffers
  22879. * @return an object holding all vertex buffers indexed by kind
  22880. */
  22881. getVertexBuffers(): Nullable<{
  22882. [key: string]: VertexBuffer;
  22883. }>;
  22884. /**
  22885. * Gets a boolean indicating if specific vertex buffer is present
  22886. * @param kind defines the data kind (Position, normal, etc...)
  22887. * @returns true if data is present
  22888. */
  22889. isVerticesDataPresent(kind: string): boolean;
  22890. /**
  22891. * Gets a list of all attached data kinds (Position, normal, etc...)
  22892. * @returns a list of string containing all kinds
  22893. */
  22894. getVerticesDataKinds(): string[];
  22895. /**
  22896. * Update index buffer
  22897. * @param indices defines the indices to store in the index buffer
  22898. * @param offset defines the offset in the target buffer where to store the data
  22899. * @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)
  22900. */
  22901. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22902. /**
  22903. * Creates a new index buffer
  22904. * @param indices defines the indices to store in the index buffer
  22905. * @param totalVertices defines the total number of vertices (could be null)
  22906. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22907. */
  22908. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22909. /**
  22910. * Return the total number of indices
  22911. * @returns the total number of indices
  22912. */
  22913. getTotalIndices(): number;
  22914. /**
  22915. * Gets the index buffer array
  22916. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22917. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22918. * @returns the index buffer array
  22919. */
  22920. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22921. /**
  22922. * Gets the index buffer
  22923. * @return the index buffer
  22924. */
  22925. getIndexBuffer(): Nullable<DataBuffer>;
  22926. /** @hidden */
  22927. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22928. /**
  22929. * Release the associated resources for a specific mesh
  22930. * @param mesh defines the source mesh
  22931. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22932. */
  22933. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22934. /**
  22935. * Apply current geometry to a given mesh
  22936. * @param mesh defines the mesh to apply geometry to
  22937. */
  22938. applyToMesh(mesh: Mesh): void;
  22939. private _updateExtend;
  22940. private _applyToMesh;
  22941. private notifyUpdate;
  22942. /**
  22943. * Load the geometry if it was flagged as delay loaded
  22944. * @param scene defines the hosting scene
  22945. * @param onLoaded defines a callback called when the geometry is loaded
  22946. */
  22947. load(scene: Scene, onLoaded?: () => void): void;
  22948. private _queueLoad;
  22949. /**
  22950. * Invert the geometry to move from a right handed system to a left handed one.
  22951. */
  22952. toLeftHanded(): void;
  22953. /** @hidden */
  22954. _resetPointsArrayCache(): void;
  22955. /** @hidden */
  22956. _generatePointsArray(): boolean;
  22957. /**
  22958. * Gets a value indicating if the geometry is disposed
  22959. * @returns true if the geometry was disposed
  22960. */
  22961. isDisposed(): boolean;
  22962. private _disposeVertexArrayObjects;
  22963. /**
  22964. * Free all associated resources
  22965. */
  22966. dispose(): void;
  22967. /**
  22968. * Clone the current geometry into a new geometry
  22969. * @param id defines the unique ID of the new geometry
  22970. * @returns a new geometry object
  22971. */
  22972. copy(id: string): Geometry;
  22973. /**
  22974. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22975. * @return a JSON representation of the current geometry data (without the vertices data)
  22976. */
  22977. serialize(): any;
  22978. private toNumberArray;
  22979. /**
  22980. * Serialize all vertices data into a JSON oject
  22981. * @returns a JSON representation of the current geometry data
  22982. */
  22983. serializeVerticeData(): any;
  22984. /**
  22985. * Extracts a clone of a mesh geometry
  22986. * @param mesh defines the source mesh
  22987. * @param id defines the unique ID of the new geometry object
  22988. * @returns the new geometry object
  22989. */
  22990. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22991. /**
  22992. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22993. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22994. * Be aware Math.random() could cause collisions, but:
  22995. * "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"
  22996. * @returns a string containing a new GUID
  22997. */
  22998. static RandomId(): string;
  22999. /** @hidden */
  23000. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23001. private static _CleanMatricesWeights;
  23002. /**
  23003. * Create a new geometry from persisted data (Using .babylon file format)
  23004. * @param parsedVertexData defines the persisted data
  23005. * @param scene defines the hosting scene
  23006. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23007. * @returns the new geometry object
  23008. */
  23009. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23010. }
  23011. }
  23012. declare module BABYLON {
  23013. /**
  23014. * Define an interface for all classes that will get and set the data on vertices
  23015. */
  23016. export interface IGetSetVerticesData {
  23017. /**
  23018. * Gets a boolean indicating if specific vertex data is present
  23019. * @param kind defines the vertex data kind to use
  23020. * @returns true is data kind is present
  23021. */
  23022. isVerticesDataPresent(kind: string): boolean;
  23023. /**
  23024. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23025. * @param kind defines the data kind (Position, normal, etc...)
  23026. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23027. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23028. * @returns a float array containing vertex data
  23029. */
  23030. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23031. /**
  23032. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23033. * @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.
  23034. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23035. * @returns the indices array or an empty array if the mesh has no geometry
  23036. */
  23037. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23038. /**
  23039. * Set specific vertex data
  23040. * @param kind defines the data kind (Position, normal, etc...)
  23041. * @param data defines the vertex data to use
  23042. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23043. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23044. */
  23045. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23046. /**
  23047. * Update a specific associated vertex buffer
  23048. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23049. * - VertexBuffer.PositionKind
  23050. * - VertexBuffer.UVKind
  23051. * - VertexBuffer.UV2Kind
  23052. * - VertexBuffer.UV3Kind
  23053. * - VertexBuffer.UV4Kind
  23054. * - VertexBuffer.UV5Kind
  23055. * - VertexBuffer.UV6Kind
  23056. * - VertexBuffer.ColorKind
  23057. * - VertexBuffer.MatricesIndicesKind
  23058. * - VertexBuffer.MatricesIndicesExtraKind
  23059. * - VertexBuffer.MatricesWeightsKind
  23060. * - VertexBuffer.MatricesWeightsExtraKind
  23061. * @param data defines the data source
  23062. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23063. * @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)
  23064. */
  23065. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23066. /**
  23067. * Creates a new index buffer
  23068. * @param indices defines the indices to store in the index buffer
  23069. * @param totalVertices defines the total number of vertices (could be null)
  23070. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23071. */
  23072. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23073. }
  23074. /**
  23075. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23076. */
  23077. export class VertexData {
  23078. /**
  23079. * Mesh side orientation : usually the external or front surface
  23080. */
  23081. static readonly FRONTSIDE: number;
  23082. /**
  23083. * Mesh side orientation : usually the internal or back surface
  23084. */
  23085. static readonly BACKSIDE: number;
  23086. /**
  23087. * Mesh side orientation : both internal and external or front and back surfaces
  23088. */
  23089. static readonly DOUBLESIDE: number;
  23090. /**
  23091. * Mesh side orientation : by default, `FRONTSIDE`
  23092. */
  23093. static readonly DEFAULTSIDE: number;
  23094. /**
  23095. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23096. */
  23097. positions: Nullable<FloatArray>;
  23098. /**
  23099. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23100. */
  23101. normals: Nullable<FloatArray>;
  23102. /**
  23103. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23104. */
  23105. tangents: Nullable<FloatArray>;
  23106. /**
  23107. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23108. */
  23109. uvs: Nullable<FloatArray>;
  23110. /**
  23111. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23112. */
  23113. uvs2: Nullable<FloatArray>;
  23114. /**
  23115. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23116. */
  23117. uvs3: Nullable<FloatArray>;
  23118. /**
  23119. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23120. */
  23121. uvs4: Nullable<FloatArray>;
  23122. /**
  23123. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23124. */
  23125. uvs5: Nullable<FloatArray>;
  23126. /**
  23127. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23128. */
  23129. uvs6: Nullable<FloatArray>;
  23130. /**
  23131. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23132. */
  23133. colors: Nullable<FloatArray>;
  23134. /**
  23135. * 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).
  23136. */
  23137. matricesIndices: Nullable<FloatArray>;
  23138. /**
  23139. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23140. */
  23141. matricesWeights: Nullable<FloatArray>;
  23142. /**
  23143. * An array extending the number of possible indices
  23144. */
  23145. matricesIndicesExtra: Nullable<FloatArray>;
  23146. /**
  23147. * An array extending the number of possible weights when the number of indices is extended
  23148. */
  23149. matricesWeightsExtra: Nullable<FloatArray>;
  23150. /**
  23151. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23152. */
  23153. indices: Nullable<IndicesArray>;
  23154. /**
  23155. * Uses the passed data array to set the set the values for the specified kind of data
  23156. * @param data a linear array of floating numbers
  23157. * @param kind the type of data that is being set, eg positions, colors etc
  23158. */
  23159. set(data: FloatArray, kind: string): void;
  23160. /**
  23161. * Associates the vertexData to the passed Mesh.
  23162. * Sets it as updatable or not (default `false`)
  23163. * @param mesh the mesh the vertexData is applied to
  23164. * @param updatable when used and having the value true allows new data to update the vertexData
  23165. * @returns the VertexData
  23166. */
  23167. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23168. /**
  23169. * Associates the vertexData to the passed Geometry.
  23170. * Sets it as updatable or not (default `false`)
  23171. * @param geometry the geometry the vertexData is applied to
  23172. * @param updatable when used and having the value true allows new data to update the vertexData
  23173. * @returns VertexData
  23174. */
  23175. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23176. /**
  23177. * Updates the associated mesh
  23178. * @param mesh the mesh to be updated
  23179. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23180. * @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
  23181. * @returns VertexData
  23182. */
  23183. updateMesh(mesh: Mesh): VertexData;
  23184. /**
  23185. * Updates the associated geometry
  23186. * @param geometry the geometry to be updated
  23187. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23188. * @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
  23189. * @returns VertexData.
  23190. */
  23191. updateGeometry(geometry: Geometry): VertexData;
  23192. private _applyTo;
  23193. private _update;
  23194. /**
  23195. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23196. * @param matrix the transforming matrix
  23197. * @returns the VertexData
  23198. */
  23199. transform(matrix: Matrix): VertexData;
  23200. /**
  23201. * Merges the passed VertexData into the current one
  23202. * @param other the VertexData to be merged into the current one
  23203. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23204. * @returns the modified VertexData
  23205. */
  23206. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23207. private _mergeElement;
  23208. private _validate;
  23209. /**
  23210. * Serializes the VertexData
  23211. * @returns a serialized object
  23212. */
  23213. serialize(): any;
  23214. /**
  23215. * Extracts the vertexData from a mesh
  23216. * @param mesh the mesh from which to extract the VertexData
  23217. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23218. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23219. * @returns the object VertexData associated to the passed mesh
  23220. */
  23221. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23222. /**
  23223. * Extracts the vertexData from the geometry
  23224. * @param geometry the geometry from which to extract the VertexData
  23225. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23226. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23227. * @returns the object VertexData associated to the passed mesh
  23228. */
  23229. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23230. private static _ExtractFrom;
  23231. /**
  23232. * Creates the VertexData for a Ribbon
  23233. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23234. * * pathArray array of paths, each of which an array of successive Vector3
  23235. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23236. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23237. * * 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
  23238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23239. * * 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)
  23240. * * 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)
  23241. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23242. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23243. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23244. * @returns the VertexData of the ribbon
  23245. */
  23246. static CreateRibbon(options: {
  23247. pathArray: Vector3[][];
  23248. closeArray?: boolean;
  23249. closePath?: boolean;
  23250. offset?: number;
  23251. sideOrientation?: number;
  23252. frontUVs?: Vector4;
  23253. backUVs?: Vector4;
  23254. invertUV?: boolean;
  23255. uvs?: Vector2[];
  23256. colors?: Color4[];
  23257. }): VertexData;
  23258. /**
  23259. * Creates the VertexData for a box
  23260. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23261. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23262. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23263. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23264. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23265. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23266. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23268. * * 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)
  23269. * * 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)
  23270. * @returns the VertexData of the box
  23271. */
  23272. static CreateBox(options: {
  23273. size?: number;
  23274. width?: number;
  23275. height?: number;
  23276. depth?: number;
  23277. faceUV?: Vector4[];
  23278. faceColors?: Color4[];
  23279. sideOrientation?: number;
  23280. frontUVs?: Vector4;
  23281. backUVs?: Vector4;
  23282. }): VertexData;
  23283. /**
  23284. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23285. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23286. * * segments sets the number of horizontal strips optional, default 32
  23287. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23288. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23289. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23290. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23291. * * 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
  23292. * * 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
  23293. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23294. * * 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)
  23295. * * 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)
  23296. * @returns the VertexData of the ellipsoid
  23297. */
  23298. static CreateSphere(options: {
  23299. segments?: number;
  23300. diameter?: number;
  23301. diameterX?: number;
  23302. diameterY?: number;
  23303. diameterZ?: number;
  23304. arc?: number;
  23305. slice?: number;
  23306. sideOrientation?: number;
  23307. frontUVs?: Vector4;
  23308. backUVs?: Vector4;
  23309. }): VertexData;
  23310. /**
  23311. * Creates the VertexData for a cylinder, cone or prism
  23312. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23313. * * height sets the height (y direction) of the cylinder, optional, default 2
  23314. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23315. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23316. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23317. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23318. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23319. * * 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
  23320. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23321. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23322. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23323. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23325. * * 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)
  23326. * * 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)
  23327. * @returns the VertexData of the cylinder, cone or prism
  23328. */
  23329. static CreateCylinder(options: {
  23330. height?: number;
  23331. diameterTop?: number;
  23332. diameterBottom?: number;
  23333. diameter?: number;
  23334. tessellation?: number;
  23335. subdivisions?: number;
  23336. arc?: number;
  23337. faceColors?: Color4[];
  23338. faceUV?: Vector4[];
  23339. hasRings?: boolean;
  23340. enclose?: boolean;
  23341. sideOrientation?: number;
  23342. frontUVs?: Vector4;
  23343. backUVs?: Vector4;
  23344. }): VertexData;
  23345. /**
  23346. * Creates the VertexData for a torus
  23347. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23348. * * diameter the diameter of the torus, optional default 1
  23349. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23350. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23352. * * 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)
  23353. * * 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)
  23354. * @returns the VertexData of the torus
  23355. */
  23356. static CreateTorus(options: {
  23357. diameter?: number;
  23358. thickness?: number;
  23359. tessellation?: number;
  23360. sideOrientation?: number;
  23361. frontUVs?: Vector4;
  23362. backUVs?: Vector4;
  23363. }): VertexData;
  23364. /**
  23365. * Creates the VertexData of the LineSystem
  23366. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23367. * - lines an array of lines, each line being an array of successive Vector3
  23368. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23369. * @returns the VertexData of the LineSystem
  23370. */
  23371. static CreateLineSystem(options: {
  23372. lines: Vector3[][];
  23373. colors?: Nullable<Color4[][]>;
  23374. }): VertexData;
  23375. /**
  23376. * Create the VertexData for a DashedLines
  23377. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23378. * - points an array successive Vector3
  23379. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23380. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23381. * - dashNb the intended total number of dashes, optional, default 200
  23382. * @returns the VertexData for the DashedLines
  23383. */
  23384. static CreateDashedLines(options: {
  23385. points: Vector3[];
  23386. dashSize?: number;
  23387. gapSize?: number;
  23388. dashNb?: number;
  23389. }): VertexData;
  23390. /**
  23391. * Creates the VertexData for a Ground
  23392. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23393. * - width the width (x direction) of the ground, optional, default 1
  23394. * - height the height (z direction) of the ground, optional, default 1
  23395. * - subdivisions the number of subdivisions per side, optional, default 1
  23396. * @returns the VertexData of the Ground
  23397. */
  23398. static CreateGround(options: {
  23399. width?: number;
  23400. height?: number;
  23401. subdivisions?: number;
  23402. subdivisionsX?: number;
  23403. subdivisionsY?: number;
  23404. }): VertexData;
  23405. /**
  23406. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23407. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23408. * * xmin the ground minimum X coordinate, optional, default -1
  23409. * * zmin the ground minimum Z coordinate, optional, default -1
  23410. * * xmax the ground maximum X coordinate, optional, default 1
  23411. * * zmax the ground maximum Z coordinate, optional, default 1
  23412. * * 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}
  23413. * * 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}
  23414. * @returns the VertexData of the TiledGround
  23415. */
  23416. static CreateTiledGround(options: {
  23417. xmin: number;
  23418. zmin: number;
  23419. xmax: number;
  23420. zmax: number;
  23421. subdivisions?: {
  23422. w: number;
  23423. h: number;
  23424. };
  23425. precision?: {
  23426. w: number;
  23427. h: number;
  23428. };
  23429. }): VertexData;
  23430. /**
  23431. * Creates the VertexData of the Ground designed from a heightmap
  23432. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23433. * * width the width (x direction) of the ground
  23434. * * height the height (z direction) of the ground
  23435. * * subdivisions the number of subdivisions per side
  23436. * * minHeight the minimum altitude on the ground, optional, default 0
  23437. * * maxHeight the maximum altitude on the ground, optional default 1
  23438. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23439. * * buffer the array holding the image color data
  23440. * * bufferWidth the width of image
  23441. * * bufferHeight the height of image
  23442. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23443. * @returns the VertexData of the Ground designed from a heightmap
  23444. */
  23445. static CreateGroundFromHeightMap(options: {
  23446. width: number;
  23447. height: number;
  23448. subdivisions: number;
  23449. minHeight: number;
  23450. maxHeight: number;
  23451. colorFilter: Color3;
  23452. buffer: Uint8Array;
  23453. bufferWidth: number;
  23454. bufferHeight: number;
  23455. alphaFilter: number;
  23456. }): VertexData;
  23457. /**
  23458. * Creates the VertexData for a Plane
  23459. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23460. * * size sets the width and height of the plane to the value of size, optional default 1
  23461. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23462. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23464. * * 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)
  23465. * * 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)
  23466. * @returns the VertexData of the box
  23467. */
  23468. static CreatePlane(options: {
  23469. size?: number;
  23470. width?: number;
  23471. height?: number;
  23472. sideOrientation?: number;
  23473. frontUVs?: Vector4;
  23474. backUVs?: Vector4;
  23475. }): VertexData;
  23476. /**
  23477. * Creates the VertexData of the Disc or regular Polygon
  23478. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23479. * * radius the radius of the disc, optional default 0.5
  23480. * * tessellation the number of polygon sides, optional, default 64
  23481. * * 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
  23482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23483. * * 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)
  23484. * * 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)
  23485. * @returns the VertexData of the box
  23486. */
  23487. static CreateDisc(options: {
  23488. radius?: number;
  23489. tessellation?: number;
  23490. arc?: number;
  23491. sideOrientation?: number;
  23492. frontUVs?: Vector4;
  23493. backUVs?: Vector4;
  23494. }): VertexData;
  23495. /**
  23496. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23497. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23498. * @param polygon a mesh built from polygonTriangulation.build()
  23499. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23500. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23501. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23502. * @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)
  23503. * @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)
  23504. * @returns the VertexData of the Polygon
  23505. */
  23506. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23507. /**
  23508. * Creates the VertexData of the IcoSphere
  23509. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23510. * * radius the radius of the IcoSphere, optional default 1
  23511. * * radiusX allows stretching in the x direction, optional, default radius
  23512. * * radiusY allows stretching in the y direction, optional, default radius
  23513. * * radiusZ allows stretching in the z direction, optional, default radius
  23514. * * flat when true creates a flat shaded mesh, optional, default true
  23515. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23517. * * 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)
  23518. * * 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)
  23519. * @returns the VertexData of the IcoSphere
  23520. */
  23521. static CreateIcoSphere(options: {
  23522. radius?: number;
  23523. radiusX?: number;
  23524. radiusY?: number;
  23525. radiusZ?: number;
  23526. flat?: boolean;
  23527. subdivisions?: number;
  23528. sideOrientation?: number;
  23529. frontUVs?: Vector4;
  23530. backUVs?: Vector4;
  23531. }): VertexData;
  23532. /**
  23533. * Creates the VertexData for a Polyhedron
  23534. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23535. * * type provided types are:
  23536. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23537. * * 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)
  23538. * * size the size of the IcoSphere, optional default 1
  23539. * * sizeX allows stretching in the x direction, optional, default size
  23540. * * sizeY allows stretching in the y direction, optional, default size
  23541. * * sizeZ allows stretching in the z direction, optional, default size
  23542. * * 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
  23543. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23544. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23545. * * flat when true creates a flat shaded mesh, optional, default true
  23546. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23548. * * 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)
  23549. * * 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)
  23550. * @returns the VertexData of the Polyhedron
  23551. */
  23552. static CreatePolyhedron(options: {
  23553. type?: number;
  23554. size?: number;
  23555. sizeX?: number;
  23556. sizeY?: number;
  23557. sizeZ?: number;
  23558. custom?: any;
  23559. faceUV?: Vector4[];
  23560. faceColors?: Color4[];
  23561. flat?: boolean;
  23562. sideOrientation?: number;
  23563. frontUVs?: Vector4;
  23564. backUVs?: Vector4;
  23565. }): VertexData;
  23566. /**
  23567. * Creates the VertexData for a TorusKnot
  23568. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23569. * * radius the radius of the torus knot, optional, default 2
  23570. * * tube the thickness of the tube, optional, default 0.5
  23571. * * radialSegments the number of sides on each tube segments, optional, default 32
  23572. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23573. * * p the number of windings around the z axis, optional, default 2
  23574. * * q the number of windings around the x axis, optional, default 3
  23575. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23576. * * 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)
  23577. * * 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)
  23578. * @returns the VertexData of the Torus Knot
  23579. */
  23580. static CreateTorusKnot(options: {
  23581. radius?: number;
  23582. tube?: number;
  23583. radialSegments?: number;
  23584. tubularSegments?: number;
  23585. p?: number;
  23586. q?: number;
  23587. sideOrientation?: number;
  23588. frontUVs?: Vector4;
  23589. backUVs?: Vector4;
  23590. }): VertexData;
  23591. /**
  23592. * Compute normals for given positions and indices
  23593. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23594. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23595. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23596. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23597. * * facetNormals : optional array of facet normals (vector3)
  23598. * * facetPositions : optional array of facet positions (vector3)
  23599. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23600. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23601. * * bInfo : optional bounding info, required for facetPartitioning computation
  23602. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23603. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23604. * * useRightHandedSystem: optional boolean to for right handed system computation
  23605. * * depthSort : optional boolean to enable the facet depth sort computation
  23606. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23607. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23608. */
  23609. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23610. facetNormals?: any;
  23611. facetPositions?: any;
  23612. facetPartitioning?: any;
  23613. ratio?: number;
  23614. bInfo?: any;
  23615. bbSize?: Vector3;
  23616. subDiv?: any;
  23617. useRightHandedSystem?: boolean;
  23618. depthSort?: boolean;
  23619. distanceTo?: Vector3;
  23620. depthSortedFacets?: any;
  23621. }): void;
  23622. /** @hidden */
  23623. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23624. /**
  23625. * Applies VertexData created from the imported parameters to the geometry
  23626. * @param parsedVertexData the parsed data from an imported file
  23627. * @param geometry the geometry to apply the VertexData to
  23628. */
  23629. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23630. }
  23631. }
  23632. declare module BABYLON {
  23633. /**
  23634. * Class containing static functions to help procedurally build meshes
  23635. */
  23636. export class DiscBuilder {
  23637. /**
  23638. * Creates a plane polygonal mesh. By default, this is a disc
  23639. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23640. * * 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
  23641. * * 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
  23642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23643. * * 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
  23644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23645. * @param name defines the name of the mesh
  23646. * @param options defines the options used to create the mesh
  23647. * @param scene defines the hosting scene
  23648. * @returns the plane polygonal mesh
  23649. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23650. */
  23651. static CreateDisc(name: string, options: {
  23652. radius?: number;
  23653. tessellation?: number;
  23654. arc?: number;
  23655. updatable?: boolean;
  23656. sideOrientation?: number;
  23657. frontUVs?: Vector4;
  23658. backUVs?: Vector4;
  23659. }, scene?: Nullable<Scene>): Mesh;
  23660. }
  23661. }
  23662. declare module BABYLON {
  23663. /**
  23664. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23665. *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.
  23666. * The SPS is also a particle system. It provides some methods to manage the particles.
  23667. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23668. *
  23669. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23670. */
  23671. export class SolidParticleSystem implements IDisposable {
  23672. /**
  23673. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23674. * Example : var p = SPS.particles[i];
  23675. */
  23676. particles: SolidParticle[];
  23677. /**
  23678. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23679. */
  23680. nbParticles: number;
  23681. /**
  23682. * If the particles must ever face the camera (default false). Useful for planar particles.
  23683. */
  23684. billboard: boolean;
  23685. /**
  23686. * Recompute normals when adding a shape
  23687. */
  23688. recomputeNormals: boolean;
  23689. /**
  23690. * This a counter ofr your own usage. It's not set by any SPS functions.
  23691. */
  23692. counter: number;
  23693. /**
  23694. * The SPS name. This name is also given to the underlying mesh.
  23695. */
  23696. name: string;
  23697. /**
  23698. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23699. */
  23700. mesh: Mesh;
  23701. /**
  23702. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23703. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23704. */
  23705. vars: any;
  23706. /**
  23707. * This array is populated when the SPS is set as 'pickable'.
  23708. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23709. * Each element of this array is an object `{idx: int, faceId: int}`.
  23710. * `idx` is the picked particle index in the `SPS.particles` array
  23711. * `faceId` is the picked face index counted within this particle.
  23712. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23713. */
  23714. pickedParticles: {
  23715. idx: number;
  23716. faceId: number;
  23717. }[];
  23718. /**
  23719. * This array is populated when `enableDepthSort` is set to true.
  23720. * Each element of this array is an instance of the class DepthSortedParticle.
  23721. */
  23722. depthSortedParticles: DepthSortedParticle[];
  23723. /**
  23724. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23725. * @hidden
  23726. */
  23727. _bSphereOnly: boolean;
  23728. /**
  23729. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23730. * @hidden
  23731. */
  23732. _bSphereRadiusFactor: number;
  23733. private _scene;
  23734. private _positions;
  23735. private _indices;
  23736. private _normals;
  23737. private _colors;
  23738. private _uvs;
  23739. private _indices32;
  23740. private _positions32;
  23741. private _normals32;
  23742. private _fixedNormal32;
  23743. private _colors32;
  23744. private _uvs32;
  23745. private _index;
  23746. private _updatable;
  23747. private _pickable;
  23748. private _isVisibilityBoxLocked;
  23749. private _alwaysVisible;
  23750. private _depthSort;
  23751. private _shapeCounter;
  23752. private _copy;
  23753. private _color;
  23754. private _computeParticleColor;
  23755. private _computeParticleTexture;
  23756. private _computeParticleRotation;
  23757. private _computeParticleVertex;
  23758. private _computeBoundingBox;
  23759. private _depthSortParticles;
  23760. private _camera;
  23761. private _mustUnrotateFixedNormals;
  23762. private _particlesIntersect;
  23763. private _needs32Bits;
  23764. /**
  23765. * Creates a SPS (Solid Particle System) object.
  23766. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23767. * @param scene (Scene) is the scene in which the SPS is added.
  23768. * @param options defines the options of the sps e.g.
  23769. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23770. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23771. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23772. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23773. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23774. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23775. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23776. */
  23777. constructor(name: string, scene: Scene, options?: {
  23778. updatable?: boolean;
  23779. isPickable?: boolean;
  23780. enableDepthSort?: boolean;
  23781. particleIntersection?: boolean;
  23782. boundingSphereOnly?: boolean;
  23783. bSphereRadiusFactor?: number;
  23784. });
  23785. /**
  23786. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23787. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23788. * @returns the created mesh
  23789. */
  23790. buildMesh(): Mesh;
  23791. /**
  23792. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23793. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23794. * Thus the particles generated from `digest()` have their property `position` set yet.
  23795. * @param mesh ( Mesh ) is the mesh to be digested
  23796. * @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
  23797. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23798. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23799. * @returns the current SPS
  23800. */
  23801. digest(mesh: Mesh, options?: {
  23802. facetNb?: number;
  23803. number?: number;
  23804. delta?: number;
  23805. }): SolidParticleSystem;
  23806. private _unrotateFixedNormals;
  23807. private _resetCopy;
  23808. private _meshBuilder;
  23809. private _posToShape;
  23810. private _uvsToShapeUV;
  23811. private _addParticle;
  23812. /**
  23813. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23814. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23815. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23816. * @param nb (positive integer) the number of particles to be created from this model
  23817. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23818. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23819. * @returns the number of shapes in the system
  23820. */
  23821. addShape(mesh: Mesh, nb: number, options?: {
  23822. positionFunction?: any;
  23823. vertexFunction?: any;
  23824. }): number;
  23825. private _rebuildParticle;
  23826. /**
  23827. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23828. * @returns the SPS.
  23829. */
  23830. rebuildMesh(): SolidParticleSystem;
  23831. /**
  23832. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23833. * This method calls `updateParticle()` for each particle of the SPS.
  23834. * For an animated SPS, it is usually called within the render loop.
  23835. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23836. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23837. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23838. * @returns the SPS.
  23839. */
  23840. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23841. /**
  23842. * Disposes the SPS.
  23843. */
  23844. dispose(): void;
  23845. /**
  23846. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23847. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23848. * @returns the SPS.
  23849. */
  23850. refreshVisibleSize(): SolidParticleSystem;
  23851. /**
  23852. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23853. * @param size the size (float) of the visibility box
  23854. * note : this doesn't lock the SPS mesh bounding box.
  23855. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23856. */
  23857. setVisibilityBox(size: number): void;
  23858. /**
  23859. * Gets whether the SPS as always visible or not
  23860. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23861. */
  23862. /**
  23863. * Sets the SPS as always visible or not
  23864. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23865. */
  23866. isAlwaysVisible: boolean;
  23867. /**
  23868. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23869. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23870. */
  23871. /**
  23872. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23873. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23874. */
  23875. isVisibilityBoxLocked: boolean;
  23876. /**
  23877. * Tells to `setParticles()` to compute the particle rotations or not.
  23878. * Default value : true. The SPS is faster when it's set to false.
  23879. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23880. */
  23881. /**
  23882. * Gets if `setParticles()` computes the particle rotations or not.
  23883. * Default value : true. The SPS is faster when it's set to false.
  23884. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23885. */
  23886. computeParticleRotation: boolean;
  23887. /**
  23888. * Tells to `setParticles()` to compute the particle colors or not.
  23889. * Default value : true. The SPS is faster when it's set to false.
  23890. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23891. */
  23892. /**
  23893. * Gets if `setParticles()` computes the particle colors or not.
  23894. * Default value : true. The SPS is faster when it's set to false.
  23895. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23896. */
  23897. computeParticleColor: boolean;
  23898. /**
  23899. * Gets if `setParticles()` computes the particle textures or not.
  23900. * Default value : true. The SPS is faster when it's set to false.
  23901. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23902. */
  23903. computeParticleTexture: boolean;
  23904. /**
  23905. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23906. * Default value : false. The SPS is faster when it's set to false.
  23907. * Note : the particle custom vertex positions aren't stored values.
  23908. */
  23909. /**
  23910. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23911. * Default value : false. The SPS is faster when it's set to false.
  23912. * Note : the particle custom vertex positions aren't stored values.
  23913. */
  23914. computeParticleVertex: boolean;
  23915. /**
  23916. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23917. */
  23918. /**
  23919. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23920. */
  23921. computeBoundingBox: boolean;
  23922. /**
  23923. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23924. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23925. * Default : `true`
  23926. */
  23927. /**
  23928. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23929. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23930. * Default : `true`
  23931. */
  23932. depthSortParticles: boolean;
  23933. /**
  23934. * This function does nothing. It may be overwritten to set all the particle first values.
  23935. * The SPS doesn't call this function, you may have to call it by your own.
  23936. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23937. */
  23938. initParticles(): void;
  23939. /**
  23940. * This function does nothing. It may be overwritten to recycle a particle.
  23941. * The SPS doesn't call this function, you may have to call it by your own.
  23942. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23943. * @param particle The particle to recycle
  23944. * @returns the recycled particle
  23945. */
  23946. recycleParticle(particle: SolidParticle): SolidParticle;
  23947. /**
  23948. * Updates a particle : this function should be overwritten by the user.
  23949. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23950. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23951. * @example : just set a particle position or velocity and recycle conditions
  23952. * @param particle The particle to update
  23953. * @returns the updated particle
  23954. */
  23955. updateParticle(particle: SolidParticle): SolidParticle;
  23956. /**
  23957. * Updates a vertex of a particle : it can be overwritten by the user.
  23958. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23959. * @param particle the current particle
  23960. * @param vertex the current index of the current particle
  23961. * @param pt the index of the current vertex in the particle shape
  23962. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23963. * @example : just set a vertex particle position
  23964. * @returns the updated vertex
  23965. */
  23966. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23967. /**
  23968. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23969. * This does nothing and may be overwritten by the user.
  23970. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23971. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23972. * @param update the boolean update value actually passed to setParticles()
  23973. */
  23974. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23975. /**
  23976. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23977. * This will be passed three parameters.
  23978. * This does nothing and may be overwritten by the user.
  23979. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23980. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23981. * @param update the boolean update value actually passed to setParticles()
  23982. */
  23983. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23984. }
  23985. }
  23986. declare module BABYLON {
  23987. /**
  23988. * Represents one particle of a solid particle system.
  23989. */
  23990. export class SolidParticle {
  23991. /**
  23992. * particle global index
  23993. */
  23994. idx: number;
  23995. /**
  23996. * The color of the particle
  23997. */
  23998. color: Nullable<Color4>;
  23999. /**
  24000. * The world space position of the particle.
  24001. */
  24002. position: Vector3;
  24003. /**
  24004. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24005. */
  24006. rotation: Vector3;
  24007. /**
  24008. * The world space rotation quaternion of the particle.
  24009. */
  24010. rotationQuaternion: Nullable<Quaternion>;
  24011. /**
  24012. * The scaling of the particle.
  24013. */
  24014. scaling: Vector3;
  24015. /**
  24016. * The uvs of the particle.
  24017. */
  24018. uvs: Vector4;
  24019. /**
  24020. * The current speed of the particle.
  24021. */
  24022. velocity: Vector3;
  24023. /**
  24024. * The pivot point in the particle local space.
  24025. */
  24026. pivot: Vector3;
  24027. /**
  24028. * Must the particle be translated from its pivot point in its local space ?
  24029. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24030. * Default : false
  24031. */
  24032. translateFromPivot: boolean;
  24033. /**
  24034. * Is the particle active or not ?
  24035. */
  24036. alive: boolean;
  24037. /**
  24038. * Is the particle visible or not ?
  24039. */
  24040. isVisible: boolean;
  24041. /**
  24042. * Index of this particle in the global "positions" array (Internal use)
  24043. * @hidden
  24044. */
  24045. _pos: number;
  24046. /**
  24047. * @hidden Index of this particle in the global "indices" array (Internal use)
  24048. */
  24049. _ind: number;
  24050. /**
  24051. * @hidden ModelShape of this particle (Internal use)
  24052. */
  24053. _model: ModelShape;
  24054. /**
  24055. * ModelShape id of this particle
  24056. */
  24057. shapeId: number;
  24058. /**
  24059. * Index of the particle in its shape id (Internal use)
  24060. */
  24061. idxInShape: number;
  24062. /**
  24063. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24064. */
  24065. _modelBoundingInfo: BoundingInfo;
  24066. /**
  24067. * @hidden Particle BoundingInfo object (Internal use)
  24068. */
  24069. _boundingInfo: BoundingInfo;
  24070. /**
  24071. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24072. */
  24073. _sps: SolidParticleSystem;
  24074. /**
  24075. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24076. */
  24077. _stillInvisible: boolean;
  24078. /**
  24079. * @hidden Last computed particle rotation matrix
  24080. */
  24081. _rotationMatrix: number[];
  24082. /**
  24083. * Parent particle Id, if any.
  24084. * Default null.
  24085. */
  24086. parentId: Nullable<number>;
  24087. /**
  24088. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24089. * The possible values are :
  24090. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24091. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24092. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24093. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24094. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24095. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24096. * */
  24097. cullingStrategy: number;
  24098. /**
  24099. * @hidden Internal global position in the SPS.
  24100. */
  24101. _globalPosition: Vector3;
  24102. /**
  24103. * Creates a Solid Particle object.
  24104. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24105. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24106. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24107. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24108. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24109. * @param shapeId (integer) is the model shape identifier in the SPS.
  24110. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24111. * @param sps defines the sps it is associated to
  24112. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24113. */
  24114. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24115. /**
  24116. * Legacy support, changed scale to scaling
  24117. */
  24118. /**
  24119. * Legacy support, changed scale to scaling
  24120. */
  24121. scale: Vector3;
  24122. /**
  24123. * Legacy support, changed quaternion to rotationQuaternion
  24124. */
  24125. /**
  24126. * Legacy support, changed quaternion to rotationQuaternion
  24127. */
  24128. quaternion: Nullable<Quaternion>;
  24129. /**
  24130. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24131. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24132. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24133. * @returns true if it intersects
  24134. */
  24135. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24136. /**
  24137. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24138. * A particle is in the frustum if its bounding box intersects the frustum
  24139. * @param frustumPlanes defines the frustum to test
  24140. * @returns true if the particle is in the frustum planes
  24141. */
  24142. isInFrustum(frustumPlanes: Plane[]): boolean;
  24143. /**
  24144. * get the rotation matrix of the particle
  24145. * @hidden
  24146. */
  24147. getRotationMatrix(m: Matrix): void;
  24148. }
  24149. /**
  24150. * Represents the shape of the model used by one particle of a solid particle system.
  24151. * SPS internal tool, don't use it manually.
  24152. */
  24153. export class ModelShape {
  24154. /**
  24155. * The shape id
  24156. * @hidden
  24157. */
  24158. shapeID: number;
  24159. /**
  24160. * flat array of model positions (internal use)
  24161. * @hidden
  24162. */
  24163. _shape: Vector3[];
  24164. /**
  24165. * flat array of model UVs (internal use)
  24166. * @hidden
  24167. */
  24168. _shapeUV: number[];
  24169. /**
  24170. * length of the shape in the model indices array (internal use)
  24171. * @hidden
  24172. */
  24173. _indicesLength: number;
  24174. /**
  24175. * Custom position function (internal use)
  24176. * @hidden
  24177. */
  24178. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24179. /**
  24180. * Custom vertex function (internal use)
  24181. * @hidden
  24182. */
  24183. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24184. /**
  24185. * 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.
  24186. * SPS internal tool, don't use it manually.
  24187. * @hidden
  24188. */
  24189. 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>);
  24190. }
  24191. /**
  24192. * Represents a Depth Sorted Particle in the solid particle system.
  24193. */
  24194. export class DepthSortedParticle {
  24195. /**
  24196. * Index of the particle in the "indices" array
  24197. */
  24198. ind: number;
  24199. /**
  24200. * Length of the particle shape in the "indices" array
  24201. */
  24202. indicesLength: number;
  24203. /**
  24204. * Squared distance from the particle to the camera
  24205. */
  24206. sqDistance: number;
  24207. }
  24208. }
  24209. declare module BABYLON {
  24210. /**
  24211. * @hidden
  24212. */
  24213. export class _MeshCollisionData {
  24214. _checkCollisions: boolean;
  24215. _collisionMask: number;
  24216. _collisionGroup: number;
  24217. _collider: Nullable<Collider>;
  24218. _oldPositionForCollisions: Vector3;
  24219. _diffPositionForCollisions: Vector3;
  24220. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24221. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24222. }
  24223. }
  24224. declare module BABYLON {
  24225. /** @hidden */
  24226. class _FacetDataStorage {
  24227. facetPositions: Vector3[];
  24228. facetNormals: Vector3[];
  24229. facetPartitioning: number[][];
  24230. facetNb: number;
  24231. partitioningSubdivisions: number;
  24232. partitioningBBoxRatio: number;
  24233. facetDataEnabled: boolean;
  24234. facetParameters: any;
  24235. bbSize: Vector3;
  24236. subDiv: {
  24237. max: number;
  24238. X: number;
  24239. Y: number;
  24240. Z: number;
  24241. };
  24242. facetDepthSort: boolean;
  24243. facetDepthSortEnabled: boolean;
  24244. depthSortedIndices: IndicesArray;
  24245. depthSortedFacets: {
  24246. ind: number;
  24247. sqDistance: number;
  24248. }[];
  24249. facetDepthSortFunction: (f1: {
  24250. ind: number;
  24251. sqDistance: number;
  24252. }, f2: {
  24253. ind: number;
  24254. sqDistance: number;
  24255. }) => number;
  24256. facetDepthSortFrom: Vector3;
  24257. facetDepthSortOrigin: Vector3;
  24258. invertedMatrix: Matrix;
  24259. }
  24260. /**
  24261. * @hidden
  24262. **/
  24263. class _InternalAbstractMeshDataInfo {
  24264. _hasVertexAlpha: boolean;
  24265. _useVertexColors: boolean;
  24266. _numBoneInfluencers: number;
  24267. _applyFog: boolean;
  24268. _receiveShadows: boolean;
  24269. _facetData: _FacetDataStorage;
  24270. _visibility: number;
  24271. _skeleton: Nullable<Skeleton>;
  24272. _layerMask: number;
  24273. _computeBonesUsingShaders: boolean;
  24274. _isActive: boolean;
  24275. _onlyForInstances: boolean;
  24276. _isActiveIntermediate: boolean;
  24277. _onlyForInstancesIntermediate: boolean;
  24278. }
  24279. /**
  24280. * Class used to store all common mesh properties
  24281. */
  24282. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24283. /** No occlusion */
  24284. static OCCLUSION_TYPE_NONE: number;
  24285. /** Occlusion set to optimisitic */
  24286. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24287. /** Occlusion set to strict */
  24288. static OCCLUSION_TYPE_STRICT: number;
  24289. /** Use an accurante occlusion algorithm */
  24290. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24291. /** Use a conservative occlusion algorithm */
  24292. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24293. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24294. * Test order :
  24295. * Is the bounding sphere outside the frustum ?
  24296. * If not, are the bounding box vertices outside the frustum ?
  24297. * It not, then the cullable object is in the frustum.
  24298. */
  24299. static readonly CULLINGSTRATEGY_STANDARD: number;
  24300. /** Culling strategy : Bounding Sphere Only.
  24301. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24302. * It's also less accurate than the standard because some not visible objects can still be selected.
  24303. * Test : is the bounding sphere outside the frustum ?
  24304. * If not, then the cullable object is in the frustum.
  24305. */
  24306. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24307. /** Culling strategy : Optimistic Inclusion.
  24308. * This in an inclusion test first, then the standard exclusion test.
  24309. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24310. * 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.
  24311. * Anyway, it's as accurate as the standard strategy.
  24312. * Test :
  24313. * Is the cullable object bounding sphere center in the frustum ?
  24314. * If not, apply the default culling strategy.
  24315. */
  24316. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24317. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24318. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24319. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24320. * 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.
  24321. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24322. * Test :
  24323. * Is the cullable object bounding sphere center in the frustum ?
  24324. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24325. */
  24326. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24327. /**
  24328. * No billboard
  24329. */
  24330. static readonly BILLBOARDMODE_NONE: number;
  24331. /** Billboard on X axis */
  24332. static readonly BILLBOARDMODE_X: number;
  24333. /** Billboard on Y axis */
  24334. static readonly BILLBOARDMODE_Y: number;
  24335. /** Billboard on Z axis */
  24336. static readonly BILLBOARDMODE_Z: number;
  24337. /** Billboard on all axes */
  24338. static readonly BILLBOARDMODE_ALL: number;
  24339. /** @hidden */
  24340. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24341. /**
  24342. * The culling strategy to use to check whether the mesh must be rendered or not.
  24343. * This value can be changed at any time and will be used on the next render mesh selection.
  24344. * The possible values are :
  24345. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24346. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24347. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24348. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24349. * Please read each static variable documentation to get details about the culling process.
  24350. * */
  24351. cullingStrategy: number;
  24352. /**
  24353. * Gets the number of facets in the mesh
  24354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24355. */
  24356. readonly facetNb: number;
  24357. /**
  24358. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24359. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24360. */
  24361. partitioningSubdivisions: number;
  24362. /**
  24363. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24364. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24366. */
  24367. partitioningBBoxRatio: number;
  24368. /**
  24369. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24370. * Works only for updatable meshes.
  24371. * Doesn't work with multi-materials
  24372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24373. */
  24374. mustDepthSortFacets: boolean;
  24375. /**
  24376. * The location (Vector3) where the facet depth sort must be computed from.
  24377. * By default, the active camera position.
  24378. * Used only when facet depth sort is enabled
  24379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24380. */
  24381. facetDepthSortFrom: Vector3;
  24382. /**
  24383. * gets a boolean indicating if facetData is enabled
  24384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24385. */
  24386. readonly isFacetDataEnabled: boolean;
  24387. /** @hidden */
  24388. _updateNonUniformScalingState(value: boolean): boolean;
  24389. /**
  24390. * An event triggered when this mesh collides with another one
  24391. */
  24392. onCollideObservable: Observable<AbstractMesh>;
  24393. /** Set a function to call when this mesh collides with another one */
  24394. onCollide: () => void;
  24395. /**
  24396. * An event triggered when the collision's position changes
  24397. */
  24398. onCollisionPositionChangeObservable: Observable<Vector3>;
  24399. /** Set a function to call when the collision's position changes */
  24400. onCollisionPositionChange: () => void;
  24401. /**
  24402. * An event triggered when material is changed
  24403. */
  24404. onMaterialChangedObservable: Observable<AbstractMesh>;
  24405. /**
  24406. * Gets or sets the orientation for POV movement & rotation
  24407. */
  24408. definedFacingForward: boolean;
  24409. /** @hidden */
  24410. _occlusionQuery: Nullable<WebGLQuery>;
  24411. /** @hidden */
  24412. _renderingGroup: Nullable<RenderingGroup>;
  24413. /**
  24414. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24415. */
  24416. /**
  24417. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24418. */
  24419. visibility: number;
  24420. /** Gets or sets the alpha index used to sort transparent meshes
  24421. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24422. */
  24423. alphaIndex: number;
  24424. /**
  24425. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24426. */
  24427. isVisible: boolean;
  24428. /**
  24429. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24430. */
  24431. isPickable: boolean;
  24432. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24433. showSubMeshesBoundingBox: boolean;
  24434. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24435. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24436. */
  24437. isBlocker: boolean;
  24438. /**
  24439. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24440. */
  24441. enablePointerMoveEvents: boolean;
  24442. /**
  24443. * Specifies the rendering group id for this mesh (0 by default)
  24444. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24445. */
  24446. renderingGroupId: number;
  24447. private _material;
  24448. /** Gets or sets current material */
  24449. material: Nullable<Material>;
  24450. /**
  24451. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24452. * @see http://doc.babylonjs.com/babylon101/shadows
  24453. */
  24454. receiveShadows: boolean;
  24455. /** Defines color to use when rendering outline */
  24456. outlineColor: Color3;
  24457. /** Define width to use when rendering outline */
  24458. outlineWidth: number;
  24459. /** Defines color to use when rendering overlay */
  24460. overlayColor: Color3;
  24461. /** Defines alpha to use when rendering overlay */
  24462. overlayAlpha: number;
  24463. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24464. hasVertexAlpha: boolean;
  24465. /** 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) */
  24466. useVertexColors: boolean;
  24467. /**
  24468. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24469. */
  24470. computeBonesUsingShaders: boolean;
  24471. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24472. numBoneInfluencers: number;
  24473. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24474. applyFog: boolean;
  24475. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24476. useOctreeForRenderingSelection: boolean;
  24477. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24478. useOctreeForPicking: boolean;
  24479. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24480. useOctreeForCollisions: boolean;
  24481. /**
  24482. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24483. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24484. */
  24485. layerMask: number;
  24486. /**
  24487. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24488. */
  24489. alwaysSelectAsActiveMesh: boolean;
  24490. /**
  24491. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24492. */
  24493. doNotSyncBoundingInfo: boolean;
  24494. /**
  24495. * Gets or sets the current action manager
  24496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24497. */
  24498. actionManager: Nullable<AbstractActionManager>;
  24499. private _meshCollisionData;
  24500. /**
  24501. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24502. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24503. */
  24504. ellipsoid: Vector3;
  24505. /**
  24506. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24507. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24508. */
  24509. ellipsoidOffset: Vector3;
  24510. /**
  24511. * Gets or sets a collision mask used to mask collisions (default is -1).
  24512. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24513. */
  24514. collisionMask: number;
  24515. /**
  24516. * Gets or sets the current collision group mask (-1 by default).
  24517. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24518. */
  24519. collisionGroup: number;
  24520. /**
  24521. * Defines edge width used when edgesRenderer is enabled
  24522. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24523. */
  24524. edgesWidth: number;
  24525. /**
  24526. * Defines edge color used when edgesRenderer is enabled
  24527. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24528. */
  24529. edgesColor: Color4;
  24530. /** @hidden */
  24531. _edgesRenderer: Nullable<IEdgesRenderer>;
  24532. /** @hidden */
  24533. _masterMesh: Nullable<AbstractMesh>;
  24534. /** @hidden */
  24535. _boundingInfo: Nullable<BoundingInfo>;
  24536. /** @hidden */
  24537. _renderId: number;
  24538. /**
  24539. * Gets or sets the list of subMeshes
  24540. * @see http://doc.babylonjs.com/how_to/multi_materials
  24541. */
  24542. subMeshes: SubMesh[];
  24543. /** @hidden */
  24544. _intersectionsInProgress: AbstractMesh[];
  24545. /** @hidden */
  24546. _unIndexed: boolean;
  24547. /** @hidden */
  24548. _lightSources: Light[];
  24549. /** Gets the list of lights affecting that mesh */
  24550. readonly lightSources: Light[];
  24551. /** @hidden */
  24552. readonly _positions: Nullable<Vector3[]>;
  24553. /** @hidden */
  24554. _waitingData: {
  24555. lods: Nullable<any>;
  24556. actions: Nullable<any>;
  24557. freezeWorldMatrix: Nullable<boolean>;
  24558. };
  24559. /** @hidden */
  24560. _bonesTransformMatrices: Nullable<Float32Array>;
  24561. /**
  24562. * Gets or sets a skeleton to apply skining transformations
  24563. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24564. */
  24565. skeleton: Nullable<Skeleton>;
  24566. /**
  24567. * An event triggered when the mesh is rebuilt.
  24568. */
  24569. onRebuildObservable: Observable<AbstractMesh>;
  24570. /**
  24571. * Creates a new AbstractMesh
  24572. * @param name defines the name of the mesh
  24573. * @param scene defines the hosting scene
  24574. */
  24575. constructor(name: string, scene?: Nullable<Scene>);
  24576. /**
  24577. * Returns the string "AbstractMesh"
  24578. * @returns "AbstractMesh"
  24579. */
  24580. getClassName(): string;
  24581. /**
  24582. * Gets a string representation of the current mesh
  24583. * @param fullDetails defines a boolean indicating if full details must be included
  24584. * @returns a string representation of the current mesh
  24585. */
  24586. toString(fullDetails?: boolean): string;
  24587. /**
  24588. * @hidden
  24589. */
  24590. protected _getEffectiveParent(): Nullable<Node>;
  24591. /** @hidden */
  24592. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24593. /** @hidden */
  24594. _rebuild(): void;
  24595. /** @hidden */
  24596. _resyncLightSources(): void;
  24597. /** @hidden */
  24598. _resyncLighSource(light: Light): void;
  24599. /** @hidden */
  24600. _unBindEffect(): void;
  24601. /** @hidden */
  24602. _removeLightSource(light: Light): void;
  24603. private _markSubMeshesAsDirty;
  24604. /** @hidden */
  24605. _markSubMeshesAsLightDirty(): void;
  24606. /** @hidden */
  24607. _markSubMeshesAsAttributesDirty(): void;
  24608. /** @hidden */
  24609. _markSubMeshesAsMiscDirty(): void;
  24610. /**
  24611. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24612. */
  24613. scaling: Vector3;
  24614. /**
  24615. * Returns true if the mesh is blocked. Implemented by child classes
  24616. */
  24617. readonly isBlocked: boolean;
  24618. /**
  24619. * Returns the mesh itself by default. Implemented by child classes
  24620. * @param camera defines the camera to use to pick the right LOD level
  24621. * @returns the currentAbstractMesh
  24622. */
  24623. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24624. /**
  24625. * Returns 0 by default. Implemented by child classes
  24626. * @returns an integer
  24627. */
  24628. getTotalVertices(): number;
  24629. /**
  24630. * Returns a positive integer : the total number of indices in this mesh geometry.
  24631. * @returns the numner of indices or zero if the mesh has no geometry.
  24632. */
  24633. getTotalIndices(): number;
  24634. /**
  24635. * Returns null by default. Implemented by child classes
  24636. * @returns null
  24637. */
  24638. getIndices(): Nullable<IndicesArray>;
  24639. /**
  24640. * Returns the array of the requested vertex data kind. Implemented by child classes
  24641. * @param kind defines the vertex data kind to use
  24642. * @returns null
  24643. */
  24644. getVerticesData(kind: string): Nullable<FloatArray>;
  24645. /**
  24646. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24647. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24648. * Note that a new underlying VertexBuffer object is created each call.
  24649. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24650. * @param kind defines vertex data kind:
  24651. * * VertexBuffer.PositionKind
  24652. * * VertexBuffer.UVKind
  24653. * * VertexBuffer.UV2Kind
  24654. * * VertexBuffer.UV3Kind
  24655. * * VertexBuffer.UV4Kind
  24656. * * VertexBuffer.UV5Kind
  24657. * * VertexBuffer.UV6Kind
  24658. * * VertexBuffer.ColorKind
  24659. * * VertexBuffer.MatricesIndicesKind
  24660. * * VertexBuffer.MatricesIndicesExtraKind
  24661. * * VertexBuffer.MatricesWeightsKind
  24662. * * VertexBuffer.MatricesWeightsExtraKind
  24663. * @param data defines the data source
  24664. * @param updatable defines if the data must be flagged as updatable (or static)
  24665. * @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
  24666. * @returns the current mesh
  24667. */
  24668. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24669. /**
  24670. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24671. * If the mesh has no geometry, it is simply returned as it is.
  24672. * @param kind defines vertex data kind:
  24673. * * VertexBuffer.PositionKind
  24674. * * VertexBuffer.UVKind
  24675. * * VertexBuffer.UV2Kind
  24676. * * VertexBuffer.UV3Kind
  24677. * * VertexBuffer.UV4Kind
  24678. * * VertexBuffer.UV5Kind
  24679. * * VertexBuffer.UV6Kind
  24680. * * VertexBuffer.ColorKind
  24681. * * VertexBuffer.MatricesIndicesKind
  24682. * * VertexBuffer.MatricesIndicesExtraKind
  24683. * * VertexBuffer.MatricesWeightsKind
  24684. * * VertexBuffer.MatricesWeightsExtraKind
  24685. * @param data defines the data source
  24686. * @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
  24687. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24688. * @returns the current mesh
  24689. */
  24690. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24691. /**
  24692. * Sets the mesh indices,
  24693. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24694. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24695. * @param totalVertices Defines the total number of vertices
  24696. * @returns the current mesh
  24697. */
  24698. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24699. /**
  24700. * Gets a boolean indicating if specific vertex data is present
  24701. * @param kind defines the vertex data kind to use
  24702. * @returns true is data kind is present
  24703. */
  24704. isVerticesDataPresent(kind: string): boolean;
  24705. /**
  24706. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24707. * @returns a BoundingInfo
  24708. */
  24709. getBoundingInfo(): BoundingInfo;
  24710. /**
  24711. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24712. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24713. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24714. * @returns the current mesh
  24715. */
  24716. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24717. /**
  24718. * Overwrite the current bounding info
  24719. * @param boundingInfo defines the new bounding info
  24720. * @returns the current mesh
  24721. */
  24722. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24723. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24724. readonly useBones: boolean;
  24725. /** @hidden */
  24726. _preActivate(): void;
  24727. /** @hidden */
  24728. _preActivateForIntermediateRendering(renderId: number): void;
  24729. /** @hidden */
  24730. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24731. /** @hidden */
  24732. _postActivate(): void;
  24733. /** @hidden */
  24734. _freeze(): void;
  24735. /** @hidden */
  24736. _unFreeze(): void;
  24737. /**
  24738. * Gets the current world matrix
  24739. * @returns a Matrix
  24740. */
  24741. getWorldMatrix(): Matrix;
  24742. /** @hidden */
  24743. _getWorldMatrixDeterminant(): number;
  24744. /**
  24745. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24746. */
  24747. readonly isAnInstance: boolean;
  24748. /**
  24749. * Perform relative position change from the point of view of behind the front of the mesh.
  24750. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24751. * Supports definition of mesh facing forward or backward
  24752. * @param amountRight defines the distance on the right axis
  24753. * @param amountUp defines the distance on the up axis
  24754. * @param amountForward defines the distance on the forward axis
  24755. * @returns the current mesh
  24756. */
  24757. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24758. /**
  24759. * Calculate relative position change from the point of view of behind the front of the mesh.
  24760. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24761. * Supports definition of mesh facing forward or backward
  24762. * @param amountRight defines the distance on the right axis
  24763. * @param amountUp defines the distance on the up axis
  24764. * @param amountForward defines the distance on the forward axis
  24765. * @returns the new displacement vector
  24766. */
  24767. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24768. /**
  24769. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24770. * Supports definition of mesh facing forward or backward
  24771. * @param flipBack defines the flip
  24772. * @param twirlClockwise defines the twirl
  24773. * @param tiltRight defines the tilt
  24774. * @returns the current mesh
  24775. */
  24776. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24777. /**
  24778. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24779. * Supports definition of mesh facing forward or backward.
  24780. * @param flipBack defines the flip
  24781. * @param twirlClockwise defines the twirl
  24782. * @param tiltRight defines the tilt
  24783. * @returns the new rotation vector
  24784. */
  24785. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24786. /**
  24787. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24788. * This means the mesh underlying bounding box and sphere are recomputed.
  24789. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24790. * @returns the current mesh
  24791. */
  24792. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24793. /** @hidden */
  24794. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24795. /** @hidden */
  24796. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24797. /** @hidden */
  24798. _updateBoundingInfo(): AbstractMesh;
  24799. /** @hidden */
  24800. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24801. /** @hidden */
  24802. protected _afterComputeWorldMatrix(): void;
  24803. /** @hidden */
  24804. readonly _effectiveMesh: AbstractMesh;
  24805. /**
  24806. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24807. * A mesh is in the frustum if its bounding box intersects the frustum
  24808. * @param frustumPlanes defines the frustum to test
  24809. * @returns true if the mesh is in the frustum planes
  24810. */
  24811. isInFrustum(frustumPlanes: Plane[]): boolean;
  24812. /**
  24813. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24814. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24815. * @param frustumPlanes defines the frustum to test
  24816. * @returns true if the mesh is completely in the frustum planes
  24817. */
  24818. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24819. /**
  24820. * True if the mesh intersects another mesh or a SolidParticle object
  24821. * @param mesh defines a target mesh or SolidParticle to test
  24822. * @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)
  24823. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24824. * @returns true if there is an intersection
  24825. */
  24826. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24827. /**
  24828. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24829. * @param point defines the point to test
  24830. * @returns true if there is an intersection
  24831. */
  24832. intersectsPoint(point: Vector3): boolean;
  24833. /**
  24834. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24836. */
  24837. checkCollisions: boolean;
  24838. /**
  24839. * Gets Collider object used to compute collisions (not physics)
  24840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24841. */
  24842. readonly collider: Nullable<Collider>;
  24843. /**
  24844. * Move the mesh using collision engine
  24845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24846. * @param displacement defines the requested displacement vector
  24847. * @returns the current mesh
  24848. */
  24849. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24850. private _onCollisionPositionChange;
  24851. /** @hidden */
  24852. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24853. /** @hidden */
  24854. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24855. /** @hidden */
  24856. _checkCollision(collider: Collider): AbstractMesh;
  24857. /** @hidden */
  24858. _generatePointsArray(): boolean;
  24859. /**
  24860. * Checks if the passed Ray intersects with the mesh
  24861. * @param ray defines the ray to use
  24862. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24863. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24864. * @returns the picking info
  24865. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24866. */
  24867. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24868. /**
  24869. * Clones the current mesh
  24870. * @param name defines the mesh name
  24871. * @param newParent defines the new mesh parent
  24872. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24873. * @returns the new mesh
  24874. */
  24875. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24876. /**
  24877. * Disposes all the submeshes of the current meshnp
  24878. * @returns the current mesh
  24879. */
  24880. releaseSubMeshes(): AbstractMesh;
  24881. /**
  24882. * Releases resources associated with this abstract mesh.
  24883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24885. */
  24886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24887. /**
  24888. * Adds the passed mesh as a child to the current mesh
  24889. * @param mesh defines the child mesh
  24890. * @returns the current mesh
  24891. */
  24892. addChild(mesh: AbstractMesh): AbstractMesh;
  24893. /**
  24894. * Removes the passed mesh from the current mesh children list
  24895. * @param mesh defines the child mesh
  24896. * @returns the current mesh
  24897. */
  24898. removeChild(mesh: AbstractMesh): AbstractMesh;
  24899. /** @hidden */
  24900. private _initFacetData;
  24901. /**
  24902. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24903. * This method can be called within the render loop.
  24904. * 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
  24905. * @returns the current mesh
  24906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24907. */
  24908. updateFacetData(): AbstractMesh;
  24909. /**
  24910. * Returns the facetLocalNormals array.
  24911. * The normals are expressed in the mesh local spac
  24912. * @returns an array of Vector3
  24913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24914. */
  24915. getFacetLocalNormals(): Vector3[];
  24916. /**
  24917. * Returns the facetLocalPositions array.
  24918. * The facet positions are expressed in the mesh local space
  24919. * @returns an array of Vector3
  24920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24921. */
  24922. getFacetLocalPositions(): Vector3[];
  24923. /**
  24924. * Returns the facetLocalPartioning array
  24925. * @returns an array of array of numbers
  24926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24927. */
  24928. getFacetLocalPartitioning(): number[][];
  24929. /**
  24930. * Returns the i-th facet position in the world system.
  24931. * This method allocates a new Vector3 per call
  24932. * @param i defines the facet index
  24933. * @returns a new Vector3
  24934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24935. */
  24936. getFacetPosition(i: number): Vector3;
  24937. /**
  24938. * Sets the reference Vector3 with the i-th facet position in the world system
  24939. * @param i defines the facet index
  24940. * @param ref defines the target vector
  24941. * @returns the current mesh
  24942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24943. */
  24944. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24945. /**
  24946. * Returns the i-th facet normal in the world system.
  24947. * This method allocates a new Vector3 per call
  24948. * @param i defines the facet index
  24949. * @returns a new Vector3
  24950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24951. */
  24952. getFacetNormal(i: number): Vector3;
  24953. /**
  24954. * Sets the reference Vector3 with the i-th facet normal in the world system
  24955. * @param i defines the facet index
  24956. * @param ref defines the target vector
  24957. * @returns the current mesh
  24958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24959. */
  24960. getFacetNormalToRef(i: number, ref: Vector3): this;
  24961. /**
  24962. * 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)
  24963. * @param x defines x coordinate
  24964. * @param y defines y coordinate
  24965. * @param z defines z coordinate
  24966. * @returns the array of facet indexes
  24967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24968. */
  24969. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24970. /**
  24971. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24972. * @param projected sets as the (x,y,z) world projection on the facet
  24973. * @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
  24974. * @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
  24975. * @param x defines x coordinate
  24976. * @param y defines y coordinate
  24977. * @param z defines z coordinate
  24978. * @returns the face index if found (or null instead)
  24979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24980. */
  24981. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24982. /**
  24983. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24984. * @param projected sets as the (x,y,z) local projection on the facet
  24985. * @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
  24986. * @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
  24987. * @param x defines x coordinate
  24988. * @param y defines y coordinate
  24989. * @param z defines z coordinate
  24990. * @returns the face index if found (or null instead)
  24991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24992. */
  24993. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24994. /**
  24995. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24996. * @returns the parameters
  24997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24998. */
  24999. getFacetDataParameters(): any;
  25000. /**
  25001. * Disables the feature FacetData and frees the related memory
  25002. * @returns the current mesh
  25003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25004. */
  25005. disableFacetData(): AbstractMesh;
  25006. /**
  25007. * Updates the AbstractMesh indices array
  25008. * @param indices defines the data source
  25009. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25010. * @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)
  25011. * @returns the current mesh
  25012. */
  25013. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25014. /**
  25015. * Creates new normals data for the mesh
  25016. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25017. * @returns the current mesh
  25018. */
  25019. createNormals(updatable: boolean): AbstractMesh;
  25020. /**
  25021. * Align the mesh with a normal
  25022. * @param normal defines the normal to use
  25023. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25024. * @returns the current mesh
  25025. */
  25026. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25027. /** @hidden */
  25028. _checkOcclusionQuery(): boolean;
  25029. /**
  25030. * Disables the mesh edge rendering mode
  25031. * @returns the currentAbstractMesh
  25032. */
  25033. disableEdgesRendering(): AbstractMesh;
  25034. /**
  25035. * Enables the edge rendering mode on the mesh.
  25036. * This mode makes the mesh edges visible
  25037. * @param epsilon defines the maximal distance between two angles to detect a face
  25038. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25039. * @returns the currentAbstractMesh
  25040. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25041. */
  25042. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25043. }
  25044. }
  25045. declare module BABYLON {
  25046. /**
  25047. * Interface used to define ActionEvent
  25048. */
  25049. export interface IActionEvent {
  25050. /** The mesh or sprite that triggered the action */
  25051. source: any;
  25052. /** The X mouse cursor position at the time of the event */
  25053. pointerX: number;
  25054. /** The Y mouse cursor position at the time of the event */
  25055. pointerY: number;
  25056. /** The mesh that is currently pointed at (can be null) */
  25057. meshUnderPointer: Nullable<AbstractMesh>;
  25058. /** the original (browser) event that triggered the ActionEvent */
  25059. sourceEvent?: any;
  25060. /** additional data for the event */
  25061. additionalData?: any;
  25062. }
  25063. /**
  25064. * ActionEvent is the event being sent when an action is triggered.
  25065. */
  25066. export class ActionEvent implements IActionEvent {
  25067. /** The mesh or sprite that triggered the action */
  25068. source: any;
  25069. /** The X mouse cursor position at the time of the event */
  25070. pointerX: number;
  25071. /** The Y mouse cursor position at the time of the event */
  25072. pointerY: number;
  25073. /** The mesh that is currently pointed at (can be null) */
  25074. meshUnderPointer: Nullable<AbstractMesh>;
  25075. /** the original (browser) event that triggered the ActionEvent */
  25076. sourceEvent?: any;
  25077. /** additional data for the event */
  25078. additionalData?: any;
  25079. /**
  25080. * Creates a new ActionEvent
  25081. * @param source The mesh or sprite that triggered the action
  25082. * @param pointerX The X mouse cursor position at the time of the event
  25083. * @param pointerY The Y mouse cursor position at the time of the event
  25084. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25085. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25086. * @param additionalData additional data for the event
  25087. */
  25088. constructor(
  25089. /** The mesh or sprite that triggered the action */
  25090. source: any,
  25091. /** The X mouse cursor position at the time of the event */
  25092. pointerX: number,
  25093. /** The Y mouse cursor position at the time of the event */
  25094. pointerY: number,
  25095. /** The mesh that is currently pointed at (can be null) */
  25096. meshUnderPointer: Nullable<AbstractMesh>,
  25097. /** the original (browser) event that triggered the ActionEvent */
  25098. sourceEvent?: any,
  25099. /** additional data for the event */
  25100. additionalData?: any);
  25101. /**
  25102. * Helper function to auto-create an ActionEvent from a source mesh.
  25103. * @param source The source mesh that triggered the event
  25104. * @param evt The original (browser) event
  25105. * @param additionalData additional data for the event
  25106. * @returns the new ActionEvent
  25107. */
  25108. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25109. /**
  25110. * Helper function to auto-create an ActionEvent from a source sprite
  25111. * @param source The source sprite that triggered the event
  25112. * @param scene Scene associated with the sprite
  25113. * @param evt The original (browser) event
  25114. * @param additionalData additional data for the event
  25115. * @returns the new ActionEvent
  25116. */
  25117. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25118. /**
  25119. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25120. * @param scene the scene where the event occurred
  25121. * @param evt The original (browser) event
  25122. * @returns the new ActionEvent
  25123. */
  25124. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25125. /**
  25126. * Helper function to auto-create an ActionEvent from a primitive
  25127. * @param prim defines the target primitive
  25128. * @param pointerPos defines the pointer position
  25129. * @param evt The original (browser) event
  25130. * @param additionalData additional data for the event
  25131. * @returns the new ActionEvent
  25132. */
  25133. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25134. }
  25135. }
  25136. declare module BABYLON {
  25137. /**
  25138. * Abstract class used to decouple action Manager from scene and meshes.
  25139. * Do not instantiate.
  25140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25141. */
  25142. export abstract class AbstractActionManager implements IDisposable {
  25143. /** Gets the list of active triggers */
  25144. static Triggers: {
  25145. [key: string]: number;
  25146. };
  25147. /** Gets the cursor to use when hovering items */
  25148. hoverCursor: string;
  25149. /** Gets the list of actions */
  25150. actions: IAction[];
  25151. /**
  25152. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25153. */
  25154. isRecursive: boolean;
  25155. /**
  25156. * Releases all associated resources
  25157. */
  25158. abstract dispose(): void;
  25159. /**
  25160. * Does this action manager has pointer triggers
  25161. */
  25162. abstract readonly hasPointerTriggers: boolean;
  25163. /**
  25164. * Does this action manager has pick triggers
  25165. */
  25166. abstract readonly hasPickTriggers: boolean;
  25167. /**
  25168. * Process a specific trigger
  25169. * @param trigger defines the trigger to process
  25170. * @param evt defines the event details to be processed
  25171. */
  25172. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25173. /**
  25174. * Does this action manager handles actions of any of the given triggers
  25175. * @param triggers defines the triggers to be tested
  25176. * @return a boolean indicating whether one (or more) of the triggers is handled
  25177. */
  25178. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25179. /**
  25180. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25181. * speed.
  25182. * @param triggerA defines the trigger to be tested
  25183. * @param triggerB defines the trigger to be tested
  25184. * @return a boolean indicating whether one (or more) of the triggers is handled
  25185. */
  25186. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25187. /**
  25188. * Does this action manager handles actions of a given trigger
  25189. * @param trigger defines the trigger to be tested
  25190. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25191. * @return whether the trigger is handled
  25192. */
  25193. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25194. /**
  25195. * Serialize this manager to a JSON object
  25196. * @param name defines the property name to store this manager
  25197. * @returns a JSON representation of this manager
  25198. */
  25199. abstract serialize(name: string): any;
  25200. /**
  25201. * Registers an action to this action manager
  25202. * @param action defines the action to be registered
  25203. * @return the action amended (prepared) after registration
  25204. */
  25205. abstract registerAction(action: IAction): Nullable<IAction>;
  25206. /**
  25207. * Unregisters an action to this action manager
  25208. * @param action defines the action to be unregistered
  25209. * @return a boolean indicating whether the action has been unregistered
  25210. */
  25211. abstract unregisterAction(action: IAction): Boolean;
  25212. /**
  25213. * Does exist one action manager with at least one trigger
  25214. **/
  25215. static readonly HasTriggers: boolean;
  25216. /**
  25217. * Does exist one action manager with at least one pick trigger
  25218. **/
  25219. static readonly HasPickTriggers: boolean;
  25220. /**
  25221. * Does exist one action manager that handles actions of a given trigger
  25222. * @param trigger defines the trigger to be tested
  25223. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25224. **/
  25225. static HasSpecificTrigger(trigger: number): boolean;
  25226. }
  25227. }
  25228. declare module BABYLON {
  25229. /**
  25230. * Defines how a node can be built from a string name.
  25231. */
  25232. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25233. /**
  25234. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25235. */
  25236. export class Node implements IBehaviorAware<Node> {
  25237. /** @hidden */
  25238. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25239. private static _NodeConstructors;
  25240. /**
  25241. * Add a new node constructor
  25242. * @param type defines the type name of the node to construct
  25243. * @param constructorFunc defines the constructor function
  25244. */
  25245. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25246. /**
  25247. * Returns a node constructor based on type name
  25248. * @param type defines the type name
  25249. * @param name defines the new node name
  25250. * @param scene defines the hosting scene
  25251. * @param options defines optional options to transmit to constructors
  25252. * @returns the new constructor or null
  25253. */
  25254. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25255. /**
  25256. * Gets or sets the name of the node
  25257. */
  25258. name: string;
  25259. /**
  25260. * Gets or sets the id of the node
  25261. */
  25262. id: string;
  25263. /**
  25264. * Gets or sets the unique id of the node
  25265. */
  25266. uniqueId: number;
  25267. /**
  25268. * Gets or sets a string used to store user defined state for the node
  25269. */
  25270. state: string;
  25271. /**
  25272. * Gets or sets an object used to store user defined information for the node
  25273. */
  25274. metadata: any;
  25275. /**
  25276. * For internal use only. Please do not use.
  25277. */
  25278. reservedDataStore: any;
  25279. /**
  25280. * List of inspectable custom properties (used by the Inspector)
  25281. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25282. */
  25283. inspectableCustomProperties: IInspectable[];
  25284. /**
  25285. * Gets or sets a boolean used to define if the node must be serialized
  25286. */
  25287. doNotSerialize: boolean;
  25288. /** @hidden */
  25289. _isDisposed: boolean;
  25290. /**
  25291. * Gets a list of Animations associated with the node
  25292. */
  25293. animations: Animation[];
  25294. protected _ranges: {
  25295. [name: string]: Nullable<AnimationRange>;
  25296. };
  25297. /**
  25298. * Callback raised when the node is ready to be used
  25299. */
  25300. onReady: Nullable<(node: Node) => void>;
  25301. private _isEnabled;
  25302. private _isParentEnabled;
  25303. private _isReady;
  25304. /** @hidden */
  25305. _currentRenderId: number;
  25306. private _parentUpdateId;
  25307. /** @hidden */
  25308. _childUpdateId: number;
  25309. /** @hidden */
  25310. _waitingParentId: Nullable<string>;
  25311. /** @hidden */
  25312. _scene: Scene;
  25313. /** @hidden */
  25314. _cache: any;
  25315. private _parentNode;
  25316. private _children;
  25317. /** @hidden */
  25318. _worldMatrix: Matrix;
  25319. /** @hidden */
  25320. _worldMatrixDeterminant: number;
  25321. /** @hidden */
  25322. _worldMatrixDeterminantIsDirty: boolean;
  25323. /** @hidden */
  25324. private _sceneRootNodesIndex;
  25325. /**
  25326. * Gets a boolean indicating if the node has been disposed
  25327. * @returns true if the node was disposed
  25328. */
  25329. isDisposed(): boolean;
  25330. /**
  25331. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25332. * @see https://doc.babylonjs.com/how_to/parenting
  25333. */
  25334. parent: Nullable<Node>;
  25335. private addToSceneRootNodes;
  25336. private removeFromSceneRootNodes;
  25337. private _animationPropertiesOverride;
  25338. /**
  25339. * Gets or sets the animation properties override
  25340. */
  25341. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25342. /**
  25343. * Gets a string idenfifying the name of the class
  25344. * @returns "Node" string
  25345. */
  25346. getClassName(): string;
  25347. /** @hidden */
  25348. readonly _isNode: boolean;
  25349. /**
  25350. * An event triggered when the mesh is disposed
  25351. */
  25352. onDisposeObservable: Observable<Node>;
  25353. private _onDisposeObserver;
  25354. /**
  25355. * Sets a callback that will be raised when the node will be disposed
  25356. */
  25357. onDispose: () => void;
  25358. /**
  25359. * Creates a new Node
  25360. * @param name the name and id to be given to this node
  25361. * @param scene the scene this node will be added to
  25362. * @param addToRootNodes the node will be added to scene.rootNodes
  25363. */
  25364. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25365. /**
  25366. * Gets the scene of the node
  25367. * @returns a scene
  25368. */
  25369. getScene(): Scene;
  25370. /**
  25371. * Gets the engine of the node
  25372. * @returns a Engine
  25373. */
  25374. getEngine(): Engine;
  25375. private _behaviors;
  25376. /**
  25377. * Attach a behavior to the node
  25378. * @see http://doc.babylonjs.com/features/behaviour
  25379. * @param behavior defines the behavior to attach
  25380. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25381. * @returns the current Node
  25382. */
  25383. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25384. /**
  25385. * Remove an attached behavior
  25386. * @see http://doc.babylonjs.com/features/behaviour
  25387. * @param behavior defines the behavior to attach
  25388. * @returns the current Node
  25389. */
  25390. removeBehavior(behavior: Behavior<Node>): Node;
  25391. /**
  25392. * Gets the list of attached behaviors
  25393. * @see http://doc.babylonjs.com/features/behaviour
  25394. */
  25395. readonly behaviors: Behavior<Node>[];
  25396. /**
  25397. * Gets an attached behavior by name
  25398. * @param name defines the name of the behavior to look for
  25399. * @see http://doc.babylonjs.com/features/behaviour
  25400. * @returns null if behavior was not found else the requested behavior
  25401. */
  25402. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25403. /**
  25404. * Returns the latest update of the World matrix
  25405. * @returns a Matrix
  25406. */
  25407. getWorldMatrix(): Matrix;
  25408. /** @hidden */
  25409. _getWorldMatrixDeterminant(): number;
  25410. /**
  25411. * Returns directly the latest state of the mesh World matrix.
  25412. * A Matrix is returned.
  25413. */
  25414. readonly worldMatrixFromCache: Matrix;
  25415. /** @hidden */
  25416. _initCache(): void;
  25417. /** @hidden */
  25418. updateCache(force?: boolean): void;
  25419. /** @hidden */
  25420. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25421. /** @hidden */
  25422. _updateCache(ignoreParentClass?: boolean): void;
  25423. /** @hidden */
  25424. _isSynchronized(): boolean;
  25425. /** @hidden */
  25426. _markSyncedWithParent(): void;
  25427. /** @hidden */
  25428. isSynchronizedWithParent(): boolean;
  25429. /** @hidden */
  25430. isSynchronized(): boolean;
  25431. /**
  25432. * Is this node ready to be used/rendered
  25433. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25434. * @return true if the node is ready
  25435. */
  25436. isReady(completeCheck?: boolean): boolean;
  25437. /**
  25438. * Is this node enabled?
  25439. * 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
  25440. * @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
  25441. * @return whether this node (and its parent) is enabled
  25442. */
  25443. isEnabled(checkAncestors?: boolean): boolean;
  25444. /** @hidden */
  25445. protected _syncParentEnabledState(): void;
  25446. /**
  25447. * Set the enabled state of this node
  25448. * @param value defines the new enabled state
  25449. */
  25450. setEnabled(value: boolean): void;
  25451. /**
  25452. * Is this node a descendant of the given node?
  25453. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25454. * @param ancestor defines the parent node to inspect
  25455. * @returns a boolean indicating if this node is a descendant of the given node
  25456. */
  25457. isDescendantOf(ancestor: Node): boolean;
  25458. /** @hidden */
  25459. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25460. /**
  25461. * Will return all nodes that have this node as ascendant
  25462. * @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
  25463. * @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
  25464. * @return all children nodes of all types
  25465. */
  25466. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25467. /**
  25468. * Get all child-meshes of this node
  25469. * @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)
  25470. * @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
  25471. * @returns an array of AbstractMesh
  25472. */
  25473. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25474. /**
  25475. * Get all direct children of this node
  25476. * @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
  25477. * @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)
  25478. * @returns an array of Node
  25479. */
  25480. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25481. /** @hidden */
  25482. _setReady(state: boolean): void;
  25483. /**
  25484. * Get an animation by name
  25485. * @param name defines the name of the animation to look for
  25486. * @returns null if not found else the requested animation
  25487. */
  25488. getAnimationByName(name: string): Nullable<Animation>;
  25489. /**
  25490. * Creates an animation range for this node
  25491. * @param name defines the name of the range
  25492. * @param from defines the starting key
  25493. * @param to defines the end key
  25494. */
  25495. createAnimationRange(name: string, from: number, to: number): void;
  25496. /**
  25497. * Delete a specific animation range
  25498. * @param name defines the name of the range to delete
  25499. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25500. */
  25501. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25502. /**
  25503. * Get an animation range by name
  25504. * @param name defines the name of the animation range to look for
  25505. * @returns null if not found else the requested animation range
  25506. */
  25507. getAnimationRange(name: string): Nullable<AnimationRange>;
  25508. /**
  25509. * Gets the list of all animation ranges defined on this node
  25510. * @returns an array
  25511. */
  25512. getAnimationRanges(): Nullable<AnimationRange>[];
  25513. /**
  25514. * Will start the animation sequence
  25515. * @param name defines the range frames for animation sequence
  25516. * @param loop defines if the animation should loop (false by default)
  25517. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25518. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25519. * @returns the object created for this animation. If range does not exist, it will return null
  25520. */
  25521. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25522. /**
  25523. * Serialize animation ranges into a JSON compatible object
  25524. * @returns serialization object
  25525. */
  25526. serializeAnimationRanges(): any;
  25527. /**
  25528. * Computes the world matrix of the node
  25529. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25530. * @returns the world matrix
  25531. */
  25532. computeWorldMatrix(force?: boolean): Matrix;
  25533. /**
  25534. * Releases resources associated with this node.
  25535. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25536. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25537. */
  25538. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25539. /**
  25540. * Parse animation range data from a serialization object and store them into a given node
  25541. * @param node defines where to store the animation ranges
  25542. * @param parsedNode defines the serialization object to read data from
  25543. * @param scene defines the hosting scene
  25544. */
  25545. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25546. /**
  25547. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25548. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25549. * @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
  25550. * @returns the new bounding vectors
  25551. */
  25552. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25553. min: Vector3;
  25554. max: Vector3;
  25555. };
  25556. }
  25557. }
  25558. declare module BABYLON {
  25559. /**
  25560. * @hidden
  25561. */
  25562. export class _IAnimationState {
  25563. key: number;
  25564. repeatCount: number;
  25565. workValue?: any;
  25566. loopMode?: number;
  25567. offsetValue?: any;
  25568. highLimitValue?: any;
  25569. }
  25570. /**
  25571. * Class used to store any kind of animation
  25572. */
  25573. export class Animation {
  25574. /**Name of the animation */
  25575. name: string;
  25576. /**Property to animate */
  25577. targetProperty: string;
  25578. /**The frames per second of the animation */
  25579. framePerSecond: number;
  25580. /**The data type of the animation */
  25581. dataType: number;
  25582. /**The loop mode of the animation */
  25583. loopMode?: number | undefined;
  25584. /**Specifies if blending should be enabled */
  25585. enableBlending?: boolean | undefined;
  25586. /**
  25587. * Use matrix interpolation instead of using direct key value when animating matrices
  25588. */
  25589. static AllowMatricesInterpolation: boolean;
  25590. /**
  25591. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25592. */
  25593. static AllowMatrixDecomposeForInterpolation: boolean;
  25594. /**
  25595. * Stores the key frames of the animation
  25596. */
  25597. private _keys;
  25598. /**
  25599. * Stores the easing function of the animation
  25600. */
  25601. private _easingFunction;
  25602. /**
  25603. * @hidden Internal use only
  25604. */
  25605. _runtimeAnimations: RuntimeAnimation[];
  25606. /**
  25607. * The set of event that will be linked to this animation
  25608. */
  25609. private _events;
  25610. /**
  25611. * Stores an array of target property paths
  25612. */
  25613. targetPropertyPath: string[];
  25614. /**
  25615. * Stores the blending speed of the animation
  25616. */
  25617. blendingSpeed: number;
  25618. /**
  25619. * Stores the animation ranges for the animation
  25620. */
  25621. private _ranges;
  25622. /**
  25623. * @hidden Internal use
  25624. */
  25625. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25626. /**
  25627. * Sets up an animation
  25628. * @param property The property to animate
  25629. * @param animationType The animation type to apply
  25630. * @param framePerSecond The frames per second of the animation
  25631. * @param easingFunction The easing function used in the animation
  25632. * @returns The created animation
  25633. */
  25634. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25635. /**
  25636. * Create and start an animation on a node
  25637. * @param name defines the name of the global animation that will be run on all nodes
  25638. * @param node defines the root node where the animation will take place
  25639. * @param targetProperty defines property to animate
  25640. * @param framePerSecond defines the number of frame per second yo use
  25641. * @param totalFrame defines the number of frames in total
  25642. * @param from defines the initial value
  25643. * @param to defines the final value
  25644. * @param loopMode defines which loop mode you want to use (off by default)
  25645. * @param easingFunction defines the easing function to use (linear by default)
  25646. * @param onAnimationEnd defines the callback to call when animation end
  25647. * @returns the animatable created for this animation
  25648. */
  25649. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25650. /**
  25651. * Create and start an animation on a node and its descendants
  25652. * @param name defines the name of the global animation that will be run on all nodes
  25653. * @param node defines the root node where the animation will take place
  25654. * @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
  25655. * @param targetProperty defines property to animate
  25656. * @param framePerSecond defines the number of frame per second to use
  25657. * @param totalFrame defines the number of frames in total
  25658. * @param from defines the initial value
  25659. * @param to defines the final value
  25660. * @param loopMode defines which loop mode you want to use (off by default)
  25661. * @param easingFunction defines the easing function to use (linear by default)
  25662. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25663. * @returns the list of animatables created for all nodes
  25664. * @example https://www.babylonjs-playground.com/#MH0VLI
  25665. */
  25666. 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[]>;
  25667. /**
  25668. * Creates a new animation, merges it with the existing animations and starts it
  25669. * @param name Name of the animation
  25670. * @param node Node which contains the scene that begins the animations
  25671. * @param targetProperty Specifies which property to animate
  25672. * @param framePerSecond The frames per second of the animation
  25673. * @param totalFrame The total number of frames
  25674. * @param from The frame at the beginning of the animation
  25675. * @param to The frame at the end of the animation
  25676. * @param loopMode Specifies the loop mode of the animation
  25677. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25678. * @param onAnimationEnd Callback to run once the animation is complete
  25679. * @returns Nullable animation
  25680. */
  25681. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25682. /**
  25683. * Transition property of an host to the target Value
  25684. * @param property The property to transition
  25685. * @param targetValue The target Value of the property
  25686. * @param host The object where the property to animate belongs
  25687. * @param scene Scene used to run the animation
  25688. * @param frameRate Framerate (in frame/s) to use
  25689. * @param transition The transition type we want to use
  25690. * @param duration The duration of the animation, in milliseconds
  25691. * @param onAnimationEnd Callback trigger at the end of the animation
  25692. * @returns Nullable animation
  25693. */
  25694. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25695. /**
  25696. * Return the array of runtime animations currently using this animation
  25697. */
  25698. readonly runtimeAnimations: RuntimeAnimation[];
  25699. /**
  25700. * Specifies if any of the runtime animations are currently running
  25701. */
  25702. readonly hasRunningRuntimeAnimations: boolean;
  25703. /**
  25704. * Initializes the animation
  25705. * @param name Name of the animation
  25706. * @param targetProperty Property to animate
  25707. * @param framePerSecond The frames per second of the animation
  25708. * @param dataType The data type of the animation
  25709. * @param loopMode The loop mode of the animation
  25710. * @param enableBlending Specifies if blending should be enabled
  25711. */
  25712. constructor(
  25713. /**Name of the animation */
  25714. name: string,
  25715. /**Property to animate */
  25716. targetProperty: string,
  25717. /**The frames per second of the animation */
  25718. framePerSecond: number,
  25719. /**The data type of the animation */
  25720. dataType: number,
  25721. /**The loop mode of the animation */
  25722. loopMode?: number | undefined,
  25723. /**Specifies if blending should be enabled */
  25724. enableBlending?: boolean | undefined);
  25725. /**
  25726. * Converts the animation to a string
  25727. * @param fullDetails support for multiple levels of logging within scene loading
  25728. * @returns String form of the animation
  25729. */
  25730. toString(fullDetails?: boolean): string;
  25731. /**
  25732. * Add an event to this animation
  25733. * @param event Event to add
  25734. */
  25735. addEvent(event: AnimationEvent): void;
  25736. /**
  25737. * Remove all events found at the given frame
  25738. * @param frame The frame to remove events from
  25739. */
  25740. removeEvents(frame: number): void;
  25741. /**
  25742. * Retrieves all the events from the animation
  25743. * @returns Events from the animation
  25744. */
  25745. getEvents(): AnimationEvent[];
  25746. /**
  25747. * Creates an animation range
  25748. * @param name Name of the animation range
  25749. * @param from Starting frame of the animation range
  25750. * @param to Ending frame of the animation
  25751. */
  25752. createRange(name: string, from: number, to: number): void;
  25753. /**
  25754. * Deletes an animation range by name
  25755. * @param name Name of the animation range to delete
  25756. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25757. */
  25758. deleteRange(name: string, deleteFrames?: boolean): void;
  25759. /**
  25760. * Gets the animation range by name, or null if not defined
  25761. * @param name Name of the animation range
  25762. * @returns Nullable animation range
  25763. */
  25764. getRange(name: string): Nullable<AnimationRange>;
  25765. /**
  25766. * Gets the key frames from the animation
  25767. * @returns The key frames of the animation
  25768. */
  25769. getKeys(): Array<IAnimationKey>;
  25770. /**
  25771. * Gets the highest frame rate of the animation
  25772. * @returns Highest frame rate of the animation
  25773. */
  25774. getHighestFrame(): number;
  25775. /**
  25776. * Gets the easing function of the animation
  25777. * @returns Easing function of the animation
  25778. */
  25779. getEasingFunction(): IEasingFunction;
  25780. /**
  25781. * Sets the easing function of the animation
  25782. * @param easingFunction A custom mathematical formula for animation
  25783. */
  25784. setEasingFunction(easingFunction: EasingFunction): void;
  25785. /**
  25786. * Interpolates a scalar linearly
  25787. * @param startValue Start value of the animation curve
  25788. * @param endValue End value of the animation curve
  25789. * @param gradient Scalar amount to interpolate
  25790. * @returns Interpolated scalar value
  25791. */
  25792. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25793. /**
  25794. * Interpolates a scalar cubically
  25795. * @param startValue Start value of the animation curve
  25796. * @param outTangent End tangent of the animation
  25797. * @param endValue End value of the animation curve
  25798. * @param inTangent Start tangent of the animation curve
  25799. * @param gradient Scalar amount to interpolate
  25800. * @returns Interpolated scalar value
  25801. */
  25802. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25803. /**
  25804. * Interpolates a quaternion using a spherical linear interpolation
  25805. * @param startValue Start value of the animation curve
  25806. * @param endValue End value of the animation curve
  25807. * @param gradient Scalar amount to interpolate
  25808. * @returns Interpolated quaternion value
  25809. */
  25810. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25811. /**
  25812. * Interpolates a quaternion cubically
  25813. * @param startValue Start value of the animation curve
  25814. * @param outTangent End tangent of the animation curve
  25815. * @param endValue End value of the animation curve
  25816. * @param inTangent Start tangent of the animation curve
  25817. * @param gradient Scalar amount to interpolate
  25818. * @returns Interpolated quaternion value
  25819. */
  25820. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25821. /**
  25822. * Interpolates a Vector3 linearl
  25823. * @param startValue Start value of the animation curve
  25824. * @param endValue End value of the animation curve
  25825. * @param gradient Scalar amount to interpolate
  25826. * @returns Interpolated scalar value
  25827. */
  25828. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25829. /**
  25830. * Interpolates a Vector3 cubically
  25831. * @param startValue Start value of the animation curve
  25832. * @param outTangent End tangent of the animation
  25833. * @param endValue End value of the animation curve
  25834. * @param inTangent Start tangent of the animation curve
  25835. * @param gradient Scalar amount to interpolate
  25836. * @returns InterpolatedVector3 value
  25837. */
  25838. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25839. /**
  25840. * Interpolates a Vector2 linearly
  25841. * @param startValue Start value of the animation curve
  25842. * @param endValue End value of the animation curve
  25843. * @param gradient Scalar amount to interpolate
  25844. * @returns Interpolated Vector2 value
  25845. */
  25846. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25847. /**
  25848. * Interpolates a Vector2 cubically
  25849. * @param startValue Start value of the animation curve
  25850. * @param outTangent End tangent of the animation
  25851. * @param endValue End value of the animation curve
  25852. * @param inTangent Start tangent of the animation curve
  25853. * @param gradient Scalar amount to interpolate
  25854. * @returns Interpolated Vector2 value
  25855. */
  25856. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25857. /**
  25858. * Interpolates a size linearly
  25859. * @param startValue Start value of the animation curve
  25860. * @param endValue End value of the animation curve
  25861. * @param gradient Scalar amount to interpolate
  25862. * @returns Interpolated Size value
  25863. */
  25864. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25865. /**
  25866. * Interpolates a Color3 linearly
  25867. * @param startValue Start value of the animation curve
  25868. * @param endValue End value of the animation curve
  25869. * @param gradient Scalar amount to interpolate
  25870. * @returns Interpolated Color3 value
  25871. */
  25872. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25873. /**
  25874. * @hidden Internal use only
  25875. */
  25876. _getKeyValue(value: any): any;
  25877. /**
  25878. * @hidden Internal use only
  25879. */
  25880. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25881. /**
  25882. * Defines the function to use to interpolate matrices
  25883. * @param startValue defines the start matrix
  25884. * @param endValue defines the end matrix
  25885. * @param gradient defines the gradient between both matrices
  25886. * @param result defines an optional target matrix where to store the interpolation
  25887. * @returns the interpolated matrix
  25888. */
  25889. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25890. /**
  25891. * Makes a copy of the animation
  25892. * @returns Cloned animation
  25893. */
  25894. clone(): Animation;
  25895. /**
  25896. * Sets the key frames of the animation
  25897. * @param values The animation key frames to set
  25898. */
  25899. setKeys(values: Array<IAnimationKey>): void;
  25900. /**
  25901. * Serializes the animation to an object
  25902. * @returns Serialized object
  25903. */
  25904. serialize(): any;
  25905. /**
  25906. * Float animation type
  25907. */
  25908. private static _ANIMATIONTYPE_FLOAT;
  25909. /**
  25910. * Vector3 animation type
  25911. */
  25912. private static _ANIMATIONTYPE_VECTOR3;
  25913. /**
  25914. * Quaternion animation type
  25915. */
  25916. private static _ANIMATIONTYPE_QUATERNION;
  25917. /**
  25918. * Matrix animation type
  25919. */
  25920. private static _ANIMATIONTYPE_MATRIX;
  25921. /**
  25922. * Color3 animation type
  25923. */
  25924. private static _ANIMATIONTYPE_COLOR3;
  25925. /**
  25926. * Vector2 animation type
  25927. */
  25928. private static _ANIMATIONTYPE_VECTOR2;
  25929. /**
  25930. * Size animation type
  25931. */
  25932. private static _ANIMATIONTYPE_SIZE;
  25933. /**
  25934. * Relative Loop Mode
  25935. */
  25936. private static _ANIMATIONLOOPMODE_RELATIVE;
  25937. /**
  25938. * Cycle Loop Mode
  25939. */
  25940. private static _ANIMATIONLOOPMODE_CYCLE;
  25941. /**
  25942. * Constant Loop Mode
  25943. */
  25944. private static _ANIMATIONLOOPMODE_CONSTANT;
  25945. /**
  25946. * Get the float animation type
  25947. */
  25948. static readonly ANIMATIONTYPE_FLOAT: number;
  25949. /**
  25950. * Get the Vector3 animation type
  25951. */
  25952. static readonly ANIMATIONTYPE_VECTOR3: number;
  25953. /**
  25954. * Get the Vector2 animation type
  25955. */
  25956. static readonly ANIMATIONTYPE_VECTOR2: number;
  25957. /**
  25958. * Get the Size animation type
  25959. */
  25960. static readonly ANIMATIONTYPE_SIZE: number;
  25961. /**
  25962. * Get the Quaternion animation type
  25963. */
  25964. static readonly ANIMATIONTYPE_QUATERNION: number;
  25965. /**
  25966. * Get the Matrix animation type
  25967. */
  25968. static readonly ANIMATIONTYPE_MATRIX: number;
  25969. /**
  25970. * Get the Color3 animation type
  25971. */
  25972. static readonly ANIMATIONTYPE_COLOR3: number;
  25973. /**
  25974. * Get the Relative Loop Mode
  25975. */
  25976. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25977. /**
  25978. * Get the Cycle Loop Mode
  25979. */
  25980. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25981. /**
  25982. * Get the Constant Loop Mode
  25983. */
  25984. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25985. /** @hidden */
  25986. static _UniversalLerp(left: any, right: any, amount: number): any;
  25987. /**
  25988. * Parses an animation object and creates an animation
  25989. * @param parsedAnimation Parsed animation object
  25990. * @returns Animation object
  25991. */
  25992. static Parse(parsedAnimation: any): Animation;
  25993. /**
  25994. * Appends the serialized animations from the source animations
  25995. * @param source Source containing the animations
  25996. * @param destination Target to store the animations
  25997. */
  25998. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25999. }
  26000. }
  26001. declare module BABYLON {
  26002. /**
  26003. * Base class of all the textures in babylon.
  26004. * It groups all the common properties the materials, post process, lights... might need
  26005. * in order to make a correct use of the texture.
  26006. */
  26007. export class BaseTexture implements IAnimatable {
  26008. /**
  26009. * Default anisotropic filtering level for the application.
  26010. * It is set to 4 as a good tradeoff between perf and quality.
  26011. */
  26012. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26013. /**
  26014. * Gets or sets the unique id of the texture
  26015. */
  26016. uniqueId: number;
  26017. /**
  26018. * Define the name of the texture.
  26019. */
  26020. name: string;
  26021. /**
  26022. * Gets or sets an object used to store user defined information.
  26023. */
  26024. metadata: any;
  26025. /**
  26026. * For internal use only. Please do not use.
  26027. */
  26028. reservedDataStore: any;
  26029. private _hasAlpha;
  26030. /**
  26031. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26032. */
  26033. hasAlpha: boolean;
  26034. /**
  26035. * Defines if the alpha value should be determined via the rgb values.
  26036. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26037. */
  26038. getAlphaFromRGB: boolean;
  26039. /**
  26040. * Intensity or strength of the texture.
  26041. * It is commonly used by materials to fine tune the intensity of the texture
  26042. */
  26043. level: number;
  26044. /**
  26045. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26046. * This is part of the texture as textures usually maps to one uv set.
  26047. */
  26048. coordinatesIndex: number;
  26049. private _coordinatesMode;
  26050. /**
  26051. * How a texture is mapped.
  26052. *
  26053. * | Value | Type | Description |
  26054. * | ----- | ----------------------------------- | ----------- |
  26055. * | 0 | EXPLICIT_MODE | |
  26056. * | 1 | SPHERICAL_MODE | |
  26057. * | 2 | PLANAR_MODE | |
  26058. * | 3 | CUBIC_MODE | |
  26059. * | 4 | PROJECTION_MODE | |
  26060. * | 5 | SKYBOX_MODE | |
  26061. * | 6 | INVCUBIC_MODE | |
  26062. * | 7 | EQUIRECTANGULAR_MODE | |
  26063. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26064. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26065. */
  26066. coordinatesMode: number;
  26067. /**
  26068. * | Value | Type | Description |
  26069. * | ----- | ------------------ | ----------- |
  26070. * | 0 | CLAMP_ADDRESSMODE | |
  26071. * | 1 | WRAP_ADDRESSMODE | |
  26072. * | 2 | MIRROR_ADDRESSMODE | |
  26073. */
  26074. wrapU: number;
  26075. /**
  26076. * | Value | Type | Description |
  26077. * | ----- | ------------------ | ----------- |
  26078. * | 0 | CLAMP_ADDRESSMODE | |
  26079. * | 1 | WRAP_ADDRESSMODE | |
  26080. * | 2 | MIRROR_ADDRESSMODE | |
  26081. */
  26082. wrapV: number;
  26083. /**
  26084. * | Value | Type | Description |
  26085. * | ----- | ------------------ | ----------- |
  26086. * | 0 | CLAMP_ADDRESSMODE | |
  26087. * | 1 | WRAP_ADDRESSMODE | |
  26088. * | 2 | MIRROR_ADDRESSMODE | |
  26089. */
  26090. wrapR: number;
  26091. /**
  26092. * With compliant hardware and browser (supporting anisotropic filtering)
  26093. * this defines the level of anisotropic filtering in the texture.
  26094. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26095. */
  26096. anisotropicFilteringLevel: number;
  26097. /**
  26098. * Define if the texture is a cube texture or if false a 2d texture.
  26099. */
  26100. isCube: boolean;
  26101. /**
  26102. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26103. */
  26104. is3D: boolean;
  26105. /**
  26106. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26107. * HDR texture are usually stored in linear space.
  26108. * This only impacts the PBR and Background materials
  26109. */
  26110. gammaSpace: boolean;
  26111. /**
  26112. * Gets whether or not the texture contains RGBD data.
  26113. */
  26114. readonly isRGBD: boolean;
  26115. /**
  26116. * Is Z inverted in the texture (useful in a cube texture).
  26117. */
  26118. invertZ: boolean;
  26119. /**
  26120. * Are mip maps generated for this texture or not.
  26121. */
  26122. readonly noMipmap: boolean;
  26123. /**
  26124. * @hidden
  26125. */
  26126. lodLevelInAlpha: boolean;
  26127. /**
  26128. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26129. */
  26130. lodGenerationOffset: number;
  26131. /**
  26132. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26133. */
  26134. lodGenerationScale: number;
  26135. /**
  26136. * Define if the texture is a render target.
  26137. */
  26138. isRenderTarget: boolean;
  26139. /**
  26140. * Define the unique id of the texture in the scene.
  26141. */
  26142. readonly uid: string;
  26143. /**
  26144. * Return a string representation of the texture.
  26145. * @returns the texture as a string
  26146. */
  26147. toString(): string;
  26148. /**
  26149. * Get the class name of the texture.
  26150. * @returns "BaseTexture"
  26151. */
  26152. getClassName(): string;
  26153. /**
  26154. * Define the list of animation attached to the texture.
  26155. */
  26156. animations: Animation[];
  26157. /**
  26158. * An event triggered when the texture is disposed.
  26159. */
  26160. onDisposeObservable: Observable<BaseTexture>;
  26161. private _onDisposeObserver;
  26162. /**
  26163. * Callback triggered when the texture has been disposed.
  26164. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26165. */
  26166. onDispose: () => void;
  26167. /**
  26168. * Define the current state of the loading sequence when in delayed load mode.
  26169. */
  26170. delayLoadState: number;
  26171. private _scene;
  26172. /** @hidden */
  26173. _texture: Nullable<InternalTexture>;
  26174. private _uid;
  26175. /**
  26176. * Define if the texture is preventinga material to render or not.
  26177. * If not and the texture is not ready, the engine will use a default black texture instead.
  26178. */
  26179. readonly isBlocking: boolean;
  26180. /**
  26181. * Instantiates a new BaseTexture.
  26182. * Base class of all the textures in babylon.
  26183. * It groups all the common properties the materials, post process, lights... might need
  26184. * in order to make a correct use of the texture.
  26185. * @param scene Define the scene the texture blongs to
  26186. */
  26187. constructor(scene: Nullable<Scene>);
  26188. /**
  26189. * Get the scene the texture belongs to.
  26190. * @returns the scene or null if undefined
  26191. */
  26192. getScene(): Nullable<Scene>;
  26193. /**
  26194. * Get the texture transform matrix used to offset tile the texture for istance.
  26195. * @returns the transformation matrix
  26196. */
  26197. getTextureMatrix(): Matrix;
  26198. /**
  26199. * Get the texture reflection matrix used to rotate/transform the reflection.
  26200. * @returns the reflection matrix
  26201. */
  26202. getReflectionTextureMatrix(): Matrix;
  26203. /**
  26204. * Get the underlying lower level texture from Babylon.
  26205. * @returns the insternal texture
  26206. */
  26207. getInternalTexture(): Nullable<InternalTexture>;
  26208. /**
  26209. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26210. * @returns true if ready or not blocking
  26211. */
  26212. isReadyOrNotBlocking(): boolean;
  26213. /**
  26214. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26215. * @returns true if fully ready
  26216. */
  26217. isReady(): boolean;
  26218. private _cachedSize;
  26219. /**
  26220. * Get the size of the texture.
  26221. * @returns the texture size.
  26222. */
  26223. getSize(): ISize;
  26224. /**
  26225. * Get the base size of the texture.
  26226. * It can be different from the size if the texture has been resized for POT for instance
  26227. * @returns the base size
  26228. */
  26229. getBaseSize(): ISize;
  26230. /**
  26231. * Update the sampling mode of the texture.
  26232. * Default is Trilinear mode.
  26233. *
  26234. * | Value | Type | Description |
  26235. * | ----- | ------------------ | ----------- |
  26236. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26237. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26238. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26239. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26240. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26241. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26242. * | 7 | NEAREST_LINEAR | |
  26243. * | 8 | NEAREST_NEAREST | |
  26244. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26245. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26246. * | 11 | LINEAR_LINEAR | |
  26247. * | 12 | LINEAR_NEAREST | |
  26248. *
  26249. * > _mag_: magnification filter (close to the viewer)
  26250. * > _min_: minification filter (far from the viewer)
  26251. * > _mip_: filter used between mip map levels
  26252. *@param samplingMode Define the new sampling mode of the texture
  26253. */
  26254. updateSamplingMode(samplingMode: number): void;
  26255. /**
  26256. * Scales the texture if is `canRescale()`
  26257. * @param ratio the resize factor we want to use to rescale
  26258. */
  26259. scale(ratio: number): void;
  26260. /**
  26261. * Get if the texture can rescale.
  26262. */
  26263. readonly canRescale: boolean;
  26264. /** @hidden */
  26265. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26266. /** @hidden */
  26267. _rebuild(): void;
  26268. /**
  26269. * Triggers the load sequence in delayed load mode.
  26270. */
  26271. delayLoad(): void;
  26272. /**
  26273. * Clones the texture.
  26274. * @returns the cloned texture
  26275. */
  26276. clone(): Nullable<BaseTexture>;
  26277. /**
  26278. * Get the texture underlying type (INT, FLOAT...)
  26279. */
  26280. readonly textureType: number;
  26281. /**
  26282. * Get the texture underlying format (RGB, RGBA...)
  26283. */
  26284. readonly textureFormat: number;
  26285. /**
  26286. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26287. * This will returns an RGBA array buffer containing either in values (0-255) or
  26288. * float values (0-1) depending of the underlying buffer type.
  26289. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26290. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26291. * @param buffer defines a user defined buffer to fill with data (can be null)
  26292. * @returns The Array buffer containing the pixels data.
  26293. */
  26294. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26295. /**
  26296. * Release and destroy the underlying lower level texture aka internalTexture.
  26297. */
  26298. releaseInternalTexture(): void;
  26299. /**
  26300. * Get the polynomial representation of the texture data.
  26301. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26302. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26303. */
  26304. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26305. /** @hidden */
  26306. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26307. /** @hidden */
  26308. readonly _lodTextureMid: Nullable<BaseTexture>;
  26309. /** @hidden */
  26310. readonly _lodTextureLow: Nullable<BaseTexture>;
  26311. /**
  26312. * Dispose the texture and release its associated resources.
  26313. */
  26314. dispose(): void;
  26315. /**
  26316. * Serialize the texture into a JSON representation that can be parsed later on.
  26317. * @returns the JSON representation of the texture
  26318. */
  26319. serialize(): any;
  26320. /**
  26321. * Helper function to be called back once a list of texture contains only ready textures.
  26322. * @param textures Define the list of textures to wait for
  26323. * @param callback Define the callback triggered once the entire list will be ready
  26324. */
  26325. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26326. }
  26327. }
  26328. declare module BABYLON {
  26329. /**
  26330. * Uniform buffer objects.
  26331. *
  26332. * Handles blocks of uniform on the GPU.
  26333. *
  26334. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26335. *
  26336. * For more information, please refer to :
  26337. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26338. */
  26339. export class UniformBuffer {
  26340. private _engine;
  26341. private _buffer;
  26342. private _data;
  26343. private _bufferData;
  26344. private _dynamic?;
  26345. private _uniformLocations;
  26346. private _uniformSizes;
  26347. private _uniformLocationPointer;
  26348. private _needSync;
  26349. private _noUBO;
  26350. private _currentEffect;
  26351. private static _MAX_UNIFORM_SIZE;
  26352. private static _tempBuffer;
  26353. /**
  26354. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26355. * This is dynamic to allow compat with webgl 1 and 2.
  26356. * You will need to pass the name of the uniform as well as the value.
  26357. */
  26358. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26359. /**
  26360. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26361. * This is dynamic to allow compat with webgl 1 and 2.
  26362. * You will need to pass the name of the uniform as well as the value.
  26363. */
  26364. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26365. /**
  26366. * Lambda to Update a single float in a uniform buffer.
  26367. * This is dynamic to allow compat with webgl 1 and 2.
  26368. * You will need to pass the name of the uniform as well as the value.
  26369. */
  26370. updateFloat: (name: string, x: number) => void;
  26371. /**
  26372. * Lambda to Update a vec2 of float in a uniform buffer.
  26373. * This is dynamic to allow compat with webgl 1 and 2.
  26374. * You will need to pass the name of the uniform as well as the value.
  26375. */
  26376. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26377. /**
  26378. * Lambda to Update a vec3 of float in a uniform buffer.
  26379. * This is dynamic to allow compat with webgl 1 and 2.
  26380. * You will need to pass the name of the uniform as well as the value.
  26381. */
  26382. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26383. /**
  26384. * Lambda to Update a vec4 of float in a uniform buffer.
  26385. * This is dynamic to allow compat with webgl 1 and 2.
  26386. * You will need to pass the name of the uniform as well as the value.
  26387. */
  26388. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26389. /**
  26390. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26391. * This is dynamic to allow compat with webgl 1 and 2.
  26392. * You will need to pass the name of the uniform as well as the value.
  26393. */
  26394. updateMatrix: (name: string, mat: Matrix) => void;
  26395. /**
  26396. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26397. * This is dynamic to allow compat with webgl 1 and 2.
  26398. * You will need to pass the name of the uniform as well as the value.
  26399. */
  26400. updateVector3: (name: string, vector: Vector3) => void;
  26401. /**
  26402. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26403. * This is dynamic to allow compat with webgl 1 and 2.
  26404. * You will need to pass the name of the uniform as well as the value.
  26405. */
  26406. updateVector4: (name: string, vector: Vector4) => void;
  26407. /**
  26408. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26409. * This is dynamic to allow compat with webgl 1 and 2.
  26410. * You will need to pass the name of the uniform as well as the value.
  26411. */
  26412. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26413. /**
  26414. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26415. * This is dynamic to allow compat with webgl 1 and 2.
  26416. * You will need to pass the name of the uniform as well as the value.
  26417. */
  26418. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26419. /**
  26420. * Instantiates a new Uniform buffer objects.
  26421. *
  26422. * Handles blocks of uniform on the GPU.
  26423. *
  26424. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26425. *
  26426. * For more information, please refer to :
  26427. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26428. * @param engine Define the engine the buffer is associated with
  26429. * @param data Define the data contained in the buffer
  26430. * @param dynamic Define if the buffer is updatable
  26431. */
  26432. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26433. /**
  26434. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26435. * or just falling back on setUniformXXX calls.
  26436. */
  26437. readonly useUbo: boolean;
  26438. /**
  26439. * Indicates if the WebGL underlying uniform buffer is in sync
  26440. * with the javascript cache data.
  26441. */
  26442. readonly isSync: boolean;
  26443. /**
  26444. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26445. * Also, a dynamic UniformBuffer will disable cache verification and always
  26446. * update the underlying WebGL uniform buffer to the GPU.
  26447. * @returns if Dynamic, otherwise false
  26448. */
  26449. isDynamic(): boolean;
  26450. /**
  26451. * The data cache on JS side.
  26452. * @returns the underlying data as a float array
  26453. */
  26454. getData(): Float32Array;
  26455. /**
  26456. * The underlying WebGL Uniform buffer.
  26457. * @returns the webgl buffer
  26458. */
  26459. getBuffer(): Nullable<DataBuffer>;
  26460. /**
  26461. * std140 layout specifies how to align data within an UBO structure.
  26462. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26463. * for specs.
  26464. */
  26465. private _fillAlignment;
  26466. /**
  26467. * Adds an uniform in the buffer.
  26468. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26469. * for the layout to be correct !
  26470. * @param name Name of the uniform, as used in the uniform block in the shader.
  26471. * @param size Data size, or data directly.
  26472. */
  26473. addUniform(name: string, size: number | number[]): void;
  26474. /**
  26475. * Adds a Matrix 4x4 to the uniform buffer.
  26476. * @param name Name of the uniform, as used in the uniform block in the shader.
  26477. * @param mat A 4x4 matrix.
  26478. */
  26479. addMatrix(name: string, mat: Matrix): void;
  26480. /**
  26481. * Adds a vec2 to the uniform buffer.
  26482. * @param name Name of the uniform, as used in the uniform block in the shader.
  26483. * @param x Define the x component value of the vec2
  26484. * @param y Define the y component value of the vec2
  26485. */
  26486. addFloat2(name: string, x: number, y: number): void;
  26487. /**
  26488. * Adds a vec3 to the uniform buffer.
  26489. * @param name Name of the uniform, as used in the uniform block in the shader.
  26490. * @param x Define the x component value of the vec3
  26491. * @param y Define the y component value of the vec3
  26492. * @param z Define the z component value of the vec3
  26493. */
  26494. addFloat3(name: string, x: number, y: number, z: number): void;
  26495. /**
  26496. * Adds a vec3 to the uniform buffer.
  26497. * @param name Name of the uniform, as used in the uniform block in the shader.
  26498. * @param color Define the vec3 from a Color
  26499. */
  26500. addColor3(name: string, color: Color3): void;
  26501. /**
  26502. * Adds a vec4 to the uniform buffer.
  26503. * @param name Name of the uniform, as used in the uniform block in the shader.
  26504. * @param color Define the rgb components from a Color
  26505. * @param alpha Define the a component of the vec4
  26506. */
  26507. addColor4(name: string, color: Color3, alpha: number): void;
  26508. /**
  26509. * Adds a vec3 to the uniform buffer.
  26510. * @param name Name of the uniform, as used in the uniform block in the shader.
  26511. * @param vector Define the vec3 components from a Vector
  26512. */
  26513. addVector3(name: string, vector: Vector3): void;
  26514. /**
  26515. * Adds a Matrix 3x3 to the uniform buffer.
  26516. * @param name Name of the uniform, as used in the uniform block in the shader.
  26517. */
  26518. addMatrix3x3(name: string): void;
  26519. /**
  26520. * Adds a Matrix 2x2 to the uniform buffer.
  26521. * @param name Name of the uniform, as used in the uniform block in the shader.
  26522. */
  26523. addMatrix2x2(name: string): void;
  26524. /**
  26525. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26526. */
  26527. create(): void;
  26528. /** @hidden */
  26529. _rebuild(): void;
  26530. /**
  26531. * Updates the WebGL Uniform Buffer on the GPU.
  26532. * If the `dynamic` flag is set to true, no cache comparison is done.
  26533. * Otherwise, the buffer will be updated only if the cache differs.
  26534. */
  26535. update(): void;
  26536. /**
  26537. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26538. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26539. * @param data Define the flattened data
  26540. * @param size Define the size of the data.
  26541. */
  26542. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26543. private _updateMatrix3x3ForUniform;
  26544. private _updateMatrix3x3ForEffect;
  26545. private _updateMatrix2x2ForEffect;
  26546. private _updateMatrix2x2ForUniform;
  26547. private _updateFloatForEffect;
  26548. private _updateFloatForUniform;
  26549. private _updateFloat2ForEffect;
  26550. private _updateFloat2ForUniform;
  26551. private _updateFloat3ForEffect;
  26552. private _updateFloat3ForUniform;
  26553. private _updateFloat4ForEffect;
  26554. private _updateFloat4ForUniform;
  26555. private _updateMatrixForEffect;
  26556. private _updateMatrixForUniform;
  26557. private _updateVector3ForEffect;
  26558. private _updateVector3ForUniform;
  26559. private _updateVector4ForEffect;
  26560. private _updateVector4ForUniform;
  26561. private _updateColor3ForEffect;
  26562. private _updateColor3ForUniform;
  26563. private _updateColor4ForEffect;
  26564. private _updateColor4ForUniform;
  26565. /**
  26566. * Sets a sampler uniform on the effect.
  26567. * @param name Define the name of the sampler.
  26568. * @param texture Define the texture to set in the sampler
  26569. */
  26570. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26571. /**
  26572. * Directly updates the value of the uniform in the cache AND on the GPU.
  26573. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26574. * @param data Define the flattened data
  26575. */
  26576. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26577. /**
  26578. * Binds this uniform buffer to an effect.
  26579. * @param effect Define the effect to bind the buffer to
  26580. * @param name Name of the uniform block in the shader.
  26581. */
  26582. bindToEffect(effect: Effect, name: string): void;
  26583. /**
  26584. * Disposes the uniform buffer.
  26585. */
  26586. dispose(): void;
  26587. }
  26588. }
  26589. declare module BABYLON {
  26590. /**
  26591. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26593. */
  26594. export class Analyser {
  26595. /**
  26596. * Gets or sets the smoothing
  26597. * @ignorenaming
  26598. */
  26599. SMOOTHING: number;
  26600. /**
  26601. * Gets or sets the FFT table size
  26602. * @ignorenaming
  26603. */
  26604. FFT_SIZE: number;
  26605. /**
  26606. * Gets or sets the bar graph amplitude
  26607. * @ignorenaming
  26608. */
  26609. BARGRAPHAMPLITUDE: number;
  26610. /**
  26611. * Gets or sets the position of the debug canvas
  26612. * @ignorenaming
  26613. */
  26614. DEBUGCANVASPOS: {
  26615. x: number;
  26616. y: number;
  26617. };
  26618. /**
  26619. * Gets or sets the debug canvas size
  26620. * @ignorenaming
  26621. */
  26622. DEBUGCANVASSIZE: {
  26623. width: number;
  26624. height: number;
  26625. };
  26626. private _byteFreqs;
  26627. private _byteTime;
  26628. private _floatFreqs;
  26629. private _webAudioAnalyser;
  26630. private _debugCanvas;
  26631. private _debugCanvasContext;
  26632. private _scene;
  26633. private _registerFunc;
  26634. private _audioEngine;
  26635. /**
  26636. * Creates a new analyser
  26637. * @param scene defines hosting scene
  26638. */
  26639. constructor(scene: Scene);
  26640. /**
  26641. * Get the number of data values you will have to play with for the visualization
  26642. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26643. * @returns a number
  26644. */
  26645. getFrequencyBinCount(): number;
  26646. /**
  26647. * Gets the current frequency data as a byte array
  26648. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26649. * @returns a Uint8Array
  26650. */
  26651. getByteFrequencyData(): Uint8Array;
  26652. /**
  26653. * Gets the current waveform as a byte array
  26654. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26655. * @returns a Uint8Array
  26656. */
  26657. getByteTimeDomainData(): Uint8Array;
  26658. /**
  26659. * Gets the current frequency data as a float array
  26660. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26661. * @returns a Float32Array
  26662. */
  26663. getFloatFrequencyData(): Float32Array;
  26664. /**
  26665. * Renders the debug canvas
  26666. */
  26667. drawDebugCanvas(): void;
  26668. /**
  26669. * Stops rendering the debug canvas and removes it
  26670. */
  26671. stopDebugCanvas(): void;
  26672. /**
  26673. * Connects two audio nodes
  26674. * @param inputAudioNode defines first node to connect
  26675. * @param outputAudioNode defines second node to connect
  26676. */
  26677. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26678. /**
  26679. * Releases all associated resources
  26680. */
  26681. dispose(): void;
  26682. }
  26683. }
  26684. declare module BABYLON {
  26685. /**
  26686. * This represents an audio engine and it is responsible
  26687. * to play, synchronize and analyse sounds throughout the application.
  26688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26689. */
  26690. export interface IAudioEngine extends IDisposable {
  26691. /**
  26692. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26693. */
  26694. readonly canUseWebAudio: boolean;
  26695. /**
  26696. * Gets the current AudioContext if available.
  26697. */
  26698. readonly audioContext: Nullable<AudioContext>;
  26699. /**
  26700. * The master gain node defines the global audio volume of your audio engine.
  26701. */
  26702. readonly masterGain: GainNode;
  26703. /**
  26704. * Gets whether or not mp3 are supported by your browser.
  26705. */
  26706. readonly isMP3supported: boolean;
  26707. /**
  26708. * Gets whether or not ogg are supported by your browser.
  26709. */
  26710. readonly isOGGsupported: boolean;
  26711. /**
  26712. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26713. * @ignoreNaming
  26714. */
  26715. WarnedWebAudioUnsupported: boolean;
  26716. /**
  26717. * Defines if the audio engine relies on a custom unlocked button.
  26718. * In this case, the embedded button will not be displayed.
  26719. */
  26720. useCustomUnlockedButton: boolean;
  26721. /**
  26722. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26723. */
  26724. readonly unlocked: boolean;
  26725. /**
  26726. * Event raised when audio has been unlocked on the browser.
  26727. */
  26728. onAudioUnlockedObservable: Observable<AudioEngine>;
  26729. /**
  26730. * Event raised when audio has been locked on the browser.
  26731. */
  26732. onAudioLockedObservable: Observable<AudioEngine>;
  26733. /**
  26734. * Flags the audio engine in Locked state.
  26735. * This happens due to new browser policies preventing audio to autoplay.
  26736. */
  26737. lock(): void;
  26738. /**
  26739. * Unlocks the audio engine once a user action has been done on the dom.
  26740. * This is helpful to resume play once browser policies have been satisfied.
  26741. */
  26742. unlock(): void;
  26743. }
  26744. /**
  26745. * This represents the default audio engine used in babylon.
  26746. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26748. */
  26749. export class AudioEngine implements IAudioEngine {
  26750. private _audioContext;
  26751. private _audioContextInitialized;
  26752. private _muteButton;
  26753. private _hostElement;
  26754. /**
  26755. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26756. */
  26757. canUseWebAudio: boolean;
  26758. /**
  26759. * The master gain node defines the global audio volume of your audio engine.
  26760. */
  26761. masterGain: GainNode;
  26762. /**
  26763. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26764. * @ignoreNaming
  26765. */
  26766. WarnedWebAudioUnsupported: boolean;
  26767. /**
  26768. * Gets whether or not mp3 are supported by your browser.
  26769. */
  26770. isMP3supported: boolean;
  26771. /**
  26772. * Gets whether or not ogg are supported by your browser.
  26773. */
  26774. isOGGsupported: boolean;
  26775. /**
  26776. * Gets whether audio has been unlocked on the device.
  26777. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26778. * a user interaction has happened.
  26779. */
  26780. unlocked: boolean;
  26781. /**
  26782. * Defines if the audio engine relies on a custom unlocked button.
  26783. * In this case, the embedded button will not be displayed.
  26784. */
  26785. useCustomUnlockedButton: boolean;
  26786. /**
  26787. * Event raised when audio has been unlocked on the browser.
  26788. */
  26789. onAudioUnlockedObservable: Observable<AudioEngine>;
  26790. /**
  26791. * Event raised when audio has been locked on the browser.
  26792. */
  26793. onAudioLockedObservable: Observable<AudioEngine>;
  26794. /**
  26795. * Gets the current AudioContext if available.
  26796. */
  26797. readonly audioContext: Nullable<AudioContext>;
  26798. private _connectedAnalyser;
  26799. /**
  26800. * Instantiates a new audio engine.
  26801. *
  26802. * There should be only one per page as some browsers restrict the number
  26803. * of audio contexts you can create.
  26804. * @param hostElement defines the host element where to display the mute icon if necessary
  26805. */
  26806. constructor(hostElement?: Nullable<HTMLElement>);
  26807. /**
  26808. * Flags the audio engine in Locked state.
  26809. * This happens due to new browser policies preventing audio to autoplay.
  26810. */
  26811. lock(): void;
  26812. /**
  26813. * Unlocks the audio engine once a user action has been done on the dom.
  26814. * This is helpful to resume play once browser policies have been satisfied.
  26815. */
  26816. unlock(): void;
  26817. private _resumeAudioContext;
  26818. private _initializeAudioContext;
  26819. private _tryToRun;
  26820. private _triggerRunningState;
  26821. private _triggerSuspendedState;
  26822. private _displayMuteButton;
  26823. private _moveButtonToTopLeft;
  26824. private _onResize;
  26825. private _hideMuteButton;
  26826. /**
  26827. * Destroy and release the resources associated with the audio ccontext.
  26828. */
  26829. dispose(): void;
  26830. /**
  26831. * Gets the global volume sets on the master gain.
  26832. * @returns the global volume if set or -1 otherwise
  26833. */
  26834. getGlobalVolume(): number;
  26835. /**
  26836. * Sets the global volume of your experience (sets on the master gain).
  26837. * @param newVolume Defines the new global volume of the application
  26838. */
  26839. setGlobalVolume(newVolume: number): void;
  26840. /**
  26841. * Connect the audio engine to an audio analyser allowing some amazing
  26842. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26844. * @param analyser The analyser to connect to the engine
  26845. */
  26846. connectToAnalyser(analyser: Analyser): void;
  26847. }
  26848. }
  26849. declare module BABYLON {
  26850. /**
  26851. * Interface used to present a loading screen while loading a scene
  26852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26853. */
  26854. export interface ILoadingScreen {
  26855. /**
  26856. * Function called to display the loading screen
  26857. */
  26858. displayLoadingUI: () => void;
  26859. /**
  26860. * Function called to hide the loading screen
  26861. */
  26862. hideLoadingUI: () => void;
  26863. /**
  26864. * Gets or sets the color to use for the background
  26865. */
  26866. loadingUIBackgroundColor: string;
  26867. /**
  26868. * Gets or sets the text to display while loading
  26869. */
  26870. loadingUIText: string;
  26871. }
  26872. /**
  26873. * Class used for the default loading screen
  26874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26875. */
  26876. export class DefaultLoadingScreen implements ILoadingScreen {
  26877. private _renderingCanvas;
  26878. private _loadingText;
  26879. private _loadingDivBackgroundColor;
  26880. private _loadingDiv;
  26881. private _loadingTextDiv;
  26882. /** Gets or sets the logo url to use for the default loading screen */
  26883. static DefaultLogoUrl: string;
  26884. /** Gets or sets the spinner url to use for the default loading screen */
  26885. static DefaultSpinnerUrl: string;
  26886. /**
  26887. * Creates a new default loading screen
  26888. * @param _renderingCanvas defines the canvas used to render the scene
  26889. * @param _loadingText defines the default text to display
  26890. * @param _loadingDivBackgroundColor defines the default background color
  26891. */
  26892. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26893. /**
  26894. * Function called to display the loading screen
  26895. */
  26896. displayLoadingUI(): void;
  26897. /**
  26898. * Function called to hide the loading screen
  26899. */
  26900. hideLoadingUI(): void;
  26901. /**
  26902. * Gets or sets the text to display while loading
  26903. */
  26904. loadingUIText: string;
  26905. /**
  26906. * Gets or sets the color to use for the background
  26907. */
  26908. loadingUIBackgroundColor: string;
  26909. private _resizeLoadingUI;
  26910. }
  26911. }
  26912. declare module BABYLON {
  26913. /** @hidden */
  26914. export class WebGLPipelineContext implements IPipelineContext {
  26915. engine: Engine;
  26916. program: Nullable<WebGLProgram>;
  26917. context?: WebGLRenderingContext;
  26918. vertexShader?: WebGLShader;
  26919. fragmentShader?: WebGLShader;
  26920. isParallelCompiled: boolean;
  26921. onCompiled?: () => void;
  26922. transformFeedback?: WebGLTransformFeedback | null;
  26923. readonly isAsync: boolean;
  26924. readonly isReady: boolean;
  26925. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26926. }
  26927. }
  26928. declare module BABYLON {
  26929. /** @hidden */
  26930. export class WebGLDataBuffer extends DataBuffer {
  26931. private _buffer;
  26932. constructor(resource: WebGLBuffer);
  26933. readonly underlyingResource: any;
  26934. }
  26935. }
  26936. declare module BABYLON {
  26937. /**
  26938. * Settings for finer control over video usage
  26939. */
  26940. export interface VideoTextureSettings {
  26941. /**
  26942. * Applies `autoplay` to video, if specified
  26943. */
  26944. autoPlay?: boolean;
  26945. /**
  26946. * Applies `loop` to video, if specified
  26947. */
  26948. loop?: boolean;
  26949. /**
  26950. * Automatically updates internal texture from video at every frame in the render loop
  26951. */
  26952. autoUpdateTexture: boolean;
  26953. /**
  26954. * Image src displayed during the video loading or until the user interacts with the video.
  26955. */
  26956. poster?: string;
  26957. }
  26958. /**
  26959. * If you want to display a video in your scene, this is the special texture for that.
  26960. * This special texture works similar to other textures, with the exception of a few parameters.
  26961. * @see https://doc.babylonjs.com/how_to/video_texture
  26962. */
  26963. export class VideoTexture extends Texture {
  26964. /**
  26965. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26966. */
  26967. readonly autoUpdateTexture: boolean;
  26968. /**
  26969. * The video instance used by the texture internally
  26970. */
  26971. readonly video: HTMLVideoElement;
  26972. private _onUserActionRequestedObservable;
  26973. /**
  26974. * Event triggerd when a dom action is required by the user to play the video.
  26975. * This happens due to recent changes in browser policies preventing video to auto start.
  26976. */
  26977. readonly onUserActionRequestedObservable: Observable<Texture>;
  26978. private _generateMipMaps;
  26979. private _engine;
  26980. private _stillImageCaptured;
  26981. private _displayingPosterTexture;
  26982. private _settings;
  26983. private _createInternalTextureOnEvent;
  26984. /**
  26985. * Creates a video texture.
  26986. * If you want to display a video in your scene, this is the special texture for that.
  26987. * This special texture works similar to other textures, with the exception of a few parameters.
  26988. * @see https://doc.babylonjs.com/how_to/video_texture
  26989. * @param name optional name, will detect from video source, if not defined
  26990. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26991. * @param scene is obviously the current scene.
  26992. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26993. * @param invertY is false by default but can be used to invert video on Y axis
  26994. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26995. * @param settings allows finer control over video usage
  26996. */
  26997. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26998. private _getName;
  26999. private _getVideo;
  27000. private _createInternalTexture;
  27001. private reset;
  27002. /**
  27003. * @hidden Internal method to initiate `update`.
  27004. */
  27005. _rebuild(): void;
  27006. /**
  27007. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27008. */
  27009. update(): void;
  27010. /**
  27011. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27012. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27013. */
  27014. updateTexture(isVisible: boolean): void;
  27015. protected _updateInternalTexture: () => void;
  27016. /**
  27017. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27018. * @param url New url.
  27019. */
  27020. updateURL(url: string): void;
  27021. /**
  27022. * Dispose the texture and release its associated resources.
  27023. */
  27024. dispose(): void;
  27025. /**
  27026. * Creates a video texture straight from a stream.
  27027. * @param scene Define the scene the texture should be created in
  27028. * @param stream Define the stream the texture should be created from
  27029. * @returns The created video texture as a promise
  27030. */
  27031. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27032. /**
  27033. * Creates a video texture straight from your WebCam video feed.
  27034. * @param scene Define the scene the texture should be created in
  27035. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27036. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27037. * @returns The created video texture as a promise
  27038. */
  27039. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27040. minWidth: number;
  27041. maxWidth: number;
  27042. minHeight: number;
  27043. maxHeight: number;
  27044. deviceId: string;
  27045. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27046. /**
  27047. * Creates a video texture straight from your WebCam video feed.
  27048. * @param scene Define the scene the texture should be created in
  27049. * @param onReady Define a callback to triggered once the texture will be ready
  27050. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27051. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27052. */
  27053. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27054. minWidth: number;
  27055. maxWidth: number;
  27056. minHeight: number;
  27057. maxHeight: number;
  27058. deviceId: string;
  27059. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27060. }
  27061. }
  27062. declare module BABYLON {
  27063. /**
  27064. * Interface for attribute information associated with buffer instanciation
  27065. */
  27066. export class InstancingAttributeInfo {
  27067. /**
  27068. * Index/offset of the attribute in the vertex shader
  27069. */
  27070. index: number;
  27071. /**
  27072. * size of the attribute, 1, 2, 3 or 4
  27073. */
  27074. attributeSize: number;
  27075. /**
  27076. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27077. * default is FLOAT
  27078. */
  27079. attribyteType: number;
  27080. /**
  27081. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27082. */
  27083. normalized: boolean;
  27084. /**
  27085. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27086. */
  27087. offset: number;
  27088. /**
  27089. * Name of the GLSL attribute, for debugging purpose only
  27090. */
  27091. attributeName: string;
  27092. }
  27093. /**
  27094. * Define options used to create a depth texture
  27095. */
  27096. export class DepthTextureCreationOptions {
  27097. /** Specifies whether or not a stencil should be allocated in the texture */
  27098. generateStencil?: boolean;
  27099. /** Specifies whether or not bilinear filtering is enable on the texture */
  27100. bilinearFiltering?: boolean;
  27101. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27102. comparisonFunction?: number;
  27103. /** Specifies if the created texture is a cube texture */
  27104. isCube?: boolean;
  27105. }
  27106. /**
  27107. * Class used to describe the capabilities of the engine relatively to the current browser
  27108. */
  27109. export class EngineCapabilities {
  27110. /** Maximum textures units per fragment shader */
  27111. maxTexturesImageUnits: number;
  27112. /** Maximum texture units per vertex shader */
  27113. maxVertexTextureImageUnits: number;
  27114. /** Maximum textures units in the entire pipeline */
  27115. maxCombinedTexturesImageUnits: number;
  27116. /** Maximum texture size */
  27117. maxTextureSize: number;
  27118. /** Maximum cube texture size */
  27119. maxCubemapTextureSize: number;
  27120. /** Maximum render texture size */
  27121. maxRenderTextureSize: number;
  27122. /** Maximum number of vertex attributes */
  27123. maxVertexAttribs: number;
  27124. /** Maximum number of varyings */
  27125. maxVaryingVectors: number;
  27126. /** Maximum number of uniforms per vertex shader */
  27127. maxVertexUniformVectors: number;
  27128. /** Maximum number of uniforms per fragment shader */
  27129. maxFragmentUniformVectors: number;
  27130. /** Defines if standard derivates (dx/dy) are supported */
  27131. standardDerivatives: boolean;
  27132. /** Defines if s3tc texture compression is supported */
  27133. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27134. /** Defines if pvrtc texture compression is supported */
  27135. pvrtc: any;
  27136. /** Defines if etc1 texture compression is supported */
  27137. etc1: any;
  27138. /** Defines if etc2 texture compression is supported */
  27139. etc2: any;
  27140. /** Defines if astc texture compression is supported */
  27141. astc: any;
  27142. /** Defines if float textures are supported */
  27143. textureFloat: boolean;
  27144. /** Defines if vertex array objects are supported */
  27145. vertexArrayObject: boolean;
  27146. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27147. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27148. /** Gets the maximum level of anisotropy supported */
  27149. maxAnisotropy: number;
  27150. /** Defines if instancing is supported */
  27151. instancedArrays: boolean;
  27152. /** Defines if 32 bits indices are supported */
  27153. uintIndices: boolean;
  27154. /** Defines if high precision shaders are supported */
  27155. highPrecisionShaderSupported: boolean;
  27156. /** Defines if depth reading in the fragment shader is supported */
  27157. fragmentDepthSupported: boolean;
  27158. /** Defines if float texture linear filtering is supported*/
  27159. textureFloatLinearFiltering: boolean;
  27160. /** Defines if rendering to float textures is supported */
  27161. textureFloatRender: boolean;
  27162. /** Defines if half float textures are supported*/
  27163. textureHalfFloat: boolean;
  27164. /** Defines if half float texture linear filtering is supported*/
  27165. textureHalfFloatLinearFiltering: boolean;
  27166. /** Defines if rendering to half float textures is supported */
  27167. textureHalfFloatRender: boolean;
  27168. /** Defines if textureLOD shader command is supported */
  27169. textureLOD: boolean;
  27170. /** Defines if draw buffers extension is supported */
  27171. drawBuffersExtension: boolean;
  27172. /** Defines if depth textures are supported */
  27173. depthTextureExtension: boolean;
  27174. /** Defines if float color buffer are supported */
  27175. colorBufferFloat: boolean;
  27176. /** Gets disjoint timer query extension (null if not supported) */
  27177. timerQuery: EXT_disjoint_timer_query;
  27178. /** Defines if timestamp can be used with timer query */
  27179. canUseTimestampForTimerQuery: boolean;
  27180. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27181. multiview: any;
  27182. /** Function used to let the system compiles shaders in background */
  27183. parallelShaderCompile: {
  27184. COMPLETION_STATUS_KHR: number;
  27185. };
  27186. }
  27187. /** Interface defining initialization parameters for Engine class */
  27188. export interface EngineOptions extends WebGLContextAttributes {
  27189. /**
  27190. * Defines if the engine should no exceed a specified device ratio
  27191. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27192. */
  27193. limitDeviceRatio?: number;
  27194. /**
  27195. * Defines if webvr should be enabled automatically
  27196. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27197. */
  27198. autoEnableWebVR?: boolean;
  27199. /**
  27200. * Defines if webgl2 should be turned off even if supported
  27201. * @see http://doc.babylonjs.com/features/webgl2
  27202. */
  27203. disableWebGL2Support?: boolean;
  27204. /**
  27205. * Defines if webaudio should be initialized as well
  27206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27207. */
  27208. audioEngine?: boolean;
  27209. /**
  27210. * Defines if animations should run using a deterministic lock step
  27211. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27212. */
  27213. deterministicLockstep?: boolean;
  27214. /** Defines the maximum steps to use with deterministic lock step mode */
  27215. lockstepMaxSteps?: number;
  27216. /**
  27217. * Defines that engine should ignore context lost events
  27218. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27219. */
  27220. doNotHandleContextLost?: boolean;
  27221. /**
  27222. * Defines that engine should ignore modifying touch action attribute and style
  27223. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27224. */
  27225. doNotHandleTouchAction?: boolean;
  27226. /**
  27227. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27228. */
  27229. useHighPrecisionFloats?: boolean;
  27230. }
  27231. /**
  27232. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27233. */
  27234. export class Engine {
  27235. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27236. static ExceptionList: ({
  27237. key: string;
  27238. capture: string;
  27239. captureConstraint: number;
  27240. targets: string[];
  27241. } | {
  27242. key: string;
  27243. capture: null;
  27244. captureConstraint: null;
  27245. targets: string[];
  27246. })[];
  27247. /** Gets the list of created engines */
  27248. static readonly Instances: Engine[];
  27249. /**
  27250. * Gets the latest created engine
  27251. */
  27252. static readonly LastCreatedEngine: Nullable<Engine>;
  27253. /**
  27254. * Gets the latest created scene
  27255. */
  27256. static readonly LastCreatedScene: Nullable<Scene>;
  27257. /**
  27258. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27259. * @param flag defines which part of the materials must be marked as dirty
  27260. * @param predicate defines a predicate used to filter which materials should be affected
  27261. */
  27262. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27263. /**
  27264. * Hidden
  27265. */
  27266. static _TextureLoaders: IInternalTextureLoader[];
  27267. /** Defines that alpha blending is disabled */
  27268. static readonly ALPHA_DISABLE: number;
  27269. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27270. static readonly ALPHA_ADD: number;
  27271. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27272. static readonly ALPHA_COMBINE: number;
  27273. /** Defines that alpha blending to DEST - SRC * DEST */
  27274. static readonly ALPHA_SUBTRACT: number;
  27275. /** Defines that alpha blending to SRC * DEST */
  27276. static readonly ALPHA_MULTIPLY: number;
  27277. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27278. static readonly ALPHA_MAXIMIZED: number;
  27279. /** Defines that alpha blending to SRC + DEST */
  27280. static readonly ALPHA_ONEONE: number;
  27281. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27282. static readonly ALPHA_PREMULTIPLIED: number;
  27283. /**
  27284. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27285. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27286. */
  27287. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27288. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27289. static readonly ALPHA_INTERPOLATE: number;
  27290. /**
  27291. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27292. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27293. */
  27294. static readonly ALPHA_SCREENMODE: number;
  27295. /** Defines that the ressource is not delayed*/
  27296. static readonly DELAYLOADSTATE_NONE: number;
  27297. /** Defines that the ressource was successfully delay loaded */
  27298. static readonly DELAYLOADSTATE_LOADED: number;
  27299. /** Defines that the ressource is currently delay loading */
  27300. static readonly DELAYLOADSTATE_LOADING: number;
  27301. /** Defines that the ressource is delayed and has not started loading */
  27302. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27303. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27304. static readonly NEVER: number;
  27305. /** 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 */
  27306. static readonly ALWAYS: number;
  27307. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27308. static readonly LESS: number;
  27309. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27310. static readonly EQUAL: number;
  27311. /** 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 */
  27312. static readonly LEQUAL: number;
  27313. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27314. static readonly GREATER: number;
  27315. /** 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 */
  27316. static readonly GEQUAL: number;
  27317. /** 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 */
  27318. static readonly NOTEQUAL: number;
  27319. /** Passed to stencilOperation to specify that stencil value must be kept */
  27320. static readonly KEEP: number;
  27321. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27322. static readonly REPLACE: number;
  27323. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27324. static readonly INCR: number;
  27325. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27326. static readonly DECR: number;
  27327. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27328. static readonly INVERT: number;
  27329. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27330. static readonly INCR_WRAP: number;
  27331. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27332. static readonly DECR_WRAP: number;
  27333. /** Texture is not repeating outside of 0..1 UVs */
  27334. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27335. /** Texture is repeating outside of 0..1 UVs */
  27336. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27337. /** Texture is repeating and mirrored */
  27338. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27339. /** ALPHA */
  27340. static readonly TEXTUREFORMAT_ALPHA: number;
  27341. /** LUMINANCE */
  27342. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27343. /** LUMINANCE_ALPHA */
  27344. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27345. /** RGB */
  27346. static readonly TEXTUREFORMAT_RGB: number;
  27347. /** RGBA */
  27348. static readonly TEXTUREFORMAT_RGBA: number;
  27349. /** RED */
  27350. static readonly TEXTUREFORMAT_RED: number;
  27351. /** RED (2nd reference) */
  27352. static readonly TEXTUREFORMAT_R: number;
  27353. /** RG */
  27354. static readonly TEXTUREFORMAT_RG: number;
  27355. /** RED_INTEGER */
  27356. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27357. /** RED_INTEGER (2nd reference) */
  27358. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27359. /** RG_INTEGER */
  27360. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27361. /** RGB_INTEGER */
  27362. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27363. /** RGBA_INTEGER */
  27364. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27365. /** UNSIGNED_BYTE */
  27366. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27367. /** UNSIGNED_BYTE (2nd reference) */
  27368. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27369. /** FLOAT */
  27370. static readonly TEXTURETYPE_FLOAT: number;
  27371. /** HALF_FLOAT */
  27372. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27373. /** BYTE */
  27374. static readonly TEXTURETYPE_BYTE: number;
  27375. /** SHORT */
  27376. static readonly TEXTURETYPE_SHORT: number;
  27377. /** UNSIGNED_SHORT */
  27378. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27379. /** INT */
  27380. static readonly TEXTURETYPE_INT: number;
  27381. /** UNSIGNED_INT */
  27382. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27383. /** UNSIGNED_SHORT_4_4_4_4 */
  27384. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27385. /** UNSIGNED_SHORT_5_5_5_1 */
  27386. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27387. /** UNSIGNED_SHORT_5_6_5 */
  27388. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27389. /** UNSIGNED_INT_2_10_10_10_REV */
  27390. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27391. /** UNSIGNED_INT_24_8 */
  27392. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27393. /** UNSIGNED_INT_10F_11F_11F_REV */
  27394. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27395. /** UNSIGNED_INT_5_9_9_9_REV */
  27396. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27397. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27398. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27399. /** nearest is mag = nearest and min = nearest and mip = linear */
  27400. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27401. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27402. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27403. /** Trilinear is mag = linear and min = linear and mip = linear */
  27404. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27405. /** nearest is mag = nearest and min = nearest and mip = linear */
  27406. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27407. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27408. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27409. /** Trilinear is mag = linear and min = linear and mip = linear */
  27410. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27411. /** mag = nearest and min = nearest and mip = nearest */
  27412. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27413. /** mag = nearest and min = linear and mip = nearest */
  27414. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27415. /** mag = nearest and min = linear and mip = linear */
  27416. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27417. /** mag = nearest and min = linear and mip = none */
  27418. static readonly TEXTURE_NEAREST_LINEAR: number;
  27419. /** mag = nearest and min = nearest and mip = none */
  27420. static readonly TEXTURE_NEAREST_NEAREST: number;
  27421. /** mag = linear and min = nearest and mip = nearest */
  27422. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27423. /** mag = linear and min = nearest and mip = linear */
  27424. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27425. /** mag = linear and min = linear and mip = none */
  27426. static readonly TEXTURE_LINEAR_LINEAR: number;
  27427. /** mag = linear and min = nearest and mip = none */
  27428. static readonly TEXTURE_LINEAR_NEAREST: number;
  27429. /** Explicit coordinates mode */
  27430. static readonly TEXTURE_EXPLICIT_MODE: number;
  27431. /** Spherical coordinates mode */
  27432. static readonly TEXTURE_SPHERICAL_MODE: number;
  27433. /** Planar coordinates mode */
  27434. static readonly TEXTURE_PLANAR_MODE: number;
  27435. /** Cubic coordinates mode */
  27436. static readonly TEXTURE_CUBIC_MODE: number;
  27437. /** Projection coordinates mode */
  27438. static readonly TEXTURE_PROJECTION_MODE: number;
  27439. /** Skybox coordinates mode */
  27440. static readonly TEXTURE_SKYBOX_MODE: number;
  27441. /** Inverse Cubic coordinates mode */
  27442. static readonly TEXTURE_INVCUBIC_MODE: number;
  27443. /** Equirectangular coordinates mode */
  27444. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27445. /** Equirectangular Fixed coordinates mode */
  27446. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27447. /** Equirectangular Fixed Mirrored coordinates mode */
  27448. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27449. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27450. static readonly SCALEMODE_FLOOR: number;
  27451. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27452. static readonly SCALEMODE_NEAREST: number;
  27453. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27454. static readonly SCALEMODE_CEILING: number;
  27455. /**
  27456. * Returns the current npm package of the sdk
  27457. */
  27458. static readonly NpmPackage: string;
  27459. /**
  27460. * Returns the current version of the framework
  27461. */
  27462. static readonly Version: string;
  27463. /**
  27464. * Returns a string describing the current engine
  27465. */
  27466. readonly description: string;
  27467. /**
  27468. * Gets or sets the epsilon value used by collision engine
  27469. */
  27470. static CollisionsEpsilon: number;
  27471. /**
  27472. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27473. */
  27474. static ShadersRepository: string;
  27475. /**
  27476. * Method called to create the default loading screen.
  27477. * This can be overriden in your own app.
  27478. * @param canvas The rendering canvas element
  27479. * @returns The loading screen
  27480. */
  27481. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27482. /**
  27483. * Method called to create the default rescale post process on each engine.
  27484. */
  27485. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27486. /**
  27487. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27488. */
  27489. forcePOTTextures: boolean;
  27490. /**
  27491. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27492. */
  27493. isFullscreen: boolean;
  27494. /**
  27495. * Gets a boolean indicating if the pointer is currently locked
  27496. */
  27497. isPointerLock: boolean;
  27498. /**
  27499. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27500. */
  27501. cullBackFaces: boolean;
  27502. /**
  27503. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27504. */
  27505. renderEvenInBackground: boolean;
  27506. /**
  27507. * Gets or sets a boolean indicating that cache can be kept between frames
  27508. */
  27509. preventCacheWipeBetweenFrames: boolean;
  27510. /**
  27511. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27512. **/
  27513. enableOfflineSupport: boolean;
  27514. /**
  27515. * 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)
  27516. **/
  27517. disableManifestCheck: boolean;
  27518. /**
  27519. * Gets the list of created scenes
  27520. */
  27521. scenes: Scene[];
  27522. /**
  27523. * Event raised when a new scene is created
  27524. */
  27525. onNewSceneAddedObservable: Observable<Scene>;
  27526. /**
  27527. * Gets the list of created postprocesses
  27528. */
  27529. postProcesses: PostProcess[];
  27530. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27531. validateShaderPrograms: boolean;
  27532. /**
  27533. * Observable event triggered each time the rendering canvas is resized
  27534. */
  27535. onResizeObservable: Observable<Engine>;
  27536. /**
  27537. * Observable event triggered each time the canvas loses focus
  27538. */
  27539. onCanvasBlurObservable: Observable<Engine>;
  27540. /**
  27541. * Observable event triggered each time the canvas gains focus
  27542. */
  27543. onCanvasFocusObservable: Observable<Engine>;
  27544. /**
  27545. * Observable event triggered each time the canvas receives pointerout event
  27546. */
  27547. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27548. /**
  27549. * Observable event triggered before each texture is initialized
  27550. */
  27551. onBeforeTextureInitObservable: Observable<Texture>;
  27552. /**
  27553. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27554. */
  27555. disableUniformBuffers: boolean;
  27556. /** @hidden */
  27557. _uniformBuffers: UniformBuffer[];
  27558. /**
  27559. * Gets a boolean indicating that the engine supports uniform buffers
  27560. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27561. */
  27562. readonly supportsUniformBuffers: boolean;
  27563. /**
  27564. * Observable raised when the engine begins a new frame
  27565. */
  27566. onBeginFrameObservable: Observable<Engine>;
  27567. /**
  27568. * If set, will be used to request the next animation frame for the render loop
  27569. */
  27570. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27571. /**
  27572. * Observable raised when the engine ends the current frame
  27573. */
  27574. onEndFrameObservable: Observable<Engine>;
  27575. /**
  27576. * Observable raised when the engine is about to compile a shader
  27577. */
  27578. onBeforeShaderCompilationObservable: Observable<Engine>;
  27579. /**
  27580. * Observable raised when the engine has jsut compiled a shader
  27581. */
  27582. onAfterShaderCompilationObservable: Observable<Engine>;
  27583. /** @hidden */
  27584. _gl: WebGLRenderingContext;
  27585. private _renderingCanvas;
  27586. private _windowIsBackground;
  27587. private _webGLVersion;
  27588. protected _highPrecisionShadersAllowed: boolean;
  27589. /** @hidden */
  27590. readonly _shouldUseHighPrecisionShader: boolean;
  27591. /**
  27592. * Gets a boolean indicating that only power of 2 textures are supported
  27593. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27594. */
  27595. readonly needPOTTextures: boolean;
  27596. /** @hidden */
  27597. _badOS: boolean;
  27598. /** @hidden */
  27599. _badDesktopOS: boolean;
  27600. /**
  27601. * Gets the audio engine
  27602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27603. * @ignorenaming
  27604. */
  27605. static audioEngine: IAudioEngine;
  27606. /**
  27607. * Default AudioEngine factory responsible of creating the Audio Engine.
  27608. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27609. */
  27610. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27611. /**
  27612. * Default offline support factory responsible of creating a tool used to store data locally.
  27613. * By default, this will create a Database object if the workload has been embedded.
  27614. */
  27615. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27616. private _onFocus;
  27617. private _onBlur;
  27618. private _onCanvasPointerOut;
  27619. private _onCanvasBlur;
  27620. private _onCanvasFocus;
  27621. private _onFullscreenChange;
  27622. private _onPointerLockChange;
  27623. private _hardwareScalingLevel;
  27624. /** @hidden */
  27625. _caps: EngineCapabilities;
  27626. private _pointerLockRequested;
  27627. private _isStencilEnable;
  27628. private _colorWrite;
  27629. private _loadingScreen;
  27630. /** @hidden */
  27631. _drawCalls: PerfCounter;
  27632. private _glVersion;
  27633. private _glRenderer;
  27634. private _glVendor;
  27635. private _videoTextureSupported;
  27636. private _renderingQueueLaunched;
  27637. private _activeRenderLoops;
  27638. private _deterministicLockstep;
  27639. private _lockstepMaxSteps;
  27640. /**
  27641. * Observable signaled when a context lost event is raised
  27642. */
  27643. onContextLostObservable: Observable<Engine>;
  27644. /**
  27645. * Observable signaled when a context restored event is raised
  27646. */
  27647. onContextRestoredObservable: Observable<Engine>;
  27648. private _onContextLost;
  27649. private _onContextRestored;
  27650. private _contextWasLost;
  27651. /** @hidden */
  27652. _doNotHandleContextLost: boolean;
  27653. /**
  27654. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27656. */
  27657. doNotHandleContextLost: boolean;
  27658. private _performanceMonitor;
  27659. private _fps;
  27660. private _deltaTime;
  27661. /**
  27662. * Turn this value on if you want to pause FPS computation when in background
  27663. */
  27664. disablePerformanceMonitorInBackground: boolean;
  27665. /**
  27666. * Gets the performance monitor attached to this engine
  27667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27668. */
  27669. readonly performanceMonitor: PerformanceMonitor;
  27670. /**
  27671. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27672. */
  27673. disableVertexArrayObjects: boolean;
  27674. /** @hidden */
  27675. protected _depthCullingState: _DepthCullingState;
  27676. /** @hidden */
  27677. protected _stencilState: _StencilState;
  27678. /** @hidden */
  27679. protected _alphaState: _AlphaState;
  27680. /** @hidden */
  27681. protected _alphaMode: number;
  27682. /** @hidden */
  27683. _internalTexturesCache: InternalTexture[];
  27684. /** @hidden */
  27685. protected _activeChannel: number;
  27686. private _currentTextureChannel;
  27687. /** @hidden */
  27688. protected _boundTexturesCache: {
  27689. [key: string]: Nullable<InternalTexture>;
  27690. };
  27691. /** @hidden */
  27692. protected _currentEffect: Nullable<Effect>;
  27693. /** @hidden */
  27694. protected _currentProgram: Nullable<WebGLProgram>;
  27695. private _compiledEffects;
  27696. private _vertexAttribArraysEnabled;
  27697. /** @hidden */
  27698. protected _cachedViewport: Nullable<Viewport>;
  27699. private _cachedVertexArrayObject;
  27700. /** @hidden */
  27701. protected _cachedVertexBuffers: any;
  27702. /** @hidden */
  27703. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27704. /** @hidden */
  27705. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27706. /** @hidden */
  27707. _currentRenderTarget: Nullable<InternalTexture>;
  27708. private _uintIndicesCurrentlySet;
  27709. private _currentBoundBuffer;
  27710. /** @hidden */
  27711. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27712. private _currentBufferPointers;
  27713. private _currentInstanceLocations;
  27714. private _currentInstanceBuffers;
  27715. private _textureUnits;
  27716. /** @hidden */
  27717. _workingCanvas: Nullable<HTMLCanvasElement>;
  27718. /** @hidden */
  27719. _workingContext: Nullable<CanvasRenderingContext2D>;
  27720. private _rescalePostProcess;
  27721. private _dummyFramebuffer;
  27722. private _externalData;
  27723. /** @hidden */
  27724. _bindedRenderFunction: any;
  27725. private _vaoRecordInProgress;
  27726. private _mustWipeVertexAttributes;
  27727. private _emptyTexture;
  27728. private _emptyCubeTexture;
  27729. private _emptyTexture3D;
  27730. /** @hidden */
  27731. _frameHandler: number;
  27732. private _nextFreeTextureSlots;
  27733. private _maxSimultaneousTextures;
  27734. private _activeRequests;
  27735. private _texturesSupported;
  27736. /** @hidden */
  27737. _textureFormatInUse: Nullable<string>;
  27738. /**
  27739. * Gets the list of texture formats supported
  27740. */
  27741. readonly texturesSupported: Array<string>;
  27742. /**
  27743. * Gets the list of texture formats in use
  27744. */
  27745. readonly textureFormatInUse: Nullable<string>;
  27746. /**
  27747. * Gets the current viewport
  27748. */
  27749. readonly currentViewport: Nullable<Viewport>;
  27750. /**
  27751. * Gets the default empty texture
  27752. */
  27753. readonly emptyTexture: InternalTexture;
  27754. /**
  27755. * Gets the default empty 3D texture
  27756. */
  27757. readonly emptyTexture3D: InternalTexture;
  27758. /**
  27759. * Gets the default empty cube texture
  27760. */
  27761. readonly emptyCubeTexture: InternalTexture;
  27762. /**
  27763. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27764. */
  27765. readonly premultipliedAlpha: boolean;
  27766. /**
  27767. * Creates a new engine
  27768. * @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
  27769. * @param antialias defines enable antialiasing (default: false)
  27770. * @param options defines further options to be sent to the getContext() function
  27771. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27772. */
  27773. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27774. /**
  27775. * Initializes a webVR display and starts listening to display change events
  27776. * The onVRDisplayChangedObservable will be notified upon these changes
  27777. * @returns The onVRDisplayChangedObservable
  27778. */
  27779. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27780. /** @hidden */
  27781. _prepareVRComponent(): void;
  27782. /** @hidden */
  27783. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27784. /** @hidden */
  27785. _submitVRFrame(): void;
  27786. /**
  27787. * Call this function to leave webVR mode
  27788. * Will do nothing if webVR is not supported or if there is no webVR device
  27789. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27790. */
  27791. disableVR(): void;
  27792. /**
  27793. * Gets a boolean indicating that the system is in VR mode and is presenting
  27794. * @returns true if VR mode is engaged
  27795. */
  27796. isVRPresenting(): boolean;
  27797. /** @hidden */
  27798. _requestVRFrame(): void;
  27799. private _disableTouchAction;
  27800. private _rebuildInternalTextures;
  27801. private _rebuildEffects;
  27802. /**
  27803. * Gets a boolean indicating if all created effects are ready
  27804. * @returns true if all effects are ready
  27805. */
  27806. areAllEffectsReady(): boolean;
  27807. private _rebuildBuffers;
  27808. private _initGLContext;
  27809. /**
  27810. * Gets version of the current webGL context
  27811. */
  27812. readonly webGLVersion: number;
  27813. /**
  27814. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27815. */
  27816. readonly isStencilEnable: boolean;
  27817. /** @hidden */
  27818. _prepareWorkingCanvas(): void;
  27819. /**
  27820. * Reset the texture cache to empty state
  27821. */
  27822. resetTextureCache(): void;
  27823. /**
  27824. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27825. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27826. * @returns true if engine is in deterministic lock step mode
  27827. */
  27828. isDeterministicLockStep(): boolean;
  27829. /**
  27830. * Gets the max steps when engine is running in deterministic lock step
  27831. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27832. * @returns the max steps
  27833. */
  27834. getLockstepMaxSteps(): number;
  27835. /**
  27836. * Gets an object containing information about the current webGL context
  27837. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27838. */
  27839. getGlInfo(): {
  27840. vendor: string;
  27841. renderer: string;
  27842. version: string;
  27843. };
  27844. /**
  27845. * Gets current aspect ratio
  27846. * @param camera defines the camera to use to get the aspect ratio
  27847. * @param useScreen defines if screen size must be used (or the current render target if any)
  27848. * @returns a number defining the aspect ratio
  27849. */
  27850. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27851. /**
  27852. * Gets current screen aspect ratio
  27853. * @returns a number defining the aspect ratio
  27854. */
  27855. getScreenAspectRatio(): number;
  27856. /**
  27857. * Gets the current render width
  27858. * @param useScreen defines if screen size must be used (or the current render target if any)
  27859. * @returns a number defining the current render width
  27860. */
  27861. getRenderWidth(useScreen?: boolean): number;
  27862. /**
  27863. * Gets the current render height
  27864. * @param useScreen defines if screen size must be used (or the current render target if any)
  27865. * @returns a number defining the current render height
  27866. */
  27867. getRenderHeight(useScreen?: boolean): number;
  27868. /**
  27869. * Gets the HTML canvas attached with the current webGL context
  27870. * @returns a HTML canvas
  27871. */
  27872. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27873. /**
  27874. * Gets the client rect of the HTML canvas attached with the current webGL context
  27875. * @returns a client rectanglee
  27876. */
  27877. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27878. /**
  27879. * Defines the hardware scaling level.
  27880. * By default the hardware scaling level is computed from the window device ratio.
  27881. * 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.
  27882. * @param level defines the level to use
  27883. */
  27884. setHardwareScalingLevel(level: number): void;
  27885. /**
  27886. * Gets the current hardware scaling level.
  27887. * By default the hardware scaling level is computed from the window device ratio.
  27888. * 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.
  27889. * @returns a number indicating the current hardware scaling level
  27890. */
  27891. getHardwareScalingLevel(): number;
  27892. /**
  27893. * Gets the list of loaded textures
  27894. * @returns an array containing all loaded textures
  27895. */
  27896. getLoadedTexturesCache(): InternalTexture[];
  27897. /**
  27898. * Gets the object containing all engine capabilities
  27899. * @returns the EngineCapabilities object
  27900. */
  27901. getCaps(): EngineCapabilities;
  27902. /**
  27903. * Gets the current depth function
  27904. * @returns a number defining the depth function
  27905. */
  27906. getDepthFunction(): Nullable<number>;
  27907. /**
  27908. * Sets the current depth function
  27909. * @param depthFunc defines the function to use
  27910. */
  27911. setDepthFunction(depthFunc: number): void;
  27912. /**
  27913. * Sets the current depth function to GREATER
  27914. */
  27915. setDepthFunctionToGreater(): void;
  27916. /**
  27917. * Sets the current depth function to GEQUAL
  27918. */
  27919. setDepthFunctionToGreaterOrEqual(): void;
  27920. /**
  27921. * Sets the current depth function to LESS
  27922. */
  27923. setDepthFunctionToLess(): void;
  27924. private _cachedStencilBuffer;
  27925. private _cachedStencilFunction;
  27926. private _cachedStencilMask;
  27927. private _cachedStencilOperationPass;
  27928. private _cachedStencilOperationFail;
  27929. private _cachedStencilOperationDepthFail;
  27930. private _cachedStencilReference;
  27931. /**
  27932. * Caches the the state of the stencil buffer
  27933. */
  27934. cacheStencilState(): void;
  27935. /**
  27936. * Restores the state of the stencil buffer
  27937. */
  27938. restoreStencilState(): void;
  27939. /**
  27940. * Sets the current depth function to LEQUAL
  27941. */
  27942. setDepthFunctionToLessOrEqual(): void;
  27943. /**
  27944. * Gets a boolean indicating if stencil buffer is enabled
  27945. * @returns the current stencil buffer state
  27946. */
  27947. getStencilBuffer(): boolean;
  27948. /**
  27949. * Enable or disable the stencil buffer
  27950. * @param enable defines if the stencil buffer must be enabled or disabled
  27951. */
  27952. setStencilBuffer(enable: boolean): void;
  27953. /**
  27954. * Gets the current stencil mask
  27955. * @returns a number defining the new stencil mask to use
  27956. */
  27957. getStencilMask(): number;
  27958. /**
  27959. * Sets the current stencil mask
  27960. * @param mask defines the new stencil mask to use
  27961. */
  27962. setStencilMask(mask: number): void;
  27963. /**
  27964. * Gets the current stencil function
  27965. * @returns a number defining the stencil function to use
  27966. */
  27967. getStencilFunction(): number;
  27968. /**
  27969. * Gets the current stencil reference value
  27970. * @returns a number defining the stencil reference value to use
  27971. */
  27972. getStencilFunctionReference(): number;
  27973. /**
  27974. * Gets the current stencil mask
  27975. * @returns a number defining the stencil mask to use
  27976. */
  27977. getStencilFunctionMask(): number;
  27978. /**
  27979. * Sets the current stencil function
  27980. * @param stencilFunc defines the new stencil function to use
  27981. */
  27982. setStencilFunction(stencilFunc: number): void;
  27983. /**
  27984. * Sets the current stencil reference
  27985. * @param reference defines the new stencil reference to use
  27986. */
  27987. setStencilFunctionReference(reference: number): void;
  27988. /**
  27989. * Sets the current stencil mask
  27990. * @param mask defines the new stencil mask to use
  27991. */
  27992. setStencilFunctionMask(mask: number): void;
  27993. /**
  27994. * Gets the current stencil operation when stencil fails
  27995. * @returns a number defining stencil operation to use when stencil fails
  27996. */
  27997. getStencilOperationFail(): number;
  27998. /**
  27999. * Gets the current stencil operation when depth fails
  28000. * @returns a number defining stencil operation to use when depth fails
  28001. */
  28002. getStencilOperationDepthFail(): number;
  28003. /**
  28004. * Gets the current stencil operation when stencil passes
  28005. * @returns a number defining stencil operation to use when stencil passes
  28006. */
  28007. getStencilOperationPass(): number;
  28008. /**
  28009. * Sets the stencil operation to use when stencil fails
  28010. * @param operation defines the stencil operation to use when stencil fails
  28011. */
  28012. setStencilOperationFail(operation: number): void;
  28013. /**
  28014. * Sets the stencil operation to use when depth fails
  28015. * @param operation defines the stencil operation to use when depth fails
  28016. */
  28017. setStencilOperationDepthFail(operation: number): void;
  28018. /**
  28019. * Sets the stencil operation to use when stencil passes
  28020. * @param operation defines the stencil operation to use when stencil passes
  28021. */
  28022. setStencilOperationPass(operation: number): void;
  28023. /**
  28024. * Sets a boolean indicating if the dithering state is enabled or disabled
  28025. * @param value defines the dithering state
  28026. */
  28027. setDitheringState(value: boolean): void;
  28028. /**
  28029. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28030. * @param value defines the rasterizer state
  28031. */
  28032. setRasterizerState(value: boolean): void;
  28033. /**
  28034. * stop executing a render loop function and remove it from the execution array
  28035. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28036. */
  28037. stopRenderLoop(renderFunction?: () => void): void;
  28038. /** @hidden */
  28039. _renderLoop(): void;
  28040. /**
  28041. * Register and execute a render loop. The engine can have more than one render function
  28042. * @param renderFunction defines the function to continuously execute
  28043. */
  28044. runRenderLoop(renderFunction: () => void): void;
  28045. /**
  28046. * Toggle full screen mode
  28047. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28048. */
  28049. switchFullscreen(requestPointerLock: boolean): void;
  28050. /**
  28051. * Enters full screen mode
  28052. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28053. */
  28054. enterFullscreen(requestPointerLock: boolean): void;
  28055. /**
  28056. * Exits full screen mode
  28057. */
  28058. exitFullscreen(): void;
  28059. /**
  28060. * Clear the current render buffer or the current render target (if any is set up)
  28061. * @param color defines the color to use
  28062. * @param backBuffer defines if the back buffer must be cleared
  28063. * @param depth defines if the depth buffer must be cleared
  28064. * @param stencil defines if the stencil buffer must be cleared
  28065. */
  28066. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28067. /**
  28068. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28069. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28070. * @param y defines the y-coordinate of the corner of the clear rectangle
  28071. * @param width defines the width of the clear rectangle
  28072. * @param height defines the height of the clear rectangle
  28073. * @param clearColor defines the clear color
  28074. */
  28075. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28076. /**
  28077. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28078. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28079. * @param y defines the y-coordinate of the corner of the clear rectangle
  28080. * @param width defines the width of the clear rectangle
  28081. * @param height defines the height of the clear rectangle
  28082. */
  28083. enableScissor(x: number, y: number, width: number, height: number): void;
  28084. /**
  28085. * Disable previously set scissor test rectangle
  28086. */
  28087. disableScissor(): void;
  28088. private _viewportCached;
  28089. /** @hidden */
  28090. _viewport(x: number, y: number, width: number, height: number): void;
  28091. /**
  28092. * Set the WebGL's viewport
  28093. * @param viewport defines the viewport element to be used
  28094. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28095. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28096. */
  28097. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28098. /**
  28099. * Directly set the WebGL Viewport
  28100. * @param x defines the x coordinate of the viewport (in screen space)
  28101. * @param y defines the y coordinate of the viewport (in screen space)
  28102. * @param width defines the width of the viewport (in screen space)
  28103. * @param height defines the height of the viewport (in screen space)
  28104. * @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
  28105. */
  28106. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28107. /**
  28108. * Begin a new frame
  28109. */
  28110. beginFrame(): void;
  28111. /**
  28112. * Enf the current frame
  28113. */
  28114. endFrame(): void;
  28115. /**
  28116. * Resize the view according to the canvas' size
  28117. */
  28118. resize(): void;
  28119. /**
  28120. * Force a specific size of the canvas
  28121. * @param width defines the new canvas' width
  28122. * @param height defines the new canvas' height
  28123. */
  28124. setSize(width: number, height: number): void;
  28125. /**
  28126. * Binds the frame buffer to the specified texture.
  28127. * @param texture The texture to render to or null for the default canvas
  28128. * @param faceIndex The face of the texture to render to in case of cube texture
  28129. * @param requiredWidth The width of the target to render to
  28130. * @param requiredHeight The height of the target to render to
  28131. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28132. * @param depthStencilTexture The depth stencil texture to use to render
  28133. * @param lodLevel defines le lod level to bind to the frame buffer
  28134. */
  28135. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28136. /** @hidden */
  28137. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28138. /**
  28139. * Unbind the current render target texture from the webGL context
  28140. * @param texture defines the render target texture to unbind
  28141. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28142. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28143. */
  28144. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28145. /**
  28146. * Force the mipmap generation for the given render target texture
  28147. * @param texture defines the render target texture to use
  28148. */
  28149. generateMipMapsForCubemap(texture: InternalTexture): void;
  28150. /**
  28151. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28152. */
  28153. flushFramebuffer(): void;
  28154. /**
  28155. * Unbind the current render target and bind the default framebuffer
  28156. */
  28157. restoreDefaultFramebuffer(): void;
  28158. /**
  28159. * Create an uniform buffer
  28160. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28161. * @param elements defines the content of the uniform buffer
  28162. * @returns the webGL uniform buffer
  28163. */
  28164. createUniformBuffer(elements: FloatArray): DataBuffer;
  28165. /**
  28166. * Create a dynamic uniform buffer
  28167. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28168. * @param elements defines the content of the uniform buffer
  28169. * @returns the webGL uniform buffer
  28170. */
  28171. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28172. /**
  28173. * Update an existing uniform buffer
  28174. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28175. * @param uniformBuffer defines the target uniform buffer
  28176. * @param elements defines the content to update
  28177. * @param offset defines the offset in the uniform buffer where update should start
  28178. * @param count defines the size of the data to update
  28179. */
  28180. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28181. private _resetVertexBufferBinding;
  28182. /**
  28183. * Creates a vertex buffer
  28184. * @param data the data for the vertex buffer
  28185. * @returns the new WebGL static buffer
  28186. */
  28187. createVertexBuffer(data: DataArray): DataBuffer;
  28188. /**
  28189. * Creates a dynamic vertex buffer
  28190. * @param data the data for the dynamic vertex buffer
  28191. * @returns the new WebGL dynamic buffer
  28192. */
  28193. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28194. /**
  28195. * Update a dynamic index buffer
  28196. * @param indexBuffer defines the target index buffer
  28197. * @param indices defines the data to update
  28198. * @param offset defines the offset in the target index buffer where update should start
  28199. */
  28200. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28201. /**
  28202. * Updates a dynamic vertex buffer.
  28203. * @param vertexBuffer the vertex buffer to update
  28204. * @param data the data used to update the vertex buffer
  28205. * @param byteOffset the byte offset of the data
  28206. * @param byteLength the byte length of the data
  28207. */
  28208. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28209. private _resetIndexBufferBinding;
  28210. /**
  28211. * Creates a new index buffer
  28212. * @param indices defines the content of the index buffer
  28213. * @param updatable defines if the index buffer must be updatable
  28214. * @returns a new webGL buffer
  28215. */
  28216. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28217. /**
  28218. * Bind a webGL buffer to the webGL context
  28219. * @param buffer defines the buffer to bind
  28220. */
  28221. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28222. /**
  28223. * Bind an uniform buffer to the current webGL context
  28224. * @param buffer defines the buffer to bind
  28225. */
  28226. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28227. /**
  28228. * Bind a buffer to the current webGL context at a given location
  28229. * @param buffer defines the buffer to bind
  28230. * @param location defines the index where to bind the buffer
  28231. */
  28232. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28233. /**
  28234. * Bind a specific block at a given index in a specific shader program
  28235. * @param pipelineContext defines the pipeline context to use
  28236. * @param blockName defines the block name
  28237. * @param index defines the index where to bind the block
  28238. */
  28239. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28240. private bindIndexBuffer;
  28241. private bindBuffer;
  28242. /**
  28243. * update the bound buffer with the given data
  28244. * @param data defines the data to update
  28245. */
  28246. updateArrayBuffer(data: Float32Array): void;
  28247. private _vertexAttribPointer;
  28248. private _bindIndexBufferWithCache;
  28249. private _bindVertexBuffersAttributes;
  28250. /**
  28251. * Records a vertex array object
  28252. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28253. * @param vertexBuffers defines the list of vertex buffers to store
  28254. * @param indexBuffer defines the index buffer to store
  28255. * @param effect defines the effect to store
  28256. * @returns the new vertex array object
  28257. */
  28258. recordVertexArrayObject(vertexBuffers: {
  28259. [key: string]: VertexBuffer;
  28260. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28261. /**
  28262. * Bind a specific vertex array object
  28263. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28264. * @param vertexArrayObject defines the vertex array object to bind
  28265. * @param indexBuffer defines the index buffer to bind
  28266. */
  28267. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28268. /**
  28269. * Bind webGl buffers directly to the webGL context
  28270. * @param vertexBuffer defines the vertex buffer to bind
  28271. * @param indexBuffer defines the index buffer to bind
  28272. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28273. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28274. * @param effect defines the effect associated with the vertex buffer
  28275. */
  28276. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28277. private _unbindVertexArrayObject;
  28278. /**
  28279. * Bind a list of vertex buffers to the webGL context
  28280. * @param vertexBuffers defines the list of vertex buffers to bind
  28281. * @param indexBuffer defines the index buffer to bind
  28282. * @param effect defines the effect associated with the vertex buffers
  28283. */
  28284. bindBuffers(vertexBuffers: {
  28285. [key: string]: Nullable<VertexBuffer>;
  28286. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28287. /**
  28288. * Unbind all instance attributes
  28289. */
  28290. unbindInstanceAttributes(): void;
  28291. /**
  28292. * Release and free the memory of a vertex array object
  28293. * @param vao defines the vertex array object to delete
  28294. */
  28295. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28296. /** @hidden */
  28297. _releaseBuffer(buffer: DataBuffer): boolean;
  28298. /**
  28299. * Creates a webGL buffer to use with instanciation
  28300. * @param capacity defines the size of the buffer
  28301. * @returns the webGL buffer
  28302. */
  28303. createInstancesBuffer(capacity: number): DataBuffer;
  28304. /**
  28305. * Delete a webGL buffer used with instanciation
  28306. * @param buffer defines the webGL buffer to delete
  28307. */
  28308. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28309. /**
  28310. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28311. * @param instancesBuffer defines the webGL buffer to update and bind
  28312. * @param data defines the data to store in the buffer
  28313. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28314. */
  28315. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28316. /**
  28317. * Apply all cached states (depth, culling, stencil and alpha)
  28318. */
  28319. applyStates(): void;
  28320. /**
  28321. * Send a draw order
  28322. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28323. * @param indexStart defines the starting index
  28324. * @param indexCount defines the number of index to draw
  28325. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28326. */
  28327. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28328. /**
  28329. * Draw a list of points
  28330. * @param verticesStart defines the index of first vertex to draw
  28331. * @param verticesCount defines the count of vertices to draw
  28332. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28333. */
  28334. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28335. /**
  28336. * Draw a list of unindexed primitives
  28337. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28338. * @param verticesStart defines the index of first vertex to draw
  28339. * @param verticesCount defines the count of vertices to draw
  28340. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28341. */
  28342. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28343. /**
  28344. * Draw a list of indexed primitives
  28345. * @param fillMode defines the primitive to use
  28346. * @param indexStart defines the starting index
  28347. * @param indexCount defines the number of index to draw
  28348. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28349. */
  28350. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28351. /**
  28352. * Draw a list of unindexed primitives
  28353. * @param fillMode defines the primitive to use
  28354. * @param verticesStart defines the index of first vertex to draw
  28355. * @param verticesCount defines the count of vertices to draw
  28356. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28357. */
  28358. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28359. private _drawMode;
  28360. /** @hidden */
  28361. _releaseEffect(effect: Effect): void;
  28362. /** @hidden */
  28363. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28364. /**
  28365. * Create a new effect (used to store vertex/fragment shaders)
  28366. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28367. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28368. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28369. * @param samplers defines an array of string used to represent textures
  28370. * @param defines defines the string containing the defines to use to compile the shaders
  28371. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28372. * @param onCompiled defines a function to call when the effect creation is successful
  28373. * @param onError defines a function to call when the effect creation has failed
  28374. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28375. * @returns the new Effect
  28376. */
  28377. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28378. private _compileShader;
  28379. private _compileRawShader;
  28380. /**
  28381. * Directly creates a webGL program
  28382. * @param pipelineContext defines the pipeline context to attach to
  28383. * @param vertexCode defines the vertex shader code to use
  28384. * @param fragmentCode defines the fragment shader code to use
  28385. * @param context defines the webGL context to use (if not set, the current one will be used)
  28386. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28387. * @returns the new webGL program
  28388. */
  28389. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28390. /**
  28391. * Creates a webGL program
  28392. * @param pipelineContext defines the pipeline context to attach to
  28393. * @param vertexCode defines the vertex shader code to use
  28394. * @param fragmentCode defines the fragment shader code to use
  28395. * @param defines defines the string containing the defines to use to compile the shaders
  28396. * @param context defines the webGL context to use (if not set, the current one will be used)
  28397. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28398. * @returns the new webGL program
  28399. */
  28400. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28401. /**
  28402. * Creates a new pipeline context
  28403. * @returns the new pipeline
  28404. */
  28405. createPipelineContext(): WebGLPipelineContext;
  28406. private _createShaderProgram;
  28407. private _finalizePipelineContext;
  28408. /** @hidden */
  28409. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28410. /** @hidden */
  28411. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28412. /** @hidden */
  28413. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28414. /**
  28415. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28416. * @param pipelineContext defines the pipeline context to use
  28417. * @param uniformsNames defines the list of uniform names
  28418. * @returns an array of webGL uniform locations
  28419. */
  28420. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28421. /**
  28422. * Gets the lsit of active attributes for a given webGL program
  28423. * @param pipelineContext defines the pipeline context to use
  28424. * @param attributesNames defines the list of attribute names to get
  28425. * @returns an array of indices indicating the offset of each attribute
  28426. */
  28427. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28428. /**
  28429. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28430. * @param effect defines the effect to activate
  28431. */
  28432. enableEffect(effect: Nullable<Effect>): void;
  28433. /**
  28434. * Set the value of an uniform to an array of int32
  28435. * @param uniform defines the webGL uniform location where to store the value
  28436. * @param array defines the array of int32 to store
  28437. */
  28438. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28439. /**
  28440. * Set the value of an uniform to an array of int32 (stored as vec2)
  28441. * @param uniform defines the webGL uniform location where to store the value
  28442. * @param array defines the array of int32 to store
  28443. */
  28444. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28445. /**
  28446. * Set the value of an uniform to an array of int32 (stored as vec3)
  28447. * @param uniform defines the webGL uniform location where to store the value
  28448. * @param array defines the array of int32 to store
  28449. */
  28450. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28451. /**
  28452. * Set the value of an uniform to an array of int32 (stored as vec4)
  28453. * @param uniform defines the webGL uniform location where to store the value
  28454. * @param array defines the array of int32 to store
  28455. */
  28456. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28457. /**
  28458. * Set the value of an uniform to an array of float32
  28459. * @param uniform defines the webGL uniform location where to store the value
  28460. * @param array defines the array of float32 to store
  28461. */
  28462. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28463. /**
  28464. * Set the value of an uniform to an array of float32 (stored as vec2)
  28465. * @param uniform defines the webGL uniform location where to store the value
  28466. * @param array defines the array of float32 to store
  28467. */
  28468. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28469. /**
  28470. * Set the value of an uniform to an array of float32 (stored as vec3)
  28471. * @param uniform defines the webGL uniform location where to store the value
  28472. * @param array defines the array of float32 to store
  28473. */
  28474. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28475. /**
  28476. * Set the value of an uniform to an array of float32 (stored as vec4)
  28477. * @param uniform defines the webGL uniform location where to store the value
  28478. * @param array defines the array of float32 to store
  28479. */
  28480. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28481. /**
  28482. * Set the value of an uniform to an array of number
  28483. * @param uniform defines the webGL uniform location where to store the value
  28484. * @param array defines the array of number to store
  28485. */
  28486. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28487. /**
  28488. * Set the value of an uniform to an array of number (stored as vec2)
  28489. * @param uniform defines the webGL uniform location where to store the value
  28490. * @param array defines the array of number to store
  28491. */
  28492. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28493. /**
  28494. * Set the value of an uniform to an array of number (stored as vec3)
  28495. * @param uniform defines the webGL uniform location where to store the value
  28496. * @param array defines the array of number to store
  28497. */
  28498. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28499. /**
  28500. * Set the value of an uniform to an array of number (stored as vec4)
  28501. * @param uniform defines the webGL uniform location where to store the value
  28502. * @param array defines the array of number to store
  28503. */
  28504. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28505. /**
  28506. * Set the value of an uniform to an array of float32 (stored as matrices)
  28507. * @param uniform defines the webGL uniform location where to store the value
  28508. * @param matrices defines the array of float32 to store
  28509. */
  28510. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28511. /**
  28512. * Set the value of an uniform to a matrix
  28513. * @param uniform defines the webGL uniform location where to store the value
  28514. * @param matrix defines the matrix to store
  28515. */
  28516. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28517. /**
  28518. * Set the value of an uniform to a matrix (3x3)
  28519. * @param uniform defines the webGL uniform location where to store the value
  28520. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28521. */
  28522. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28523. /**
  28524. * Set the value of an uniform to a matrix (2x2)
  28525. * @param uniform defines the webGL uniform location where to store the value
  28526. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28527. */
  28528. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28529. /**
  28530. * Set the value of an uniform to a number (int)
  28531. * @param uniform defines the webGL uniform location where to store the value
  28532. * @param value defines the int number to store
  28533. */
  28534. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28535. /**
  28536. * Set the value of an uniform to a number (float)
  28537. * @param uniform defines the webGL uniform location where to store the value
  28538. * @param value defines the float number to store
  28539. */
  28540. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28541. /**
  28542. * Set the value of an uniform to a vec2
  28543. * @param uniform defines the webGL uniform location where to store the value
  28544. * @param x defines the 1st component of the value
  28545. * @param y defines the 2nd component of the value
  28546. */
  28547. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28548. /**
  28549. * Set the value of an uniform to a vec3
  28550. * @param uniform defines the webGL uniform location where to store the value
  28551. * @param x defines the 1st component of the value
  28552. * @param y defines the 2nd component of the value
  28553. * @param z defines the 3rd component of the value
  28554. */
  28555. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28556. /**
  28557. * Set the value of an uniform to a boolean
  28558. * @param uniform defines the webGL uniform location where to store the value
  28559. * @param bool defines the boolean to store
  28560. */
  28561. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28562. /**
  28563. * Set the value of an uniform to a vec4
  28564. * @param uniform defines the webGL uniform location where to store the value
  28565. * @param x defines the 1st component of the value
  28566. * @param y defines the 2nd component of the value
  28567. * @param z defines the 3rd component of the value
  28568. * @param w defines the 4th component of the value
  28569. */
  28570. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28571. /**
  28572. * Set the value of an uniform to a Color3
  28573. * @param uniform defines the webGL uniform location where to store the value
  28574. * @param color3 defines the color to store
  28575. */
  28576. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28577. /**
  28578. * Set the value of an uniform to a Color3 and an alpha value
  28579. * @param uniform defines the webGL uniform location where to store the value
  28580. * @param color3 defines the color to store
  28581. * @param alpha defines the alpha component to store
  28582. */
  28583. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28584. /**
  28585. * Sets a Color4 on a uniform variable
  28586. * @param uniform defines the uniform location
  28587. * @param color4 defines the value to be set
  28588. */
  28589. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28590. /**
  28591. * Set various states to the webGL context
  28592. * @param culling defines backface culling state
  28593. * @param zOffset defines the value to apply to zOffset (0 by default)
  28594. * @param force defines if states must be applied even if cache is up to date
  28595. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28596. */
  28597. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28598. /**
  28599. * Set the z offset to apply to current rendering
  28600. * @param value defines the offset to apply
  28601. */
  28602. setZOffset(value: number): void;
  28603. /**
  28604. * Gets the current value of the zOffset
  28605. * @returns the current zOffset state
  28606. */
  28607. getZOffset(): number;
  28608. /**
  28609. * Enable or disable depth buffering
  28610. * @param enable defines the state to set
  28611. */
  28612. setDepthBuffer(enable: boolean): void;
  28613. /**
  28614. * Gets a boolean indicating if depth writing is enabled
  28615. * @returns the current depth writing state
  28616. */
  28617. getDepthWrite(): boolean;
  28618. /**
  28619. * Enable or disable depth writing
  28620. * @param enable defines the state to set
  28621. */
  28622. setDepthWrite(enable: boolean): void;
  28623. /**
  28624. * Enable or disable color writing
  28625. * @param enable defines the state to set
  28626. */
  28627. setColorWrite(enable: boolean): void;
  28628. /**
  28629. * Gets a boolean indicating if color writing is enabled
  28630. * @returns the current color writing state
  28631. */
  28632. getColorWrite(): boolean;
  28633. /**
  28634. * Sets alpha constants used by some alpha blending modes
  28635. * @param r defines the red component
  28636. * @param g defines the green component
  28637. * @param b defines the blue component
  28638. * @param a defines the alpha component
  28639. */
  28640. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28641. /**
  28642. * Sets the current alpha mode
  28643. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28644. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28645. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28646. */
  28647. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28648. /**
  28649. * Gets the current alpha mode
  28650. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28651. * @returns the current alpha mode
  28652. */
  28653. getAlphaMode(): number;
  28654. /**
  28655. * Clears the list of texture accessible through engine.
  28656. * This can help preventing texture load conflict due to name collision.
  28657. */
  28658. clearInternalTexturesCache(): void;
  28659. /**
  28660. * Force the entire cache to be cleared
  28661. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28662. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28663. */
  28664. wipeCaches(bruteForce?: boolean): void;
  28665. /**
  28666. * Set the compressed texture format to use, based on the formats you have, and the formats
  28667. * supported by the hardware / browser.
  28668. *
  28669. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28670. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28671. * to API arguments needed to compressed textures. This puts the burden on the container
  28672. * generator to house the arcane code for determining these for current & future formats.
  28673. *
  28674. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28675. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28676. *
  28677. * Note: The result of this call is not taken into account when a texture is base64.
  28678. *
  28679. * @param formatsAvailable defines the list of those format families you have created
  28680. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28681. *
  28682. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28683. * @returns The extension selected.
  28684. */
  28685. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28686. /** @hidden */
  28687. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28688. min: number;
  28689. mag: number;
  28690. };
  28691. /** @hidden */
  28692. _createTexture(): WebGLTexture;
  28693. /**
  28694. * Usually called from Texture.ts.
  28695. * Passed information to create a WebGLTexture
  28696. * @param urlArg defines a value which contains one of the following:
  28697. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28698. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28699. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28701. * @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)
  28702. * @param scene needed for loading to the correct scene
  28703. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28704. * @param onLoad optional callback to be called upon successful completion
  28705. * @param onError optional callback to be called upon failure
  28706. * @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
  28707. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28708. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28709. * @param forcedExtension defines the extension to use to pick the right loader
  28710. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28711. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28712. */
  28713. 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;
  28714. private _rescaleTexture;
  28715. private _unpackFlipYCached;
  28716. /**
  28717. * In case you are sharing the context with other applications, it might
  28718. * be interested to not cache the unpack flip y state to ensure a consistent
  28719. * value would be set.
  28720. */
  28721. enableUnpackFlipYCached: boolean;
  28722. /** @hidden */
  28723. _unpackFlipY(value: boolean): void;
  28724. /** @hidden */
  28725. _getUnpackAlignement(): number;
  28726. /**
  28727. * Creates a dynamic texture
  28728. * @param width defines the width of the texture
  28729. * @param height defines the height of the texture
  28730. * @param generateMipMaps defines if the engine should generate the mip levels
  28731. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28732. * @returns the dynamic texture inside an InternalTexture
  28733. */
  28734. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28735. /**
  28736. * Update the sampling mode of a given texture
  28737. * @param samplingMode defines the required sampling mode
  28738. * @param texture defines the texture to update
  28739. */
  28740. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28741. /**
  28742. * Update the content of a dynamic texture
  28743. * @param texture defines the texture to update
  28744. * @param canvas defines the canvas containing the source
  28745. * @param invertY defines if data must be stored with Y axis inverted
  28746. * @param premulAlpha defines if alpha is stored as premultiplied
  28747. * @param format defines the format of the data
  28748. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28749. */
  28750. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28751. /**
  28752. * Update a video texture
  28753. * @param texture defines the texture to update
  28754. * @param video defines the video element to use
  28755. * @param invertY defines if data must be stored with Y axis inverted
  28756. */
  28757. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28758. /**
  28759. * Updates a depth texture Comparison Mode and Function.
  28760. * If the comparison Function is equal to 0, the mode will be set to none.
  28761. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28762. * @param texture The texture to set the comparison function for
  28763. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28764. */
  28765. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28766. /** @hidden */
  28767. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28768. width: number;
  28769. height: number;
  28770. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28771. /**
  28772. * Creates a depth stencil texture.
  28773. * This is only available in WebGL 2 or with the depth texture extension available.
  28774. * @param size The size of face edge in the texture.
  28775. * @param options The options defining the texture.
  28776. * @returns The texture
  28777. */
  28778. createDepthStencilTexture(size: number | {
  28779. width: number;
  28780. height: number;
  28781. }, options: DepthTextureCreationOptions): InternalTexture;
  28782. /**
  28783. * Creates a depth stencil texture.
  28784. * This is only available in WebGL 2 or with the depth texture extension available.
  28785. * @param size The size of face edge in the texture.
  28786. * @param options The options defining the texture.
  28787. * @returns The texture
  28788. */
  28789. private _createDepthStencilTexture;
  28790. /**
  28791. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28792. * @param renderTarget The render target to set the frame buffer for
  28793. */
  28794. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28795. /**
  28796. * Creates a new render target texture
  28797. * @param size defines the size of the texture
  28798. * @param options defines the options used to create the texture
  28799. * @returns a new render target texture stored in an InternalTexture
  28800. */
  28801. createRenderTargetTexture(size: number | {
  28802. width: number;
  28803. height: number;
  28804. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28805. /** @hidden */
  28806. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28807. /**
  28808. * Updates the sample count of a render target texture
  28809. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28810. * @param texture defines the texture to update
  28811. * @param samples defines the sample count to set
  28812. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28813. */
  28814. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28815. /** @hidden */
  28816. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28817. /** @hidden */
  28818. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28819. /** @hidden */
  28820. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28821. /** @hidden */
  28822. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28823. /**
  28824. * @hidden
  28825. */
  28826. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28827. private _prepareWebGLTextureContinuation;
  28828. private _prepareWebGLTexture;
  28829. /** @hidden */
  28830. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28831. /** @hidden */
  28832. _releaseFramebufferObjects(texture: InternalTexture): void;
  28833. /** @hidden */
  28834. _releaseTexture(texture: InternalTexture): void;
  28835. private setProgram;
  28836. private _boundUniforms;
  28837. /**
  28838. * Binds an effect to the webGL context
  28839. * @param effect defines the effect to bind
  28840. */
  28841. bindSamplers(effect: Effect): void;
  28842. private _activateCurrentTexture;
  28843. /** @hidden */
  28844. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28845. /** @hidden */
  28846. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28847. /**
  28848. * Sets a texture to the webGL context from a postprocess
  28849. * @param channel defines the channel to use
  28850. * @param postProcess defines the source postprocess
  28851. */
  28852. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28853. /**
  28854. * Binds the output of the passed in post process to the texture channel specified
  28855. * @param channel The channel the texture should be bound to
  28856. * @param postProcess The post process which's output should be bound
  28857. */
  28858. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28859. /**
  28860. * Unbind all textures from the webGL context
  28861. */
  28862. unbindAllTextures(): void;
  28863. /**
  28864. * Sets a texture to the according uniform.
  28865. * @param channel The texture channel
  28866. * @param uniform The uniform to set
  28867. * @param texture The texture to apply
  28868. */
  28869. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28870. /**
  28871. * Sets a depth stencil texture from a render target to the according uniform.
  28872. * @param channel The texture channel
  28873. * @param uniform The uniform to set
  28874. * @param texture The render target texture containing the depth stencil texture to apply
  28875. */
  28876. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28877. private _bindSamplerUniformToChannel;
  28878. private _getTextureWrapMode;
  28879. private _setTexture;
  28880. /**
  28881. * Sets an array of texture to the webGL context
  28882. * @param channel defines the channel where the texture array must be set
  28883. * @param uniform defines the associated uniform location
  28884. * @param textures defines the array of textures to bind
  28885. */
  28886. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28887. /** @hidden */
  28888. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28889. private _setTextureParameterFloat;
  28890. private _setTextureParameterInteger;
  28891. /**
  28892. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28893. * @param x defines the x coordinate of the rectangle where pixels must be read
  28894. * @param y defines the y coordinate of the rectangle where pixels must be read
  28895. * @param width defines the width of the rectangle where pixels must be read
  28896. * @param height defines the height of the rectangle where pixels must be read
  28897. * @returns a Uint8Array containing RGBA colors
  28898. */
  28899. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28900. /**
  28901. * Add an externaly attached data from its key.
  28902. * This method call will fail and return false, if such key already exists.
  28903. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28904. * @param key the unique key that identifies the data
  28905. * @param data the data object to associate to the key for this Engine instance
  28906. * @return true if no such key were already present and the data was added successfully, false otherwise
  28907. */
  28908. addExternalData<T>(key: string, data: T): boolean;
  28909. /**
  28910. * Get an externaly attached data from its key
  28911. * @param key the unique key that identifies the data
  28912. * @return the associated data, if present (can be null), or undefined if not present
  28913. */
  28914. getExternalData<T>(key: string): T;
  28915. /**
  28916. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28917. * @param key the unique key that identifies the data
  28918. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28919. * @return the associated data, can be null if the factory returned null.
  28920. */
  28921. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28922. /**
  28923. * Remove an externaly attached data from the Engine instance
  28924. * @param key the unique key that identifies the data
  28925. * @return true if the data was successfully removed, false if it doesn't exist
  28926. */
  28927. removeExternalData(key: string): boolean;
  28928. /**
  28929. * Unbind all vertex attributes from the webGL context
  28930. */
  28931. unbindAllAttributes(): void;
  28932. /**
  28933. * 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
  28934. */
  28935. releaseEffects(): void;
  28936. /**
  28937. * Dispose and release all associated resources
  28938. */
  28939. dispose(): void;
  28940. /**
  28941. * Display the loading screen
  28942. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28943. */
  28944. displayLoadingUI(): void;
  28945. /**
  28946. * Hide the loading screen
  28947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28948. */
  28949. hideLoadingUI(): void;
  28950. /**
  28951. * Gets the current loading screen object
  28952. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28953. */
  28954. /**
  28955. * Sets the current loading screen object
  28956. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28957. */
  28958. loadingScreen: ILoadingScreen;
  28959. /**
  28960. * Sets the current loading screen text
  28961. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28962. */
  28963. loadingUIText: string;
  28964. /**
  28965. * Sets the current loading screen background color
  28966. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28967. */
  28968. loadingUIBackgroundColor: string;
  28969. /**
  28970. * Attach a new callback raised when context lost event is fired
  28971. * @param callback defines the callback to call
  28972. */
  28973. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28974. /**
  28975. * Attach a new callback raised when context restored event is fired
  28976. * @param callback defines the callback to call
  28977. */
  28978. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28979. /**
  28980. * Gets the source code of the vertex shader associated with a specific webGL program
  28981. * @param program defines the program to use
  28982. * @returns a string containing the source code of the vertex shader associated with the program
  28983. */
  28984. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28985. /**
  28986. * Gets the source code of the fragment shader associated with a specific webGL program
  28987. * @param program defines the program to use
  28988. * @returns a string containing the source code of the fragment shader associated with the program
  28989. */
  28990. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28991. /**
  28992. * Get the current error code of the webGL context
  28993. * @returns the error code
  28994. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28995. */
  28996. getError(): number;
  28997. /**
  28998. * Gets the current framerate
  28999. * @returns a number representing the framerate
  29000. */
  29001. getFps(): number;
  29002. /**
  29003. * Gets the time spent between current and previous frame
  29004. * @returns a number representing the delta time in ms
  29005. */
  29006. getDeltaTime(): number;
  29007. private _measureFps;
  29008. /** @hidden */
  29009. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29010. private _canRenderToFloatFramebuffer;
  29011. private _canRenderToHalfFloatFramebuffer;
  29012. private _canRenderToFramebuffer;
  29013. /** @hidden */
  29014. _getWebGLTextureType(type: number): number;
  29015. /** @hidden */
  29016. _getInternalFormat(format: number): number;
  29017. /** @hidden */
  29018. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29019. /** @hidden */
  29020. _getRGBAMultiSampleBufferFormat(type: number): number;
  29021. /** @hidden */
  29022. _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;
  29023. /** @hidden */
  29024. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29025. /**
  29026. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29027. * @returns true if the engine can be created
  29028. * @ignorenaming
  29029. */
  29030. static isSupported(): boolean;
  29031. }
  29032. }
  29033. declare module BABYLON {
  29034. /**
  29035. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29036. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29037. */
  29038. export class EffectFallbacks {
  29039. private _defines;
  29040. private _currentRank;
  29041. private _maxRank;
  29042. private _mesh;
  29043. /**
  29044. * Removes the fallback from the bound mesh.
  29045. */
  29046. unBindMesh(): void;
  29047. /**
  29048. * Adds a fallback on the specified property.
  29049. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29050. * @param define The name of the define in the shader
  29051. */
  29052. addFallback(rank: number, define: string): void;
  29053. /**
  29054. * Sets the mesh to use CPU skinning when needing to fallback.
  29055. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29056. * @param mesh The mesh to use the fallbacks.
  29057. */
  29058. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29059. /**
  29060. * Checks to see if more fallbacks are still availible.
  29061. */
  29062. readonly isMoreFallbacks: boolean;
  29063. /**
  29064. * Removes the defines that shoould be removed when falling back.
  29065. * @param currentDefines defines the current define statements for the shader.
  29066. * @param effect defines the current effect we try to compile
  29067. * @returns The resulting defines with defines of the current rank removed.
  29068. */
  29069. reduce(currentDefines: string, effect: Effect): string;
  29070. }
  29071. /**
  29072. * Options to be used when creating an effect.
  29073. */
  29074. export class EffectCreationOptions {
  29075. /**
  29076. * Atrributes that will be used in the shader.
  29077. */
  29078. attributes: string[];
  29079. /**
  29080. * Uniform varible names that will be set in the shader.
  29081. */
  29082. uniformsNames: string[];
  29083. /**
  29084. * Uniform buffer varible names that will be set in the shader.
  29085. */
  29086. uniformBuffersNames: string[];
  29087. /**
  29088. * Sampler texture variable names that will be set in the shader.
  29089. */
  29090. samplers: string[];
  29091. /**
  29092. * Define statements that will be set in the shader.
  29093. */
  29094. defines: any;
  29095. /**
  29096. * Possible fallbacks for this effect to improve performance when needed.
  29097. */
  29098. fallbacks: Nullable<EffectFallbacks>;
  29099. /**
  29100. * Callback that will be called when the shader is compiled.
  29101. */
  29102. onCompiled: Nullable<(effect: Effect) => void>;
  29103. /**
  29104. * Callback that will be called if an error occurs during shader compilation.
  29105. */
  29106. onError: Nullable<(effect: Effect, errors: string) => void>;
  29107. /**
  29108. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29109. */
  29110. indexParameters: any;
  29111. /**
  29112. * Max number of lights that can be used in the shader.
  29113. */
  29114. maxSimultaneousLights: number;
  29115. /**
  29116. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29117. */
  29118. transformFeedbackVaryings: Nullable<string[]>;
  29119. }
  29120. /**
  29121. * Effect containing vertex and fragment shader that can be executed on an object.
  29122. */
  29123. export class Effect implements IDisposable {
  29124. /**
  29125. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29126. */
  29127. static ShadersRepository: string;
  29128. /**
  29129. * Name of the effect.
  29130. */
  29131. name: any;
  29132. /**
  29133. * String container all the define statements that should be set on the shader.
  29134. */
  29135. defines: string;
  29136. /**
  29137. * Callback that will be called when the shader is compiled.
  29138. */
  29139. onCompiled: Nullable<(effect: Effect) => void>;
  29140. /**
  29141. * Callback that will be called if an error occurs during shader compilation.
  29142. */
  29143. onError: Nullable<(effect: Effect, errors: string) => void>;
  29144. /**
  29145. * Callback that will be called when effect is bound.
  29146. */
  29147. onBind: Nullable<(effect: Effect) => void>;
  29148. /**
  29149. * Unique ID of the effect.
  29150. */
  29151. uniqueId: number;
  29152. /**
  29153. * Observable that will be called when the shader is compiled.
  29154. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29155. */
  29156. onCompileObservable: Observable<Effect>;
  29157. /**
  29158. * Observable that will be called if an error occurs during shader compilation.
  29159. */
  29160. onErrorObservable: Observable<Effect>;
  29161. /** @hidden */
  29162. _onBindObservable: Nullable<Observable<Effect>>;
  29163. /**
  29164. * Observable that will be called when effect is bound.
  29165. */
  29166. readonly onBindObservable: Observable<Effect>;
  29167. /** @hidden */
  29168. _bonesComputationForcedToCPU: boolean;
  29169. private static _uniqueIdSeed;
  29170. private _engine;
  29171. private _uniformBuffersNames;
  29172. private _uniformsNames;
  29173. private _samplerList;
  29174. private _samplers;
  29175. private _isReady;
  29176. private _compilationError;
  29177. private _attributesNames;
  29178. private _attributes;
  29179. private _uniforms;
  29180. /**
  29181. * Key for the effect.
  29182. * @hidden
  29183. */
  29184. _key: string;
  29185. private _indexParameters;
  29186. private _fallbacks;
  29187. private _vertexSourceCode;
  29188. private _fragmentSourceCode;
  29189. private _vertexSourceCodeOverride;
  29190. private _fragmentSourceCodeOverride;
  29191. private _transformFeedbackVaryings;
  29192. /**
  29193. * Compiled shader to webGL program.
  29194. * @hidden
  29195. */
  29196. _pipelineContext: Nullable<IPipelineContext>;
  29197. private _valueCache;
  29198. private static _baseCache;
  29199. /**
  29200. * Instantiates an effect.
  29201. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29202. * @param baseName Name of the effect.
  29203. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29204. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29205. * @param samplers List of sampler variables that will be passed to the shader.
  29206. * @param engine Engine to be used to render the effect
  29207. * @param defines Define statements to be added to the shader.
  29208. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29209. * @param onCompiled Callback that will be called when the shader is compiled.
  29210. * @param onError Callback that will be called if an error occurs during shader compilation.
  29211. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29212. */
  29213. 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);
  29214. /**
  29215. * Unique key for this effect
  29216. */
  29217. readonly key: string;
  29218. /**
  29219. * If the effect has been compiled and prepared.
  29220. * @returns if the effect is compiled and prepared.
  29221. */
  29222. isReady(): boolean;
  29223. /**
  29224. * The engine the effect was initialized with.
  29225. * @returns the engine.
  29226. */
  29227. getEngine(): Engine;
  29228. /**
  29229. * The pipeline context for this effect
  29230. * @returns the associated pipeline context
  29231. */
  29232. getPipelineContext(): Nullable<IPipelineContext>;
  29233. /**
  29234. * The set of names of attribute variables for the shader.
  29235. * @returns An array of attribute names.
  29236. */
  29237. getAttributesNames(): string[];
  29238. /**
  29239. * Returns the attribute at the given index.
  29240. * @param index The index of the attribute.
  29241. * @returns The location of the attribute.
  29242. */
  29243. getAttributeLocation(index: number): number;
  29244. /**
  29245. * Returns the attribute based on the name of the variable.
  29246. * @param name of the attribute to look up.
  29247. * @returns the attribute location.
  29248. */
  29249. getAttributeLocationByName(name: string): number;
  29250. /**
  29251. * The number of attributes.
  29252. * @returns the numnber of attributes.
  29253. */
  29254. getAttributesCount(): number;
  29255. /**
  29256. * Gets the index of a uniform variable.
  29257. * @param uniformName of the uniform to look up.
  29258. * @returns the index.
  29259. */
  29260. getUniformIndex(uniformName: string): number;
  29261. /**
  29262. * Returns the attribute based on the name of the variable.
  29263. * @param uniformName of the uniform to look up.
  29264. * @returns the location of the uniform.
  29265. */
  29266. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29267. /**
  29268. * Returns an array of sampler variable names
  29269. * @returns The array of sampler variable neames.
  29270. */
  29271. getSamplers(): string[];
  29272. /**
  29273. * The error from the last compilation.
  29274. * @returns the error string.
  29275. */
  29276. getCompilationError(): string;
  29277. /**
  29278. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29279. * @param func The callback to be used.
  29280. */
  29281. executeWhenCompiled(func: (effect: Effect) => void): void;
  29282. private _checkIsReady;
  29283. /** @hidden */
  29284. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29285. /** @hidden */
  29286. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29287. /** @hidden */
  29288. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29289. private _processShaderConversion;
  29290. private _processIncludes;
  29291. private _processPrecision;
  29292. /**
  29293. * Recompiles the webGL program
  29294. * @param vertexSourceCode The source code for the vertex shader.
  29295. * @param fragmentSourceCode The source code for the fragment shader.
  29296. * @param onCompiled Callback called when completed.
  29297. * @param onError Callback called on error.
  29298. * @hidden
  29299. */
  29300. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29301. /**
  29302. * Prepares the effect
  29303. * @hidden
  29304. */
  29305. _prepareEffect(): void;
  29306. /**
  29307. * Checks if the effect is supported. (Must be called after compilation)
  29308. */
  29309. readonly isSupported: boolean;
  29310. /**
  29311. * Binds a texture to the engine to be used as output of the shader.
  29312. * @param channel Name of the output variable.
  29313. * @param texture Texture to bind.
  29314. * @hidden
  29315. */
  29316. _bindTexture(channel: string, texture: InternalTexture): void;
  29317. /**
  29318. * Sets a texture on the engine to be used in the shader.
  29319. * @param channel Name of the sampler variable.
  29320. * @param texture Texture to set.
  29321. */
  29322. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29323. /**
  29324. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29325. * @param channel Name of the sampler variable.
  29326. * @param texture Texture to set.
  29327. */
  29328. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29329. /**
  29330. * Sets an array of textures on the engine to be used in the shader.
  29331. * @param channel Name of the variable.
  29332. * @param textures Textures to set.
  29333. */
  29334. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29335. /**
  29336. * 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)
  29337. * @param channel Name of the sampler variable.
  29338. * @param postProcess Post process to get the input texture from.
  29339. */
  29340. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29341. /**
  29342. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29343. * 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)
  29344. * @param channel Name of the sampler variable.
  29345. * @param postProcess Post process to get the output texture from.
  29346. */
  29347. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29348. /** @hidden */
  29349. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29350. /** @hidden */
  29351. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29352. /** @hidden */
  29353. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29354. /** @hidden */
  29355. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29356. /**
  29357. * Binds a buffer to a uniform.
  29358. * @param buffer Buffer to bind.
  29359. * @param name Name of the uniform variable to bind to.
  29360. */
  29361. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29362. /**
  29363. * Binds block to a uniform.
  29364. * @param blockName Name of the block to bind.
  29365. * @param index Index to bind.
  29366. */
  29367. bindUniformBlock(blockName: string, index: number): void;
  29368. /**
  29369. * Sets an interger value on a uniform variable.
  29370. * @param uniformName Name of the variable.
  29371. * @param value Value to be set.
  29372. * @returns this effect.
  29373. */
  29374. setInt(uniformName: string, value: number): Effect;
  29375. /**
  29376. * Sets an int array on a uniform variable.
  29377. * @param uniformName Name of the variable.
  29378. * @param array array to be set.
  29379. * @returns this effect.
  29380. */
  29381. setIntArray(uniformName: string, array: Int32Array): Effect;
  29382. /**
  29383. * 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)
  29384. * @param uniformName Name of the variable.
  29385. * @param array array to be set.
  29386. * @returns this effect.
  29387. */
  29388. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29389. /**
  29390. * 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)
  29391. * @param uniformName Name of the variable.
  29392. * @param array array to be set.
  29393. * @returns this effect.
  29394. */
  29395. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29396. /**
  29397. * 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)
  29398. * @param uniformName Name of the variable.
  29399. * @param array array to be set.
  29400. * @returns this effect.
  29401. */
  29402. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29403. /**
  29404. * Sets an float array on a uniform variable.
  29405. * @param uniformName Name of the variable.
  29406. * @param array array to be set.
  29407. * @returns this effect.
  29408. */
  29409. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29410. /**
  29411. * 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)
  29412. * @param uniformName Name of the variable.
  29413. * @param array array to be set.
  29414. * @returns this effect.
  29415. */
  29416. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29417. /**
  29418. * 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)
  29419. * @param uniformName Name of the variable.
  29420. * @param array array to be set.
  29421. * @returns this effect.
  29422. */
  29423. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29424. /**
  29425. * 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)
  29426. * @param uniformName Name of the variable.
  29427. * @param array array to be set.
  29428. * @returns this effect.
  29429. */
  29430. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29431. /**
  29432. * Sets an array on a uniform variable.
  29433. * @param uniformName Name of the variable.
  29434. * @param array array to be set.
  29435. * @returns this effect.
  29436. */
  29437. setArray(uniformName: string, array: number[]): Effect;
  29438. /**
  29439. * 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)
  29440. * @param uniformName Name of the variable.
  29441. * @param array array to be set.
  29442. * @returns this effect.
  29443. */
  29444. setArray2(uniformName: string, array: number[]): Effect;
  29445. /**
  29446. * 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)
  29447. * @param uniformName Name of the variable.
  29448. * @param array array to be set.
  29449. * @returns this effect.
  29450. */
  29451. setArray3(uniformName: string, array: number[]): Effect;
  29452. /**
  29453. * 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)
  29454. * @param uniformName Name of the variable.
  29455. * @param array array to be set.
  29456. * @returns this effect.
  29457. */
  29458. setArray4(uniformName: string, array: number[]): Effect;
  29459. /**
  29460. * Sets matrices on a uniform variable.
  29461. * @param uniformName Name of the variable.
  29462. * @param matrices matrices to be set.
  29463. * @returns this effect.
  29464. */
  29465. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29466. /**
  29467. * Sets matrix on a uniform variable.
  29468. * @param uniformName Name of the variable.
  29469. * @param matrix matrix to be set.
  29470. * @returns this effect.
  29471. */
  29472. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29473. /**
  29474. * 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)
  29475. * @param uniformName Name of the variable.
  29476. * @param matrix matrix to be set.
  29477. * @returns this effect.
  29478. */
  29479. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29480. /**
  29481. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29482. * @param uniformName Name of the variable.
  29483. * @param matrix matrix to be set.
  29484. * @returns this effect.
  29485. */
  29486. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29487. /**
  29488. * Sets a float on a uniform variable.
  29489. * @param uniformName Name of the variable.
  29490. * @param value value to be set.
  29491. * @returns this effect.
  29492. */
  29493. setFloat(uniformName: string, value: number): Effect;
  29494. /**
  29495. * Sets a boolean on a uniform variable.
  29496. * @param uniformName Name of the variable.
  29497. * @param bool value to be set.
  29498. * @returns this effect.
  29499. */
  29500. setBool(uniformName: string, bool: boolean): Effect;
  29501. /**
  29502. * Sets a Vector2 on a uniform variable.
  29503. * @param uniformName Name of the variable.
  29504. * @param vector2 vector2 to be set.
  29505. * @returns this effect.
  29506. */
  29507. setVector2(uniformName: string, vector2: Vector2): Effect;
  29508. /**
  29509. * Sets a float2 on a uniform variable.
  29510. * @param uniformName Name of the variable.
  29511. * @param x First float in float2.
  29512. * @param y Second float in float2.
  29513. * @returns this effect.
  29514. */
  29515. setFloat2(uniformName: string, x: number, y: number): Effect;
  29516. /**
  29517. * Sets a Vector3 on a uniform variable.
  29518. * @param uniformName Name of the variable.
  29519. * @param vector3 Value to be set.
  29520. * @returns this effect.
  29521. */
  29522. setVector3(uniformName: string, vector3: Vector3): Effect;
  29523. /**
  29524. * Sets a float3 on a uniform variable.
  29525. * @param uniformName Name of the variable.
  29526. * @param x First float in float3.
  29527. * @param y Second float in float3.
  29528. * @param z Third float in float3.
  29529. * @returns this effect.
  29530. */
  29531. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29532. /**
  29533. * Sets a Vector4 on a uniform variable.
  29534. * @param uniformName Name of the variable.
  29535. * @param vector4 Value to be set.
  29536. * @returns this effect.
  29537. */
  29538. setVector4(uniformName: string, vector4: Vector4): Effect;
  29539. /**
  29540. * Sets a float4 on a uniform variable.
  29541. * @param uniformName Name of the variable.
  29542. * @param x First float in float4.
  29543. * @param y Second float in float4.
  29544. * @param z Third float in float4.
  29545. * @param w Fourth float in float4.
  29546. * @returns this effect.
  29547. */
  29548. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29549. /**
  29550. * Sets a Color3 on a uniform variable.
  29551. * @param uniformName Name of the variable.
  29552. * @param color3 Value to be set.
  29553. * @returns this effect.
  29554. */
  29555. setColor3(uniformName: string, color3: Color3): Effect;
  29556. /**
  29557. * Sets a Color4 on a uniform variable.
  29558. * @param uniformName Name of the variable.
  29559. * @param color3 Value to be set.
  29560. * @param alpha Alpha value to be set.
  29561. * @returns this effect.
  29562. */
  29563. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29564. /**
  29565. * Sets a Color4 on a uniform variable
  29566. * @param uniformName defines the name of the variable
  29567. * @param color4 defines the value to be set
  29568. * @returns this effect.
  29569. */
  29570. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29571. /** Release all associated resources */
  29572. dispose(): void;
  29573. /**
  29574. * This function will add a new shader to the shader store
  29575. * @param name the name of the shader
  29576. * @param pixelShader optional pixel shader content
  29577. * @param vertexShader optional vertex shader content
  29578. */
  29579. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29580. /**
  29581. * Store of each shader (The can be looked up using effect.key)
  29582. */
  29583. static ShadersStore: {
  29584. [key: string]: string;
  29585. };
  29586. /**
  29587. * Store of each included file for a shader (The can be looked up using effect.key)
  29588. */
  29589. static IncludesShadersStore: {
  29590. [key: string]: string;
  29591. };
  29592. /**
  29593. * Resets the cache of effects.
  29594. */
  29595. static ResetCache(): void;
  29596. }
  29597. }
  29598. declare module BABYLON {
  29599. /**
  29600. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29601. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29602. * 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;
  29603. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29604. */
  29605. export class ColorCurves {
  29606. private _dirty;
  29607. private _tempColor;
  29608. private _globalCurve;
  29609. private _highlightsCurve;
  29610. private _midtonesCurve;
  29611. private _shadowsCurve;
  29612. private _positiveCurve;
  29613. private _negativeCurve;
  29614. private _globalHue;
  29615. private _globalDensity;
  29616. private _globalSaturation;
  29617. private _globalExposure;
  29618. /**
  29619. * Gets the global Hue value.
  29620. * 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).
  29621. */
  29622. /**
  29623. * Sets the global Hue value.
  29624. * 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).
  29625. */
  29626. globalHue: number;
  29627. /**
  29628. * Gets the global Density value.
  29629. * 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.
  29630. * Values less than zero provide a filter of opposite hue.
  29631. */
  29632. /**
  29633. * Sets the global Density value.
  29634. * 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.
  29635. * Values less than zero provide a filter of opposite hue.
  29636. */
  29637. globalDensity: number;
  29638. /**
  29639. * Gets the global Saturation value.
  29640. * 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.
  29641. */
  29642. /**
  29643. * Sets the global Saturation value.
  29644. * 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.
  29645. */
  29646. globalSaturation: number;
  29647. /**
  29648. * Gets the global Exposure value.
  29649. * 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.
  29650. */
  29651. /**
  29652. * Sets the global Exposure value.
  29653. * 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.
  29654. */
  29655. globalExposure: number;
  29656. private _highlightsHue;
  29657. private _highlightsDensity;
  29658. private _highlightsSaturation;
  29659. private _highlightsExposure;
  29660. /**
  29661. * Gets the highlights Hue value.
  29662. * 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).
  29663. */
  29664. /**
  29665. * Sets the highlights Hue value.
  29666. * 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).
  29667. */
  29668. highlightsHue: number;
  29669. /**
  29670. * Gets the highlights Density value.
  29671. * 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.
  29672. * Values less than zero provide a filter of opposite hue.
  29673. */
  29674. /**
  29675. * Sets the highlights Density value.
  29676. * 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.
  29677. * Values less than zero provide a filter of opposite hue.
  29678. */
  29679. highlightsDensity: number;
  29680. /**
  29681. * Gets the highlights Saturation value.
  29682. * 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.
  29683. */
  29684. /**
  29685. * Sets the highlights Saturation value.
  29686. * 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.
  29687. */
  29688. highlightsSaturation: number;
  29689. /**
  29690. * Gets the highlights Exposure value.
  29691. * 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.
  29692. */
  29693. /**
  29694. * Sets the highlights Exposure value.
  29695. * 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.
  29696. */
  29697. highlightsExposure: number;
  29698. private _midtonesHue;
  29699. private _midtonesDensity;
  29700. private _midtonesSaturation;
  29701. private _midtonesExposure;
  29702. /**
  29703. * Gets the midtones Hue value.
  29704. * 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).
  29705. */
  29706. /**
  29707. * Sets the midtones Hue value.
  29708. * 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).
  29709. */
  29710. midtonesHue: number;
  29711. /**
  29712. * Gets the midtones Density value.
  29713. * 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.
  29714. * Values less than zero provide a filter of opposite hue.
  29715. */
  29716. /**
  29717. * Sets the midtones Density value.
  29718. * 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.
  29719. * Values less than zero provide a filter of opposite hue.
  29720. */
  29721. midtonesDensity: number;
  29722. /**
  29723. * Gets the midtones Saturation value.
  29724. * 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.
  29725. */
  29726. /**
  29727. * Sets the midtones Saturation value.
  29728. * 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.
  29729. */
  29730. midtonesSaturation: number;
  29731. /**
  29732. * Gets the midtones Exposure value.
  29733. * 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.
  29734. */
  29735. /**
  29736. * Sets the midtones Exposure value.
  29737. * 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.
  29738. */
  29739. midtonesExposure: number;
  29740. private _shadowsHue;
  29741. private _shadowsDensity;
  29742. private _shadowsSaturation;
  29743. private _shadowsExposure;
  29744. /**
  29745. * Gets the shadows Hue value.
  29746. * 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).
  29747. */
  29748. /**
  29749. * Sets the shadows Hue value.
  29750. * 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).
  29751. */
  29752. shadowsHue: number;
  29753. /**
  29754. * Gets the shadows Density value.
  29755. * 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.
  29756. * Values less than zero provide a filter of opposite hue.
  29757. */
  29758. /**
  29759. * Sets the shadows Density value.
  29760. * 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.
  29761. * Values less than zero provide a filter of opposite hue.
  29762. */
  29763. shadowsDensity: number;
  29764. /**
  29765. * Gets the shadows Saturation value.
  29766. * 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.
  29767. */
  29768. /**
  29769. * Sets the shadows Saturation value.
  29770. * 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.
  29771. */
  29772. shadowsSaturation: number;
  29773. /**
  29774. * Gets the shadows Exposure value.
  29775. * 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.
  29776. */
  29777. /**
  29778. * Sets the shadows Exposure value.
  29779. * 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.
  29780. */
  29781. shadowsExposure: number;
  29782. /**
  29783. * Returns the class name
  29784. * @returns The class name
  29785. */
  29786. getClassName(): string;
  29787. /**
  29788. * Binds the color curves to the shader.
  29789. * @param colorCurves The color curve to bind
  29790. * @param effect The effect to bind to
  29791. * @param positiveUniform The positive uniform shader parameter
  29792. * @param neutralUniform The neutral uniform shader parameter
  29793. * @param negativeUniform The negative uniform shader parameter
  29794. */
  29795. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29796. /**
  29797. * Prepare the list of uniforms associated with the ColorCurves effects.
  29798. * @param uniformsList The list of uniforms used in the effect
  29799. */
  29800. static PrepareUniforms(uniformsList: string[]): void;
  29801. /**
  29802. * Returns color grading data based on a hue, density, saturation and exposure value.
  29803. * @param filterHue The hue of the color filter.
  29804. * @param filterDensity The density of the color filter.
  29805. * @param saturation The saturation.
  29806. * @param exposure The exposure.
  29807. * @param result The result data container.
  29808. */
  29809. private getColorGradingDataToRef;
  29810. /**
  29811. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29812. * @param value The input slider value in range [-100,100].
  29813. * @returns Adjusted value.
  29814. */
  29815. private static applyColorGradingSliderNonlinear;
  29816. /**
  29817. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29818. * @param hue The hue (H) input.
  29819. * @param saturation The saturation (S) input.
  29820. * @param brightness The brightness (B) input.
  29821. * @result An RGBA color represented as Vector4.
  29822. */
  29823. private static fromHSBToRef;
  29824. /**
  29825. * Returns a value clamped between min and max
  29826. * @param value The value to clamp
  29827. * @param min The minimum of value
  29828. * @param max The maximum of value
  29829. * @returns The clamped value.
  29830. */
  29831. private static clamp;
  29832. /**
  29833. * Clones the current color curve instance.
  29834. * @return The cloned curves
  29835. */
  29836. clone(): ColorCurves;
  29837. /**
  29838. * Serializes the current color curve instance to a json representation.
  29839. * @return a JSON representation
  29840. */
  29841. serialize(): any;
  29842. /**
  29843. * Parses the color curve from a json representation.
  29844. * @param source the JSON source to parse
  29845. * @return The parsed curves
  29846. */
  29847. static Parse(source: any): ColorCurves;
  29848. }
  29849. }
  29850. declare module BABYLON {
  29851. /**
  29852. * Interface to follow in your material defines to integrate easily the
  29853. * Image proccessing functions.
  29854. * @hidden
  29855. */
  29856. export interface IImageProcessingConfigurationDefines {
  29857. IMAGEPROCESSING: boolean;
  29858. VIGNETTE: boolean;
  29859. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29860. VIGNETTEBLENDMODEOPAQUE: boolean;
  29861. TONEMAPPING: boolean;
  29862. TONEMAPPING_ACES: boolean;
  29863. CONTRAST: boolean;
  29864. EXPOSURE: boolean;
  29865. COLORCURVES: boolean;
  29866. COLORGRADING: boolean;
  29867. COLORGRADING3D: boolean;
  29868. SAMPLER3DGREENDEPTH: boolean;
  29869. SAMPLER3DBGRMAP: boolean;
  29870. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29871. }
  29872. /**
  29873. * @hidden
  29874. */
  29875. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29876. IMAGEPROCESSING: boolean;
  29877. VIGNETTE: boolean;
  29878. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29879. VIGNETTEBLENDMODEOPAQUE: boolean;
  29880. TONEMAPPING: boolean;
  29881. TONEMAPPING_ACES: boolean;
  29882. CONTRAST: boolean;
  29883. COLORCURVES: boolean;
  29884. COLORGRADING: boolean;
  29885. COLORGRADING3D: boolean;
  29886. SAMPLER3DGREENDEPTH: boolean;
  29887. SAMPLER3DBGRMAP: boolean;
  29888. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29889. EXPOSURE: boolean;
  29890. constructor();
  29891. }
  29892. /**
  29893. * This groups together the common properties used for image processing either in direct forward pass
  29894. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29895. * or not.
  29896. */
  29897. export class ImageProcessingConfiguration {
  29898. /**
  29899. * Default tone mapping applied in BabylonJS.
  29900. */
  29901. static readonly TONEMAPPING_STANDARD: number;
  29902. /**
  29903. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29904. * to other engines rendering to increase portability.
  29905. */
  29906. static readonly TONEMAPPING_ACES: number;
  29907. /**
  29908. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29909. */
  29910. colorCurves: Nullable<ColorCurves>;
  29911. private _colorCurvesEnabled;
  29912. /**
  29913. * Gets wether the color curves effect is enabled.
  29914. */
  29915. /**
  29916. * Sets wether the color curves effect is enabled.
  29917. */
  29918. colorCurvesEnabled: boolean;
  29919. private _colorGradingTexture;
  29920. /**
  29921. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29922. */
  29923. /**
  29924. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29925. */
  29926. colorGradingTexture: Nullable<BaseTexture>;
  29927. private _colorGradingEnabled;
  29928. /**
  29929. * Gets wether the color grading effect is enabled.
  29930. */
  29931. /**
  29932. * Sets wether the color grading effect is enabled.
  29933. */
  29934. colorGradingEnabled: boolean;
  29935. private _colorGradingWithGreenDepth;
  29936. /**
  29937. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29938. */
  29939. /**
  29940. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29941. */
  29942. colorGradingWithGreenDepth: boolean;
  29943. private _colorGradingBGR;
  29944. /**
  29945. * Gets wether the color grading texture contains BGR values.
  29946. */
  29947. /**
  29948. * Sets wether the color grading texture contains BGR values.
  29949. */
  29950. colorGradingBGR: boolean;
  29951. /** @hidden */
  29952. _exposure: number;
  29953. /**
  29954. * Gets the Exposure used in the effect.
  29955. */
  29956. /**
  29957. * Sets the Exposure used in the effect.
  29958. */
  29959. exposure: number;
  29960. private _toneMappingEnabled;
  29961. /**
  29962. * Gets wether the tone mapping effect is enabled.
  29963. */
  29964. /**
  29965. * Sets wether the tone mapping effect is enabled.
  29966. */
  29967. toneMappingEnabled: boolean;
  29968. private _toneMappingType;
  29969. /**
  29970. * Gets the type of tone mapping effect.
  29971. */
  29972. /**
  29973. * Sets the type of tone mapping effect used in BabylonJS.
  29974. */
  29975. toneMappingType: number;
  29976. protected _contrast: number;
  29977. /**
  29978. * Gets the contrast used in the effect.
  29979. */
  29980. /**
  29981. * Sets the contrast used in the effect.
  29982. */
  29983. contrast: number;
  29984. /**
  29985. * Vignette stretch size.
  29986. */
  29987. vignetteStretch: number;
  29988. /**
  29989. * Vignette centre X Offset.
  29990. */
  29991. vignetteCentreX: number;
  29992. /**
  29993. * Vignette centre Y Offset.
  29994. */
  29995. vignetteCentreY: number;
  29996. /**
  29997. * Vignette weight or intensity of the vignette effect.
  29998. */
  29999. vignetteWeight: number;
  30000. /**
  30001. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30002. * if vignetteEnabled is set to true.
  30003. */
  30004. vignetteColor: Color4;
  30005. /**
  30006. * Camera field of view used by the Vignette effect.
  30007. */
  30008. vignetteCameraFov: number;
  30009. private _vignetteBlendMode;
  30010. /**
  30011. * Gets the vignette blend mode allowing different kind of effect.
  30012. */
  30013. /**
  30014. * Sets the vignette blend mode allowing different kind of effect.
  30015. */
  30016. vignetteBlendMode: number;
  30017. private _vignetteEnabled;
  30018. /**
  30019. * Gets wether the vignette effect is enabled.
  30020. */
  30021. /**
  30022. * Sets wether the vignette effect is enabled.
  30023. */
  30024. vignetteEnabled: boolean;
  30025. private _applyByPostProcess;
  30026. /**
  30027. * Gets wether the image processing is applied through a post process or not.
  30028. */
  30029. /**
  30030. * Sets wether the image processing is applied through a post process or not.
  30031. */
  30032. applyByPostProcess: boolean;
  30033. private _isEnabled;
  30034. /**
  30035. * Gets wether the image processing is enabled or not.
  30036. */
  30037. /**
  30038. * Sets wether the image processing is enabled or not.
  30039. */
  30040. isEnabled: boolean;
  30041. /**
  30042. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30043. */
  30044. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30045. /**
  30046. * Method called each time the image processing information changes requires to recompile the effect.
  30047. */
  30048. protected _updateParameters(): void;
  30049. /**
  30050. * Gets the current class name.
  30051. * @return "ImageProcessingConfiguration"
  30052. */
  30053. getClassName(): string;
  30054. /**
  30055. * Prepare the list of uniforms associated with the Image Processing effects.
  30056. * @param uniforms The list of uniforms used in the effect
  30057. * @param defines the list of defines currently in use
  30058. */
  30059. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30060. /**
  30061. * Prepare the list of samplers associated with the Image Processing effects.
  30062. * @param samplersList The list of uniforms used in the effect
  30063. * @param defines the list of defines currently in use
  30064. */
  30065. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30066. /**
  30067. * Prepare the list of defines associated to the shader.
  30068. * @param defines the list of defines to complete
  30069. * @param forPostProcess Define if we are currently in post process mode or not
  30070. */
  30071. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30072. /**
  30073. * Returns true if all the image processing information are ready.
  30074. * @returns True if ready, otherwise, false
  30075. */
  30076. isReady(): boolean;
  30077. /**
  30078. * Binds the image processing to the shader.
  30079. * @param effect The effect to bind to
  30080. * @param aspectRatio Define the current aspect ratio of the effect
  30081. */
  30082. bind(effect: Effect, aspectRatio?: number): void;
  30083. /**
  30084. * Clones the current image processing instance.
  30085. * @return The cloned image processing
  30086. */
  30087. clone(): ImageProcessingConfiguration;
  30088. /**
  30089. * Serializes the current image processing instance to a json representation.
  30090. * @return a JSON representation
  30091. */
  30092. serialize(): any;
  30093. /**
  30094. * Parses the image processing from a json representation.
  30095. * @param source the JSON source to parse
  30096. * @return The parsed image processing
  30097. */
  30098. static Parse(source: any): ImageProcessingConfiguration;
  30099. private static _VIGNETTEMODE_MULTIPLY;
  30100. private static _VIGNETTEMODE_OPAQUE;
  30101. /**
  30102. * Used to apply the vignette as a mix with the pixel color.
  30103. */
  30104. static readonly VIGNETTEMODE_MULTIPLY: number;
  30105. /**
  30106. * Used to apply the vignette as a replacement of the pixel color.
  30107. */
  30108. static readonly VIGNETTEMODE_OPAQUE: number;
  30109. }
  30110. }
  30111. declare module BABYLON {
  30112. /**
  30113. * This represents all the required information to add a fresnel effect on a material:
  30114. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30115. */
  30116. export class FresnelParameters {
  30117. private _isEnabled;
  30118. /**
  30119. * Define if the fresnel effect is enable or not.
  30120. */
  30121. isEnabled: boolean;
  30122. /**
  30123. * Define the color used on edges (grazing angle)
  30124. */
  30125. leftColor: Color3;
  30126. /**
  30127. * Define the color used on center
  30128. */
  30129. rightColor: Color3;
  30130. /**
  30131. * Define bias applied to computed fresnel term
  30132. */
  30133. bias: number;
  30134. /**
  30135. * Defined the power exponent applied to fresnel term
  30136. */
  30137. power: number;
  30138. /**
  30139. * Clones the current fresnel and its valuues
  30140. * @returns a clone fresnel configuration
  30141. */
  30142. clone(): FresnelParameters;
  30143. /**
  30144. * Serializes the current fresnel parameters to a JSON representation.
  30145. * @return the JSON serialization
  30146. */
  30147. serialize(): any;
  30148. /**
  30149. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30150. * @param parsedFresnelParameters Define the JSON representation
  30151. * @returns the parsed parameters
  30152. */
  30153. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30154. }
  30155. }
  30156. declare module BABYLON {
  30157. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30158. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30159. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30160. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30161. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30162. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30163. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30164. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30169. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30170. /**
  30171. * Decorator used to define property that can be serialized as reference to a camera
  30172. * @param sourceName defines the name of the property to decorate
  30173. */
  30174. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30175. /**
  30176. * Class used to help serialization objects
  30177. */
  30178. export class SerializationHelper {
  30179. /** hidden */
  30180. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30181. /** hidden */
  30182. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30183. /** hidden */
  30184. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30185. /** hidden */
  30186. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30187. /**
  30188. * Appends the serialized animations from the source animations
  30189. * @param source Source containing the animations
  30190. * @param destination Target to store the animations
  30191. */
  30192. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30193. /**
  30194. * Static function used to serialized a specific entity
  30195. * @param entity defines the entity to serialize
  30196. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30197. * @returns a JSON compatible object representing the serialization of the entity
  30198. */
  30199. static Serialize<T>(entity: T, serializationObject?: any): any;
  30200. /**
  30201. * Creates a new entity from a serialization data object
  30202. * @param creationFunction defines a function used to instanciated the new entity
  30203. * @param source defines the source serialization data
  30204. * @param scene defines the hosting scene
  30205. * @param rootUrl defines the root url for resources
  30206. * @returns a new entity
  30207. */
  30208. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30209. /**
  30210. * Clones an object
  30211. * @param creationFunction defines the function used to instanciate the new object
  30212. * @param source defines the source object
  30213. * @returns the cloned object
  30214. */
  30215. static Clone<T>(creationFunction: () => T, source: T): T;
  30216. /**
  30217. * Instanciates a new object based on a source one (some data will be shared between both object)
  30218. * @param creationFunction defines the function used to instanciate the new object
  30219. * @param source defines the source object
  30220. * @returns the new object
  30221. */
  30222. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30223. }
  30224. }
  30225. declare module BABYLON {
  30226. /**
  30227. * This is the base class of all the camera used in the application.
  30228. * @see http://doc.babylonjs.com/features/cameras
  30229. */
  30230. export class Camera extends Node {
  30231. /** @hidden */
  30232. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30233. /**
  30234. * This is the default projection mode used by the cameras.
  30235. * It helps recreating a feeling of perspective and better appreciate depth.
  30236. * This is the best way to simulate real life cameras.
  30237. */
  30238. static readonly PERSPECTIVE_CAMERA: number;
  30239. /**
  30240. * This helps creating camera with an orthographic mode.
  30241. * 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.
  30242. */
  30243. static readonly ORTHOGRAPHIC_CAMERA: number;
  30244. /**
  30245. * This is the default FOV mode for perspective cameras.
  30246. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30247. */
  30248. static readonly FOVMODE_VERTICAL_FIXED: number;
  30249. /**
  30250. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30251. */
  30252. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30253. /**
  30254. * This specifies ther is no need for a camera rig.
  30255. * Basically only one eye is rendered corresponding to the camera.
  30256. */
  30257. static readonly RIG_MODE_NONE: number;
  30258. /**
  30259. * Simulates a camera Rig with one blue eye and one red eye.
  30260. * This can be use with 3d blue and red glasses.
  30261. */
  30262. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30263. /**
  30264. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30265. */
  30266. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30267. /**
  30268. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30269. */
  30270. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30271. /**
  30272. * Defines that both eyes of the camera will be rendered over under each other.
  30273. */
  30274. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30275. /**
  30276. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30277. */
  30278. static readonly RIG_MODE_VR: number;
  30279. /**
  30280. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30281. */
  30282. static readonly RIG_MODE_WEBVR: number;
  30283. /**
  30284. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30285. */
  30286. static readonly RIG_MODE_CUSTOM: number;
  30287. /**
  30288. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30289. */
  30290. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30291. /**
  30292. * Define the input manager associated with the camera.
  30293. */
  30294. inputs: CameraInputsManager<Camera>;
  30295. /** @hidden */
  30296. _position: Vector3;
  30297. /**
  30298. * Define the current local position of the camera in the scene
  30299. */
  30300. position: Vector3;
  30301. /**
  30302. * The vector the camera should consider as up.
  30303. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30304. */
  30305. upVector: Vector3;
  30306. /**
  30307. * Define the current limit on the left side for an orthographic camera
  30308. * In scene unit
  30309. */
  30310. orthoLeft: Nullable<number>;
  30311. /**
  30312. * Define the current limit on the right side for an orthographic camera
  30313. * In scene unit
  30314. */
  30315. orthoRight: Nullable<number>;
  30316. /**
  30317. * Define the current limit on the bottom side for an orthographic camera
  30318. * In scene unit
  30319. */
  30320. orthoBottom: Nullable<number>;
  30321. /**
  30322. * Define the current limit on the top side for an orthographic camera
  30323. * In scene unit
  30324. */
  30325. orthoTop: Nullable<number>;
  30326. /**
  30327. * Field Of View is set in Radians. (default is 0.8)
  30328. */
  30329. fov: number;
  30330. /**
  30331. * Define the minimum distance the camera can see from.
  30332. * This is important to note that the depth buffer are not infinite and the closer it starts
  30333. * the more your scene might encounter depth fighting issue.
  30334. */
  30335. minZ: number;
  30336. /**
  30337. * Define the maximum distance the camera can see to.
  30338. * This is important to note that the depth buffer are not infinite and the further it end
  30339. * the more your scene might encounter depth fighting issue.
  30340. */
  30341. maxZ: number;
  30342. /**
  30343. * Define the default inertia of the camera.
  30344. * This helps giving a smooth feeling to the camera movement.
  30345. */
  30346. inertia: number;
  30347. /**
  30348. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30349. */
  30350. mode: number;
  30351. /**
  30352. * Define wether the camera is intermediate.
  30353. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30354. */
  30355. isIntermediate: boolean;
  30356. /**
  30357. * Define the viewport of the camera.
  30358. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30359. */
  30360. viewport: Viewport;
  30361. /**
  30362. * Restricts the camera to viewing objects with the same layerMask.
  30363. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30364. */
  30365. layerMask: number;
  30366. /**
  30367. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30368. */
  30369. fovMode: number;
  30370. /**
  30371. * Rig mode of the camera.
  30372. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30373. * This is normally controlled byt the camera themselves as internal use.
  30374. */
  30375. cameraRigMode: number;
  30376. /**
  30377. * Defines the distance between both "eyes" in case of a RIG
  30378. */
  30379. interaxialDistance: number;
  30380. /**
  30381. * Defines if stereoscopic rendering is done side by side or over under.
  30382. */
  30383. isStereoscopicSideBySide: boolean;
  30384. /**
  30385. * 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
  30386. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30387. * else in the scene.
  30388. */
  30389. customRenderTargets: RenderTargetTexture[];
  30390. /**
  30391. * When set, the camera will render to this render target instead of the default canvas
  30392. */
  30393. outputRenderTarget: Nullable<RenderTargetTexture>;
  30394. /**
  30395. * Observable triggered when the camera view matrix has changed.
  30396. */
  30397. onViewMatrixChangedObservable: Observable<Camera>;
  30398. /**
  30399. * Observable triggered when the camera Projection matrix has changed.
  30400. */
  30401. onProjectionMatrixChangedObservable: Observable<Camera>;
  30402. /**
  30403. * Observable triggered when the inputs have been processed.
  30404. */
  30405. onAfterCheckInputsObservable: Observable<Camera>;
  30406. /**
  30407. * Observable triggered when reset has been called and applied to the camera.
  30408. */
  30409. onRestoreStateObservable: Observable<Camera>;
  30410. /** @hidden */
  30411. _cameraRigParams: any;
  30412. /** @hidden */
  30413. _rigCameras: Camera[];
  30414. /** @hidden */
  30415. _rigPostProcess: Nullable<PostProcess>;
  30416. protected _webvrViewMatrix: Matrix;
  30417. /** @hidden */
  30418. _skipRendering: boolean;
  30419. /** @hidden */
  30420. _projectionMatrix: Matrix;
  30421. /** @hidden */
  30422. _postProcesses: Nullable<PostProcess>[];
  30423. /** @hidden */
  30424. _activeMeshes: SmartArray<AbstractMesh>;
  30425. protected _globalPosition: Vector3;
  30426. /** hidden */
  30427. _computedViewMatrix: Matrix;
  30428. private _doNotComputeProjectionMatrix;
  30429. private _transformMatrix;
  30430. private _frustumPlanes;
  30431. private _refreshFrustumPlanes;
  30432. private _storedFov;
  30433. private _stateStored;
  30434. /**
  30435. * Instantiates a new camera object.
  30436. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30437. * @see http://doc.babylonjs.com/features/cameras
  30438. * @param name Defines the name of the camera in the scene
  30439. * @param position Defines the position of the camera
  30440. * @param scene Defines the scene the camera belongs too
  30441. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30442. */
  30443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30444. /**
  30445. * Store current camera state (fov, position, etc..)
  30446. * @returns the camera
  30447. */
  30448. storeState(): Camera;
  30449. /**
  30450. * Restores the camera state values if it has been stored. You must call storeState() first
  30451. */
  30452. protected _restoreStateValues(): boolean;
  30453. /**
  30454. * Restored camera state. You must call storeState() first.
  30455. * @returns true if restored and false otherwise
  30456. */
  30457. restoreState(): boolean;
  30458. /**
  30459. * Gets the class name of the camera.
  30460. * @returns the class name
  30461. */
  30462. getClassName(): string;
  30463. /** @hidden */
  30464. readonly _isCamera: boolean;
  30465. /**
  30466. * Gets a string representation of the camera useful for debug purpose.
  30467. * @param fullDetails Defines that a more verboe level of logging is required
  30468. * @returns the string representation
  30469. */
  30470. toString(fullDetails?: boolean): string;
  30471. /**
  30472. * Gets the current world space position of the camera.
  30473. */
  30474. readonly globalPosition: Vector3;
  30475. /**
  30476. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30477. * @returns the active meshe list
  30478. */
  30479. getActiveMeshes(): SmartArray<AbstractMesh>;
  30480. /**
  30481. * Check wether a mesh is part of the current active mesh list of the camera
  30482. * @param mesh Defines the mesh to check
  30483. * @returns true if active, false otherwise
  30484. */
  30485. isActiveMesh(mesh: Mesh): boolean;
  30486. /**
  30487. * Is this camera ready to be used/rendered
  30488. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30489. * @return true if the camera is ready
  30490. */
  30491. isReady(completeCheck?: boolean): boolean;
  30492. /** @hidden */
  30493. _initCache(): void;
  30494. /** @hidden */
  30495. _updateCache(ignoreParentClass?: boolean): void;
  30496. /** @hidden */
  30497. _isSynchronized(): boolean;
  30498. /** @hidden */
  30499. _isSynchronizedViewMatrix(): boolean;
  30500. /** @hidden */
  30501. _isSynchronizedProjectionMatrix(): boolean;
  30502. /**
  30503. * Attach the input controls to a specific dom element to get the input from.
  30504. * @param element Defines the element the controls should be listened from
  30505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30506. */
  30507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30508. /**
  30509. * Detach the current controls from the specified dom element.
  30510. * @param element Defines the element to stop listening the inputs from
  30511. */
  30512. detachControl(element: HTMLElement): void;
  30513. /**
  30514. * Update the camera state according to the different inputs gathered during the frame.
  30515. */
  30516. update(): void;
  30517. /** @hidden */
  30518. _checkInputs(): void;
  30519. /** @hidden */
  30520. readonly rigCameras: Camera[];
  30521. /**
  30522. * Gets the post process used by the rig cameras
  30523. */
  30524. readonly rigPostProcess: Nullable<PostProcess>;
  30525. /**
  30526. * Internal, gets the first post proces.
  30527. * @returns the first post process to be run on this camera.
  30528. */
  30529. _getFirstPostProcess(): Nullable<PostProcess>;
  30530. private _cascadePostProcessesToRigCams;
  30531. /**
  30532. * Attach a post process to the camera.
  30533. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30534. * @param postProcess The post process to attach to the camera
  30535. * @param insertAt The position of the post process in case several of them are in use in the scene
  30536. * @returns the position the post process has been inserted at
  30537. */
  30538. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30539. /**
  30540. * Detach a post process to the camera.
  30541. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30542. * @param postProcess The post process to detach from the camera
  30543. */
  30544. detachPostProcess(postProcess: PostProcess): void;
  30545. /**
  30546. * Gets the current world matrix of the camera
  30547. */
  30548. getWorldMatrix(): Matrix;
  30549. /** @hidden */
  30550. _getViewMatrix(): Matrix;
  30551. /**
  30552. * Gets the current view matrix of the camera.
  30553. * @param force forces the camera to recompute the matrix without looking at the cached state
  30554. * @returns the view matrix
  30555. */
  30556. getViewMatrix(force?: boolean): Matrix;
  30557. /**
  30558. * Freeze the projection matrix.
  30559. * It will prevent the cache check of the camera projection compute and can speed up perf
  30560. * if no parameter of the camera are meant to change
  30561. * @param projection Defines manually a projection if necessary
  30562. */
  30563. freezeProjectionMatrix(projection?: Matrix): void;
  30564. /**
  30565. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30566. */
  30567. unfreezeProjectionMatrix(): void;
  30568. /**
  30569. * Gets the current projection matrix of the camera.
  30570. * @param force forces the camera to recompute the matrix without looking at the cached state
  30571. * @returns the projection matrix
  30572. */
  30573. getProjectionMatrix(force?: boolean): Matrix;
  30574. /**
  30575. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30576. * @returns a Matrix
  30577. */
  30578. getTransformationMatrix(): Matrix;
  30579. private _updateFrustumPlanes;
  30580. /**
  30581. * Checks if a cullable object (mesh...) is in the camera frustum
  30582. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30583. * @param target The object to check
  30584. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30585. * @returns true if the object is in frustum otherwise false
  30586. */
  30587. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30588. /**
  30589. * Checks if a cullable object (mesh...) is in the camera frustum
  30590. * Unlike isInFrustum this cheks the full bounding box
  30591. * @param target The object to check
  30592. * @returns true if the object is in frustum otherwise false
  30593. */
  30594. isCompletelyInFrustum(target: ICullable): boolean;
  30595. /**
  30596. * Gets a ray in the forward direction from the camera.
  30597. * @param length Defines the length of the ray to create
  30598. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30599. * @param origin Defines the start point of the ray which defaults to the camera position
  30600. * @returns the forward ray
  30601. */
  30602. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30603. /**
  30604. * Releases resources associated with this node.
  30605. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30606. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30607. */
  30608. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30609. /** @hidden */
  30610. _isLeftCamera: boolean;
  30611. /**
  30612. * Gets the left camera of a rig setup in case of Rigged Camera
  30613. */
  30614. readonly isLeftCamera: boolean;
  30615. /** @hidden */
  30616. _isRightCamera: boolean;
  30617. /**
  30618. * Gets the right camera of a rig setup in case of Rigged Camera
  30619. */
  30620. readonly isRightCamera: boolean;
  30621. /**
  30622. * Gets the left camera of a rig setup in case of Rigged Camera
  30623. */
  30624. readonly leftCamera: Nullable<FreeCamera>;
  30625. /**
  30626. * Gets the right camera of a rig setup in case of Rigged Camera
  30627. */
  30628. readonly rightCamera: Nullable<FreeCamera>;
  30629. /**
  30630. * Gets the left camera target of a rig setup in case of Rigged Camera
  30631. * @returns the target position
  30632. */
  30633. getLeftTarget(): Nullable<Vector3>;
  30634. /**
  30635. * Gets the right camera target of a rig setup in case of Rigged Camera
  30636. * @returns the target position
  30637. */
  30638. getRightTarget(): Nullable<Vector3>;
  30639. /**
  30640. * @hidden
  30641. */
  30642. setCameraRigMode(mode: number, rigParams: any): void;
  30643. /** @hidden */
  30644. static _setStereoscopicRigMode(camera: Camera): void;
  30645. /** @hidden */
  30646. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30647. /** @hidden */
  30648. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30649. /** @hidden */
  30650. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30651. /** @hidden */
  30652. _getVRProjectionMatrix(): Matrix;
  30653. protected _updateCameraRotationMatrix(): void;
  30654. protected _updateWebVRCameraRotationMatrix(): void;
  30655. /**
  30656. * This function MUST be overwritten by the different WebVR cameras available.
  30657. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30658. * @hidden
  30659. */
  30660. _getWebVRProjectionMatrix(): Matrix;
  30661. /**
  30662. * This function MUST be overwritten by the different WebVR cameras available.
  30663. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30664. * @hidden
  30665. */
  30666. _getWebVRViewMatrix(): Matrix;
  30667. /** @hidden */
  30668. setCameraRigParameter(name: string, value: any): void;
  30669. /**
  30670. * needs to be overridden by children so sub has required properties to be copied
  30671. * @hidden
  30672. */
  30673. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30674. /**
  30675. * May need to be overridden by children
  30676. * @hidden
  30677. */
  30678. _updateRigCameras(): void;
  30679. /** @hidden */
  30680. _setupInputs(): void;
  30681. /**
  30682. * Serialiaze the camera setup to a json represention
  30683. * @returns the JSON representation
  30684. */
  30685. serialize(): any;
  30686. /**
  30687. * Clones the current camera.
  30688. * @param name The cloned camera name
  30689. * @returns the cloned camera
  30690. */
  30691. clone(name: string): Camera;
  30692. /**
  30693. * Gets the direction of the camera relative to a given local axis.
  30694. * @param localAxis Defines the reference axis to provide a relative direction.
  30695. * @return the direction
  30696. */
  30697. getDirection(localAxis: Vector3): Vector3;
  30698. /**
  30699. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30700. * @param localAxis Defines the reference axis to provide a relative direction.
  30701. * @param result Defines the vector to store the result in
  30702. */
  30703. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30704. /**
  30705. * Gets a camera constructor for a given camera type
  30706. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30707. * @param name The name of the camera the result will be able to instantiate
  30708. * @param scene The scene the result will construct the camera in
  30709. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30710. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30711. * @returns a factory method to construc the camera
  30712. */
  30713. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30714. /**
  30715. * Compute the world matrix of the camera.
  30716. * @returns the camera workd matrix
  30717. */
  30718. computeWorldMatrix(): Matrix;
  30719. /**
  30720. * Parse a JSON and creates the camera from the parsed information
  30721. * @param parsedCamera The JSON to parse
  30722. * @param scene The scene to instantiate the camera in
  30723. * @returns the newly constructed camera
  30724. */
  30725. static Parse(parsedCamera: any, scene: Scene): Camera;
  30726. }
  30727. }
  30728. declare module BABYLON {
  30729. /**
  30730. * Interface for any object that can request an animation frame
  30731. */
  30732. export interface ICustomAnimationFrameRequester {
  30733. /**
  30734. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30735. */
  30736. renderFunction?: Function;
  30737. /**
  30738. * Called to request the next frame to render to
  30739. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30740. */
  30741. requestAnimationFrame: Function;
  30742. /**
  30743. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30744. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30745. */
  30746. requestID?: number;
  30747. }
  30748. /**
  30749. * Interface containing an array of animations
  30750. */
  30751. export interface IAnimatable {
  30752. /**
  30753. * Array of animations
  30754. */
  30755. animations: Nullable<Array<Animation>>;
  30756. }
  30757. /** Interface used by value gradients (color, factor, ...) */
  30758. export interface IValueGradient {
  30759. /**
  30760. * Gets or sets the gradient value (between 0 and 1)
  30761. */
  30762. gradient: number;
  30763. }
  30764. /** Class used to store color4 gradient */
  30765. export class ColorGradient implements IValueGradient {
  30766. /**
  30767. * Gets or sets the gradient value (between 0 and 1)
  30768. */
  30769. gradient: number;
  30770. /**
  30771. * Gets or sets first associated color
  30772. */
  30773. color1: Color4;
  30774. /**
  30775. * Gets or sets second associated color
  30776. */
  30777. color2?: Color4;
  30778. /**
  30779. * Will get a color picked randomly between color1 and color2.
  30780. * If color2 is undefined then color1 will be used
  30781. * @param result defines the target Color4 to store the result in
  30782. */
  30783. getColorToRef(result: Color4): void;
  30784. }
  30785. /** Class used to store color 3 gradient */
  30786. export class Color3Gradient implements IValueGradient {
  30787. /**
  30788. * Gets or sets the gradient value (between 0 and 1)
  30789. */
  30790. gradient: number;
  30791. /**
  30792. * Gets or sets the associated color
  30793. */
  30794. color: Color3;
  30795. }
  30796. /** Class used to store factor gradient */
  30797. export class FactorGradient implements IValueGradient {
  30798. /**
  30799. * Gets or sets the gradient value (between 0 and 1)
  30800. */
  30801. gradient: number;
  30802. /**
  30803. * Gets or sets first associated factor
  30804. */
  30805. factor1: number;
  30806. /**
  30807. * Gets or sets second associated factor
  30808. */
  30809. factor2?: number;
  30810. /**
  30811. * Will get a number picked randomly between factor1 and factor2.
  30812. * If factor2 is undefined then factor1 will be used
  30813. * @returns the picked number
  30814. */
  30815. getFactor(): number;
  30816. }
  30817. /**
  30818. * @ignore
  30819. * Application error to support additional information when loading a file
  30820. */
  30821. export class LoadFileError extends Error {
  30822. /** defines the optional web request */
  30823. request?: WebRequest | undefined;
  30824. private static _setPrototypeOf;
  30825. /**
  30826. * Creates a new LoadFileError
  30827. * @param message defines the message of the error
  30828. * @param request defines the optional web request
  30829. */
  30830. constructor(message: string,
  30831. /** defines the optional web request */
  30832. request?: WebRequest | undefined);
  30833. }
  30834. /**
  30835. * Class used to define a retry strategy when error happens while loading assets
  30836. */
  30837. export class RetryStrategy {
  30838. /**
  30839. * Function used to defines an exponential back off strategy
  30840. * @param maxRetries defines the maximum number of retries (3 by default)
  30841. * @param baseInterval defines the interval between retries
  30842. * @returns the strategy function to use
  30843. */
  30844. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30845. }
  30846. /**
  30847. * File request interface
  30848. */
  30849. export interface IFileRequest {
  30850. /**
  30851. * Raised when the request is complete (success or error).
  30852. */
  30853. onCompleteObservable: Observable<IFileRequest>;
  30854. /**
  30855. * Aborts the request for a file.
  30856. */
  30857. abort: () => void;
  30858. }
  30859. /**
  30860. * Class containing a set of static utilities functions
  30861. */
  30862. export class Tools {
  30863. /**
  30864. * Gets or sets the base URL to use to load assets
  30865. */
  30866. static BaseUrl: string;
  30867. /**
  30868. * Enable/Disable Custom HTTP Request Headers globally.
  30869. * default = false
  30870. * @see CustomRequestHeaders
  30871. */
  30872. static UseCustomRequestHeaders: boolean;
  30873. /**
  30874. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30875. * i.e. when loading files, where the server/service expects an Authorization header
  30876. */
  30877. static CustomRequestHeaders: {
  30878. [key: string]: string;
  30879. };
  30880. /**
  30881. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30882. */
  30883. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30884. /**
  30885. * Default behaviour for cors in the application.
  30886. * It can be a string if the expected behavior is identical in the entire app.
  30887. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30888. */
  30889. static CorsBehavior: string | ((url: string | string[]) => string);
  30890. /**
  30891. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30892. * @ignorenaming
  30893. */
  30894. static UseFallbackTexture: boolean;
  30895. /**
  30896. * Use this object to register external classes like custom textures or material
  30897. * to allow the laoders to instantiate them
  30898. */
  30899. static RegisteredExternalClasses: {
  30900. [key: string]: Object;
  30901. };
  30902. /**
  30903. * Texture content used if a texture cannot loaded
  30904. * @ignorenaming
  30905. */
  30906. static fallbackTexture: string;
  30907. /**
  30908. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30909. * @param u defines the coordinate on X axis
  30910. * @param v defines the coordinate on Y axis
  30911. * @param width defines the width of the source data
  30912. * @param height defines the height of the source data
  30913. * @param pixels defines the source byte array
  30914. * @param color defines the output color
  30915. */
  30916. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30917. /**
  30918. * Interpolates between a and b via alpha
  30919. * @param a The lower value (returned when alpha = 0)
  30920. * @param b The upper value (returned when alpha = 1)
  30921. * @param alpha The interpolation-factor
  30922. * @return The mixed value
  30923. */
  30924. static Mix(a: number, b: number, alpha: number): number;
  30925. /**
  30926. * Tries to instantiate a new object from a given class name
  30927. * @param className defines the class name to instantiate
  30928. * @returns the new object or null if the system was not able to do the instantiation
  30929. */
  30930. static Instantiate(className: string): any;
  30931. /**
  30932. * Provides a slice function that will work even on IE
  30933. * @param data defines the array to slice
  30934. * @param start defines the start of the data (optional)
  30935. * @param end defines the end of the data (optional)
  30936. * @returns the new sliced array
  30937. */
  30938. static Slice<T>(data: T, start?: number, end?: number): T;
  30939. /**
  30940. * Polyfill for setImmediate
  30941. * @param action defines the action to execute after the current execution block
  30942. */
  30943. static SetImmediate(action: () => void): void;
  30944. /**
  30945. * Function indicating if a number is an exponent of 2
  30946. * @param value defines the value to test
  30947. * @returns true if the value is an exponent of 2
  30948. */
  30949. static IsExponentOfTwo(value: number): boolean;
  30950. private static _tmpFloatArray;
  30951. /**
  30952. * Returns the nearest 32-bit single precision float representation of a Number
  30953. * @param value A Number. If the parameter is of a different type, it will get converted
  30954. * to a number or to NaN if it cannot be converted
  30955. * @returns number
  30956. */
  30957. static FloatRound(value: number): number;
  30958. /**
  30959. * Find the next highest power of two.
  30960. * @param x Number to start search from.
  30961. * @return Next highest power of two.
  30962. */
  30963. static CeilingPOT(x: number): number;
  30964. /**
  30965. * Find the next lowest power of two.
  30966. * @param x Number to start search from.
  30967. * @return Next lowest power of two.
  30968. */
  30969. static FloorPOT(x: number): number;
  30970. /**
  30971. * Find the nearest power of two.
  30972. * @param x Number to start search from.
  30973. * @return Next nearest power of two.
  30974. */
  30975. static NearestPOT(x: number): number;
  30976. /**
  30977. * Get the closest exponent of two
  30978. * @param value defines the value to approximate
  30979. * @param max defines the maximum value to return
  30980. * @param mode defines how to define the closest value
  30981. * @returns closest exponent of two of the given value
  30982. */
  30983. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30984. /**
  30985. * Extracts the filename from a path
  30986. * @param path defines the path to use
  30987. * @returns the filename
  30988. */
  30989. static GetFilename(path: string): string;
  30990. /**
  30991. * Extracts the "folder" part of a path (everything before the filename).
  30992. * @param uri The URI to extract the info from
  30993. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30994. * @returns The "folder" part of the path
  30995. */
  30996. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30997. /**
  30998. * Extracts text content from a DOM element hierarchy
  30999. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31000. */
  31001. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31002. /**
  31003. * Convert an angle in radians to degrees
  31004. * @param angle defines the angle to convert
  31005. * @returns the angle in degrees
  31006. */
  31007. static ToDegrees(angle: number): number;
  31008. /**
  31009. * Convert an angle in degrees to radians
  31010. * @param angle defines the angle to convert
  31011. * @returns the angle in radians
  31012. */
  31013. static ToRadians(angle: number): number;
  31014. /**
  31015. * Encode a buffer to a base64 string
  31016. * @param buffer defines the buffer to encode
  31017. * @returns the encoded string
  31018. */
  31019. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31020. /**
  31021. * Extracts minimum and maximum values from a list of indexed positions
  31022. * @param positions defines the positions to use
  31023. * @param indices defines the indices to the positions
  31024. * @param indexStart defines the start index
  31025. * @param indexCount defines the end index
  31026. * @param bias defines bias value to add to the result
  31027. * @return minimum and maximum values
  31028. */
  31029. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31030. minimum: Vector3;
  31031. maximum: Vector3;
  31032. };
  31033. /**
  31034. * Extracts minimum and maximum values from a list of positions
  31035. * @param positions defines the positions to use
  31036. * @param start defines the start index in the positions array
  31037. * @param count defines the number of positions to handle
  31038. * @param bias defines bias value to add to the result
  31039. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31040. * @return minimum and maximum values
  31041. */
  31042. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31043. minimum: Vector3;
  31044. maximum: Vector3;
  31045. };
  31046. /**
  31047. * Returns an array if obj is not an array
  31048. * @param obj defines the object to evaluate as an array
  31049. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31050. * @returns either obj directly if obj is an array or a new array containing obj
  31051. */
  31052. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31053. /**
  31054. * Gets the pointer prefix to use
  31055. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31056. */
  31057. static GetPointerPrefix(): string;
  31058. /**
  31059. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31060. * @param func - the function to be called
  31061. * @param requester - the object that will request the next frame. Falls back to window.
  31062. * @returns frame number
  31063. */
  31064. static QueueNewFrame(func: () => void, requester?: any): number;
  31065. /**
  31066. * Ask the browser to promote the current element to fullscreen rendering mode
  31067. * @param element defines the DOM element to promote
  31068. */
  31069. static RequestFullscreen(element: HTMLElement): void;
  31070. /**
  31071. * Asks the browser to exit fullscreen mode
  31072. */
  31073. static ExitFullscreen(): void;
  31074. /**
  31075. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31076. * @param url define the url we are trying
  31077. * @param element define the dom element where to configure the cors policy
  31078. */
  31079. static SetCorsBehavior(url: string | string[], element: {
  31080. crossOrigin: string | null;
  31081. }): void;
  31082. /**
  31083. * Removes unwanted characters from an url
  31084. * @param url defines the url to clean
  31085. * @returns the cleaned url
  31086. */
  31087. static CleanUrl(url: string): string;
  31088. /**
  31089. * Gets or sets a function used to pre-process url before using them to load assets
  31090. */
  31091. static PreprocessUrl: (url: string) => string;
  31092. /**
  31093. * Loads an image as an HTMLImageElement.
  31094. * @param input url string, ArrayBuffer, or Blob to load
  31095. * @param onLoad callback called when the image successfully loads
  31096. * @param onError callback called when the image fails to load
  31097. * @param offlineProvider offline provider for caching
  31098. * @returns the HTMLImageElement of the loaded image
  31099. */
  31100. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31101. /**
  31102. * Loads a file
  31103. * @param url url string, ArrayBuffer, or Blob to load
  31104. * @param onSuccess callback called when the file successfully loads
  31105. * @param onProgress callback called while file is loading (if the server supports this mode)
  31106. * @param offlineProvider defines the offline provider for caching
  31107. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31108. * @param onError callback called when the file fails to load
  31109. * @returns a file request object
  31110. */
  31111. 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;
  31112. /**
  31113. * Load a script (identified by an url). When the url returns, the
  31114. * content of this file is added into a new script element, attached to the DOM (body element)
  31115. * @param scriptUrl defines the url of the script to laod
  31116. * @param onSuccess defines the callback called when the script is loaded
  31117. * @param onError defines the callback to call if an error occurs
  31118. * @param scriptId defines the id of the script element
  31119. */
  31120. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31121. /**
  31122. * Load an asynchronous script (identified by an url). When the url returns, the
  31123. * content of this file is added into a new script element, attached to the DOM (body element)
  31124. * @param scriptUrl defines the url of the script to laod
  31125. * @param scriptId defines the id of the script element
  31126. * @returns a promise request object
  31127. */
  31128. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31129. /**
  31130. * Loads a file from a blob
  31131. * @param fileToLoad defines the blob to use
  31132. * @param callback defines the callback to call when data is loaded
  31133. * @param progressCallback defines the callback to call during loading process
  31134. * @returns a file request object
  31135. */
  31136. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31137. /**
  31138. * Loads a file
  31139. * @param fileToLoad defines the file to load
  31140. * @param callback defines the callback to call when data is loaded
  31141. * @param progressCallBack defines the callback to call during loading process
  31142. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31143. * @returns a file request object
  31144. */
  31145. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31146. /**
  31147. * Creates a data url from a given string content
  31148. * @param content defines the content to convert
  31149. * @returns the new data url link
  31150. */
  31151. static FileAsURL(content: string): string;
  31152. /**
  31153. * Format the given number to a specific decimal format
  31154. * @param value defines the number to format
  31155. * @param decimals defines the number of decimals to use
  31156. * @returns the formatted string
  31157. */
  31158. static Format(value: number, decimals?: number): string;
  31159. /**
  31160. * Checks if a given vector is inside a specific range
  31161. * @param v defines the vector to test
  31162. * @param min defines the minimum range
  31163. * @param max defines the maximum range
  31164. */
  31165. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31166. /**
  31167. * Tries to copy an object by duplicating every property
  31168. * @param source defines the source object
  31169. * @param destination defines the target object
  31170. * @param doNotCopyList defines a list of properties to avoid
  31171. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31172. */
  31173. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31174. /**
  31175. * Gets a boolean indicating if the given object has no own property
  31176. * @param obj defines the object to test
  31177. * @returns true if object has no own property
  31178. */
  31179. static IsEmpty(obj: any): boolean;
  31180. /**
  31181. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31182. * @param str Source string
  31183. * @param suffix Suffix to search for in the source string
  31184. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31185. */
  31186. static EndsWith(str: string, suffix: string): boolean;
  31187. /**
  31188. * Function used to register events at window level
  31189. * @param events defines the events to register
  31190. */
  31191. static RegisterTopRootEvents(events: {
  31192. name: string;
  31193. handler: Nullable<(e: FocusEvent) => any>;
  31194. }[]): void;
  31195. /**
  31196. * Function used to unregister events from window level
  31197. * @param events defines the events to unregister
  31198. */
  31199. static UnregisterTopRootEvents(events: {
  31200. name: string;
  31201. handler: Nullable<(e: FocusEvent) => any>;
  31202. }[]): void;
  31203. /**
  31204. * @ignore
  31205. */
  31206. static _ScreenshotCanvas: HTMLCanvasElement;
  31207. /**
  31208. * Dumps the current bound framebuffer
  31209. * @param width defines the rendering width
  31210. * @param height defines the rendering height
  31211. * @param engine defines the hosting engine
  31212. * @param successCallback defines the callback triggered once the data are available
  31213. * @param mimeType defines the mime type of the result
  31214. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31215. */
  31216. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31217. /**
  31218. * Converts the canvas data to blob.
  31219. * This acts as a polyfill for browsers not supporting the to blob function.
  31220. * @param canvas Defines the canvas to extract the data from
  31221. * @param successCallback Defines the callback triggered once the data are available
  31222. * @param mimeType Defines the mime type of the result
  31223. */
  31224. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31225. /**
  31226. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31227. * @param successCallback defines the callback triggered once the data are available
  31228. * @param mimeType defines the mime type of the result
  31229. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31230. */
  31231. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31232. /**
  31233. * Downloads a blob in the browser
  31234. * @param blob defines the blob to download
  31235. * @param fileName defines the name of the downloaded file
  31236. */
  31237. static Download(blob: Blob, fileName: string): void;
  31238. /**
  31239. * Captures a screenshot of the current rendering
  31240. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31241. * @param engine defines the rendering engine
  31242. * @param camera defines the source camera
  31243. * @param size This parameter can be set to a single number or to an object with the
  31244. * following (optional) properties: precision, width, height. If a single number is passed,
  31245. * it will be used for both width and height. If an object is passed, the screenshot size
  31246. * will be derived from the parameters. The precision property is a multiplier allowing
  31247. * rendering at a higher or lower resolution
  31248. * @param successCallback defines the callback receives a single parameter which contains the
  31249. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31250. * src parameter of an <img> to display it
  31251. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31252. * Check your browser for supported MIME types
  31253. */
  31254. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31255. /**
  31256. * Generates an image screenshot from the specified camera.
  31257. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31258. * @param engine The engine to use for rendering
  31259. * @param camera The camera to use for rendering
  31260. * @param size This parameter can be set to a single number or to an object with the
  31261. * following (optional) properties: precision, width, height. If a single number is passed,
  31262. * it will be used for both width and height. If an object is passed, the screenshot size
  31263. * will be derived from the parameters. The precision property is a multiplier allowing
  31264. * rendering at a higher or lower resolution
  31265. * @param successCallback The callback receives a single parameter which contains the
  31266. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31267. * src parameter of an <img> to display it
  31268. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31269. * Check your browser for supported MIME types
  31270. * @param samples Texture samples (default: 1)
  31271. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31272. * @param fileName A name for for the downloaded file.
  31273. */
  31274. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31275. /**
  31276. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31277. * Be aware Math.random() could cause collisions, but:
  31278. * "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"
  31279. * @returns a pseudo random id
  31280. */
  31281. static RandomId(): string;
  31282. /**
  31283. * Test if the given uri is a base64 string
  31284. * @param uri The uri to test
  31285. * @return True if the uri is a base64 string or false otherwise
  31286. */
  31287. static IsBase64(uri: string): boolean;
  31288. /**
  31289. * Decode the given base64 uri.
  31290. * @param uri The uri to decode
  31291. * @return The decoded base64 data.
  31292. */
  31293. static DecodeBase64(uri: string): ArrayBuffer;
  31294. /**
  31295. * Gets the absolute url.
  31296. * @param url the input url
  31297. * @return the absolute url
  31298. */
  31299. static GetAbsoluteUrl(url: string): string;
  31300. /**
  31301. * No log
  31302. */
  31303. static readonly NoneLogLevel: number;
  31304. /**
  31305. * Only message logs
  31306. */
  31307. static readonly MessageLogLevel: number;
  31308. /**
  31309. * Only warning logs
  31310. */
  31311. static readonly WarningLogLevel: number;
  31312. /**
  31313. * Only error logs
  31314. */
  31315. static readonly ErrorLogLevel: number;
  31316. /**
  31317. * All logs
  31318. */
  31319. static readonly AllLogLevel: number;
  31320. /**
  31321. * Gets a value indicating the number of loading errors
  31322. * @ignorenaming
  31323. */
  31324. static readonly errorsCount: number;
  31325. /**
  31326. * Callback called when a new log is added
  31327. */
  31328. static OnNewCacheEntry: (entry: string) => void;
  31329. /**
  31330. * Log a message to the console
  31331. * @param message defines the message to log
  31332. */
  31333. static Log(message: string): void;
  31334. /**
  31335. * Write a warning message to the console
  31336. * @param message defines the message to log
  31337. */
  31338. static Warn(message: string): void;
  31339. /**
  31340. * Write an error message to the console
  31341. * @param message defines the message to log
  31342. */
  31343. static Error(message: string): void;
  31344. /**
  31345. * Gets current log cache (list of logs)
  31346. */
  31347. static readonly LogCache: string;
  31348. /**
  31349. * Clears the log cache
  31350. */
  31351. static ClearLogCache(): void;
  31352. /**
  31353. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31354. */
  31355. static LogLevels: number;
  31356. /**
  31357. * Checks if the loaded document was accessed via `file:`-Protocol.
  31358. * @returns boolean
  31359. */
  31360. static IsFileURL(): boolean;
  31361. /**
  31362. * Checks if the window object exists
  31363. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31364. */
  31365. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31366. /**
  31367. * No performance log
  31368. */
  31369. static readonly PerformanceNoneLogLevel: number;
  31370. /**
  31371. * Use user marks to log performance
  31372. */
  31373. static readonly PerformanceUserMarkLogLevel: number;
  31374. /**
  31375. * Log performance to the console
  31376. */
  31377. static readonly PerformanceConsoleLogLevel: number;
  31378. private static _performance;
  31379. /**
  31380. * Sets the current performance log level
  31381. */
  31382. static PerformanceLogLevel: number;
  31383. private static _StartPerformanceCounterDisabled;
  31384. private static _EndPerformanceCounterDisabled;
  31385. private static _StartUserMark;
  31386. private static _EndUserMark;
  31387. private static _StartPerformanceConsole;
  31388. private static _EndPerformanceConsole;
  31389. /**
  31390. * Starts a performance counter
  31391. */
  31392. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31393. /**
  31394. * Ends a specific performance coutner
  31395. */
  31396. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31397. /**
  31398. * Gets either window.performance.now() if supported or Date.now() else
  31399. */
  31400. static readonly Now: number;
  31401. /**
  31402. * This method will return the name of the class used to create the instance of the given object.
  31403. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31404. * @param object the object to get the class name from
  31405. * @param isType defines if the object is actually a type
  31406. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31407. */
  31408. static GetClassName(object: any, isType?: boolean): string;
  31409. /**
  31410. * Gets the first element of an array satisfying a given predicate
  31411. * @param array defines the array to browse
  31412. * @param predicate defines the predicate to use
  31413. * @returns null if not found or the element
  31414. */
  31415. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31416. /**
  31417. * This method will return the name of the full name of the class, including its owning module (if any).
  31418. * 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).
  31419. * @param object the object to get the class name from
  31420. * @param isType defines if the object is actually a type
  31421. * @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.
  31422. * @ignorenaming
  31423. */
  31424. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31425. /**
  31426. * Returns a promise that resolves after the given amount of time.
  31427. * @param delay Number of milliseconds to delay
  31428. * @returns Promise that resolves after the given amount of time
  31429. */
  31430. static DelayAsync(delay: number): Promise<void>;
  31431. /**
  31432. * Gets the current gradient from an array of IValueGradient
  31433. * @param ratio defines the current ratio to get
  31434. * @param gradients defines the array of IValueGradient
  31435. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31436. */
  31437. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31438. }
  31439. /**
  31440. * This class is used to track a performance counter which is number based.
  31441. * The user has access to many properties which give statistics of different nature.
  31442. *
  31443. * The implementer can track two kinds of Performance Counter: time and count.
  31444. * 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.
  31445. * 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.
  31446. */
  31447. export class PerfCounter {
  31448. /**
  31449. * Gets or sets a global boolean to turn on and off all the counters
  31450. */
  31451. static Enabled: boolean;
  31452. /**
  31453. * Returns the smallest value ever
  31454. */
  31455. readonly min: number;
  31456. /**
  31457. * Returns the biggest value ever
  31458. */
  31459. readonly max: number;
  31460. /**
  31461. * Returns the average value since the performance counter is running
  31462. */
  31463. readonly average: number;
  31464. /**
  31465. * Returns the average value of the last second the counter was monitored
  31466. */
  31467. readonly lastSecAverage: number;
  31468. /**
  31469. * Returns the current value
  31470. */
  31471. readonly current: number;
  31472. /**
  31473. * Gets the accumulated total
  31474. */
  31475. readonly total: number;
  31476. /**
  31477. * Gets the total value count
  31478. */
  31479. readonly count: number;
  31480. /**
  31481. * Creates a new counter
  31482. */
  31483. constructor();
  31484. /**
  31485. * Call this method to start monitoring a new frame.
  31486. * 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.
  31487. */
  31488. fetchNewFrame(): void;
  31489. /**
  31490. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31491. * @param newCount the count value to add to the monitored count
  31492. * @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.
  31493. */
  31494. addCount(newCount: number, fetchResult: boolean): void;
  31495. /**
  31496. * Start monitoring this performance counter
  31497. */
  31498. beginMonitoring(): void;
  31499. /**
  31500. * Compute the time lapsed since the previous beginMonitoring() call.
  31501. * @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
  31502. */
  31503. endMonitoring(newFrame?: boolean): void;
  31504. private _fetchResult;
  31505. private _startMonitoringTime;
  31506. private _min;
  31507. private _max;
  31508. private _average;
  31509. private _current;
  31510. private _totalValueCount;
  31511. private _totalAccumulated;
  31512. private _lastSecAverage;
  31513. private _lastSecAccumulated;
  31514. private _lastSecTime;
  31515. private _lastSecValueCount;
  31516. }
  31517. /**
  31518. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31519. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31520. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31521. * @param name The name of the class, case should be preserved
  31522. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31523. */
  31524. export function className(name: string, module?: string): (target: Object) => void;
  31525. /**
  31526. * An implementation of a loop for asynchronous functions.
  31527. */
  31528. export class AsyncLoop {
  31529. /**
  31530. * Defines the number of iterations for the loop
  31531. */
  31532. iterations: number;
  31533. /**
  31534. * Defines the current index of the loop.
  31535. */
  31536. index: number;
  31537. private _done;
  31538. private _fn;
  31539. private _successCallback;
  31540. /**
  31541. * Constructor.
  31542. * @param iterations the number of iterations.
  31543. * @param func the function to run each iteration
  31544. * @param successCallback the callback that will be called upon succesful execution
  31545. * @param offset starting offset.
  31546. */
  31547. constructor(
  31548. /**
  31549. * Defines the number of iterations for the loop
  31550. */
  31551. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31552. /**
  31553. * Execute the next iteration. Must be called after the last iteration was finished.
  31554. */
  31555. executeNext(): void;
  31556. /**
  31557. * Break the loop and run the success callback.
  31558. */
  31559. breakLoop(): void;
  31560. /**
  31561. * Create and run an async loop.
  31562. * @param iterations the number of iterations.
  31563. * @param fn the function to run each iteration
  31564. * @param successCallback the callback that will be called upon succesful execution
  31565. * @param offset starting offset.
  31566. * @returns the created async loop object
  31567. */
  31568. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31569. /**
  31570. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31571. * @param iterations total number of iterations
  31572. * @param syncedIterations number of synchronous iterations in each async iteration.
  31573. * @param fn the function to call each iteration.
  31574. * @param callback a success call back that will be called when iterating stops.
  31575. * @param breakFunction a break condition (optional)
  31576. * @param timeout timeout settings for the setTimeout function. default - 0.
  31577. * @returns the created async loop object
  31578. */
  31579. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31580. }
  31581. }
  31582. declare module BABYLON {
  31583. /** @hidden */
  31584. export interface ICollisionCoordinator {
  31585. createCollider(): Collider;
  31586. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31587. init(scene: Scene): void;
  31588. }
  31589. /** @hidden */
  31590. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31591. private _scene;
  31592. private _scaledPosition;
  31593. private _scaledVelocity;
  31594. private _finalPosition;
  31595. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31596. createCollider(): Collider;
  31597. init(scene: Scene): void;
  31598. private _collideWithWorld;
  31599. }
  31600. }
  31601. declare module BABYLON {
  31602. /**
  31603. * Class used to manage all inputs for the scene.
  31604. */
  31605. export class InputManager {
  31606. /** The distance in pixel that you have to move to prevent some events */
  31607. static DragMovementThreshold: number;
  31608. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31609. static LongPressDelay: number;
  31610. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31611. static DoubleClickDelay: number;
  31612. /** If you need to check double click without raising a single click at first click, enable this flag */
  31613. static ExclusiveDoubleClickMode: boolean;
  31614. private _wheelEventName;
  31615. private _onPointerMove;
  31616. private _onPointerDown;
  31617. private _onPointerUp;
  31618. private _initClickEvent;
  31619. private _initActionManager;
  31620. private _delayedSimpleClick;
  31621. private _delayedSimpleClickTimeout;
  31622. private _previousDelayedSimpleClickTimeout;
  31623. private _meshPickProceed;
  31624. private _previousButtonPressed;
  31625. private _currentPickResult;
  31626. private _previousPickResult;
  31627. private _totalPointersPressed;
  31628. private _doubleClickOccured;
  31629. private _pointerOverMesh;
  31630. private _pickedDownMesh;
  31631. private _pickedUpMesh;
  31632. private _pointerX;
  31633. private _pointerY;
  31634. private _unTranslatedPointerX;
  31635. private _unTranslatedPointerY;
  31636. private _startingPointerPosition;
  31637. private _previousStartingPointerPosition;
  31638. private _startingPointerTime;
  31639. private _previousStartingPointerTime;
  31640. private _pointerCaptures;
  31641. private _onKeyDown;
  31642. private _onKeyUp;
  31643. private _onCanvasFocusObserver;
  31644. private _onCanvasBlurObserver;
  31645. private _scene;
  31646. /**
  31647. * Creates a new InputManager
  31648. * @param scene defines the hosting scene
  31649. */
  31650. constructor(scene: Scene);
  31651. /**
  31652. * Gets the mesh that is currently under the pointer
  31653. */
  31654. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31655. /**
  31656. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31657. */
  31658. readonly unTranslatedPointer: Vector2;
  31659. /**
  31660. * Gets or sets the current on-screen X position of the pointer
  31661. */
  31662. pointerX: number;
  31663. /**
  31664. * Gets or sets the current on-screen Y position of the pointer
  31665. */
  31666. pointerY: number;
  31667. private _updatePointerPosition;
  31668. private _processPointerMove;
  31669. private _setRayOnPointerInfo;
  31670. private _checkPrePointerObservable;
  31671. /**
  31672. * Use this method to simulate a pointer move on a mesh
  31673. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31674. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31675. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31676. */
  31677. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31678. /**
  31679. * Use this method to simulate a pointer down on a mesh
  31680. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31681. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31682. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31683. */
  31684. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31685. private _processPointerDown;
  31686. /** @hidden */
  31687. _isPointerSwiping(): boolean;
  31688. /**
  31689. * Use this method to simulate a pointer up on a mesh
  31690. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31691. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31692. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31693. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31694. */
  31695. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31696. private _processPointerUp;
  31697. /**
  31698. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31699. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31700. * @returns true if the pointer was captured
  31701. */
  31702. isPointerCaptured(pointerId?: number): boolean;
  31703. /**
  31704. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31705. * @param attachUp defines if you want to attach events to pointerup
  31706. * @param attachDown defines if you want to attach events to pointerdown
  31707. * @param attachMove defines if you want to attach events to pointermove
  31708. */
  31709. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31710. /**
  31711. * Detaches all event handlers
  31712. */
  31713. detachControl(): void;
  31714. /**
  31715. * Force the value of meshUnderPointer
  31716. * @param mesh defines the mesh to use
  31717. */
  31718. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31719. /**
  31720. * Gets the mesh under the pointer
  31721. * @returns a Mesh or null if no mesh is under the pointer
  31722. */
  31723. getPointerOverMesh(): Nullable<AbstractMesh>;
  31724. }
  31725. }
  31726. declare module BABYLON {
  31727. /**
  31728. * This class defines the direct association between an animation and a target
  31729. */
  31730. export class TargetedAnimation {
  31731. /**
  31732. * Animation to perform
  31733. */
  31734. animation: Animation;
  31735. /**
  31736. * Target to animate
  31737. */
  31738. target: any;
  31739. }
  31740. /**
  31741. * Use this class to create coordinated animations on multiple targets
  31742. */
  31743. export class AnimationGroup implements IDisposable {
  31744. /** The name of the animation group */
  31745. name: string;
  31746. private _scene;
  31747. private _targetedAnimations;
  31748. private _animatables;
  31749. private _from;
  31750. private _to;
  31751. private _isStarted;
  31752. private _isPaused;
  31753. private _speedRatio;
  31754. private _loopAnimation;
  31755. /**
  31756. * Gets or sets the unique id of the node
  31757. */
  31758. uniqueId: number;
  31759. /**
  31760. * This observable will notify when one animation have ended
  31761. */
  31762. onAnimationEndObservable: Observable<TargetedAnimation>;
  31763. /**
  31764. * Observer raised when one animation loops
  31765. */
  31766. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31767. /**
  31768. * This observable will notify when all animations have ended.
  31769. */
  31770. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31771. /**
  31772. * This observable will notify when all animations have paused.
  31773. */
  31774. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31775. /**
  31776. * This observable will notify when all animations are playing.
  31777. */
  31778. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31779. /**
  31780. * Gets the first frame
  31781. */
  31782. readonly from: number;
  31783. /**
  31784. * Gets the last frame
  31785. */
  31786. readonly to: number;
  31787. /**
  31788. * Define if the animations are started
  31789. */
  31790. readonly isStarted: boolean;
  31791. /**
  31792. * Gets a value indicating that the current group is playing
  31793. */
  31794. readonly isPlaying: boolean;
  31795. /**
  31796. * Gets or sets the speed ratio to use for all animations
  31797. */
  31798. /**
  31799. * Gets or sets the speed ratio to use for all animations
  31800. */
  31801. speedRatio: number;
  31802. /**
  31803. * Gets or sets if all animations should loop or not
  31804. */
  31805. loopAnimation: boolean;
  31806. /**
  31807. * Gets the targeted animations for this animation group
  31808. */
  31809. readonly targetedAnimations: Array<TargetedAnimation>;
  31810. /**
  31811. * returning the list of animatables controlled by this animation group.
  31812. */
  31813. readonly animatables: Array<Animatable>;
  31814. /**
  31815. * Instantiates a new Animation Group.
  31816. * This helps managing several animations at once.
  31817. * @see http://doc.babylonjs.com/how_to/group
  31818. * @param name Defines the name of the group
  31819. * @param scene Defines the scene the group belongs to
  31820. */
  31821. constructor(
  31822. /** The name of the animation group */
  31823. name: string, scene?: Nullable<Scene>);
  31824. /**
  31825. * Add an animation (with its target) in the group
  31826. * @param animation defines the animation we want to add
  31827. * @param target defines the target of the animation
  31828. * @returns the TargetedAnimation object
  31829. */
  31830. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31831. /**
  31832. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31833. * It can add constant keys at begin or end
  31834. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31835. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31836. * @returns the animation group
  31837. */
  31838. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31839. /**
  31840. * Start all animations on given targets
  31841. * @param loop defines if animations must loop
  31842. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31843. * @param from defines the from key (optional)
  31844. * @param to defines the to key (optional)
  31845. * @returns the current animation group
  31846. */
  31847. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31848. /**
  31849. * Pause all animations
  31850. * @returns the animation group
  31851. */
  31852. pause(): AnimationGroup;
  31853. /**
  31854. * Play all animations to initial state
  31855. * This function will start() the animations if they were not started or will restart() them if they were paused
  31856. * @param loop defines if animations must loop
  31857. * @returns the animation group
  31858. */
  31859. play(loop?: boolean): AnimationGroup;
  31860. /**
  31861. * Reset all animations to initial state
  31862. * @returns the animation group
  31863. */
  31864. reset(): AnimationGroup;
  31865. /**
  31866. * Restart animations from key 0
  31867. * @returns the animation group
  31868. */
  31869. restart(): AnimationGroup;
  31870. /**
  31871. * Stop all animations
  31872. * @returns the animation group
  31873. */
  31874. stop(): AnimationGroup;
  31875. /**
  31876. * Set animation weight for all animatables
  31877. * @param weight defines the weight to use
  31878. * @return the animationGroup
  31879. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31880. */
  31881. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31882. /**
  31883. * Synchronize and normalize all animatables with a source animatable
  31884. * @param root defines the root animatable to synchronize with
  31885. * @return the animationGroup
  31886. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31887. */
  31888. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31889. /**
  31890. * Goes to a specific frame in this animation group
  31891. * @param frame the frame number to go to
  31892. * @return the animationGroup
  31893. */
  31894. goToFrame(frame: number): AnimationGroup;
  31895. /**
  31896. * Dispose all associated resources
  31897. */
  31898. dispose(): void;
  31899. private _checkAnimationGroupEnded;
  31900. /**
  31901. * Clone the current animation group and returns a copy
  31902. * @param newName defines the name of the new group
  31903. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31904. * @returns the new aniamtion group
  31905. */
  31906. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31907. /**
  31908. * Returns a new AnimationGroup object parsed from the source provided.
  31909. * @param parsedAnimationGroup defines the source
  31910. * @param scene defines the scene that will receive the animationGroup
  31911. * @returns a new AnimationGroup
  31912. */
  31913. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31914. /**
  31915. * Returns the string "AnimationGroup"
  31916. * @returns "AnimationGroup"
  31917. */
  31918. getClassName(): string;
  31919. /**
  31920. * Creates a detailled string about the object
  31921. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31922. * @returns a string representing the object
  31923. */
  31924. toString(fullDetails?: boolean): string;
  31925. }
  31926. }
  31927. declare module BABYLON {
  31928. /**
  31929. * Define an interface for all classes that will hold resources
  31930. */
  31931. export interface IDisposable {
  31932. /**
  31933. * Releases all held resources
  31934. */
  31935. dispose(): void;
  31936. }
  31937. /** Interface defining initialization parameters for Scene class */
  31938. export interface SceneOptions {
  31939. /**
  31940. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31941. * It will improve performance when the number of geometries becomes important.
  31942. */
  31943. useGeometryUniqueIdsMap?: boolean;
  31944. /**
  31945. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31946. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31947. */
  31948. useMaterialMeshMap?: boolean;
  31949. /**
  31950. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31951. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31952. */
  31953. useClonedMeshhMap?: boolean;
  31954. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31955. virtual?: boolean;
  31956. }
  31957. /**
  31958. * Represents a scene to be rendered by the engine.
  31959. * @see http://doc.babylonjs.com/features/scene
  31960. */
  31961. export class Scene extends AbstractScene implements IAnimatable {
  31962. private static _uniqueIdCounter;
  31963. /** The fog is deactivated */
  31964. static readonly FOGMODE_NONE: number;
  31965. /** The fog density is following an exponential function */
  31966. static readonly FOGMODE_EXP: number;
  31967. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31968. static readonly FOGMODE_EXP2: number;
  31969. /** The fog density is following a linear function. */
  31970. static readonly FOGMODE_LINEAR: number;
  31971. /**
  31972. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31973. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31974. */
  31975. static MinDeltaTime: number;
  31976. /**
  31977. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31979. */
  31980. static MaxDeltaTime: number;
  31981. /**
  31982. * Factory used to create the default material.
  31983. * @param name The name of the material to create
  31984. * @param scene The scene to create the material for
  31985. * @returns The default material
  31986. */
  31987. static DefaultMaterialFactory(scene: Scene): Material;
  31988. /**
  31989. * Factory used to create the a collision coordinator.
  31990. * @returns The collision coordinator
  31991. */
  31992. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31993. /** @hidden */
  31994. _inputManager: InputManager;
  31995. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31996. cameraToUseForPointers: Nullable<Camera>;
  31997. /** @hidden */
  31998. readonly _isScene: boolean;
  31999. /**
  32000. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32001. */
  32002. autoClear: boolean;
  32003. /**
  32004. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32005. */
  32006. autoClearDepthAndStencil: boolean;
  32007. /**
  32008. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32009. */
  32010. clearColor: Color4;
  32011. /**
  32012. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32013. */
  32014. ambientColor: Color3;
  32015. /**
  32016. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32017. * It should only be one of the following (if not the default embedded one):
  32018. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32019. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32020. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32021. * The material properties need to be setup according to the type of texture in use.
  32022. */
  32023. environmentBRDFTexture: BaseTexture;
  32024. /** @hidden */
  32025. protected _environmentTexture: Nullable<BaseTexture>;
  32026. /**
  32027. * Texture used in all pbr material as the reflection texture.
  32028. * As in the majority of the scene they are the same (exception for multi room and so on),
  32029. * this is easier to reference from here than from all the materials.
  32030. */
  32031. /**
  32032. * Texture used in all pbr material as the reflection texture.
  32033. * As in the majority of the scene they are the same (exception for multi room and so on),
  32034. * this is easier to set here than in all the materials.
  32035. */
  32036. environmentTexture: Nullable<BaseTexture>;
  32037. /** @hidden */
  32038. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32039. /**
  32040. * Default image processing configuration used either in the rendering
  32041. * Forward main pass or through the imageProcessingPostProcess if present.
  32042. * As in the majority of the scene they are the same (exception for multi camera),
  32043. * this is easier to reference from here than from all the materials and post process.
  32044. *
  32045. * No setter as we it is a shared configuration, you can set the values instead.
  32046. */
  32047. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32048. private _forceWireframe;
  32049. /**
  32050. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32051. */
  32052. forceWireframe: boolean;
  32053. private _forcePointsCloud;
  32054. /**
  32055. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32056. */
  32057. forcePointsCloud: boolean;
  32058. /**
  32059. * Gets or sets the active clipplane 1
  32060. */
  32061. clipPlane: Nullable<Plane>;
  32062. /**
  32063. * Gets or sets the active clipplane 2
  32064. */
  32065. clipPlane2: Nullable<Plane>;
  32066. /**
  32067. * Gets or sets the active clipplane 3
  32068. */
  32069. clipPlane3: Nullable<Plane>;
  32070. /**
  32071. * Gets or sets the active clipplane 4
  32072. */
  32073. clipPlane4: Nullable<Plane>;
  32074. /**
  32075. * Gets or sets a boolean indicating if animations are enabled
  32076. */
  32077. animationsEnabled: boolean;
  32078. private _animationPropertiesOverride;
  32079. /**
  32080. * Gets or sets the animation properties override
  32081. */
  32082. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32083. /**
  32084. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32085. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32086. */
  32087. useConstantAnimationDeltaTime: boolean;
  32088. /**
  32089. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32090. * Please note that it requires to run a ray cast through the scene on every frame
  32091. */
  32092. constantlyUpdateMeshUnderPointer: boolean;
  32093. /**
  32094. * Defines the HTML cursor to use when hovering over interactive elements
  32095. */
  32096. hoverCursor: string;
  32097. /**
  32098. * Defines the HTML default cursor to use (empty by default)
  32099. */
  32100. defaultCursor: string;
  32101. /**
  32102. * This is used to call preventDefault() on pointer down
  32103. * in order to block unwanted artifacts like system double clicks
  32104. */
  32105. preventDefaultOnPointerDown: boolean;
  32106. /**
  32107. * This is used to call preventDefault() on pointer up
  32108. * in order to block unwanted artifacts like system double clicks
  32109. */
  32110. preventDefaultOnPointerUp: boolean;
  32111. /**
  32112. * Gets or sets user defined metadata
  32113. */
  32114. metadata: any;
  32115. /**
  32116. * For internal use only. Please do not use.
  32117. */
  32118. reservedDataStore: any;
  32119. /**
  32120. * Gets the name of the plugin used to load this scene (null by default)
  32121. */
  32122. loadingPluginName: string;
  32123. /**
  32124. * Use this array to add regular expressions used to disable offline support for specific urls
  32125. */
  32126. disableOfflineSupportExceptionRules: RegExp[];
  32127. /**
  32128. * An event triggered when the scene is disposed.
  32129. */
  32130. onDisposeObservable: Observable<Scene>;
  32131. private _onDisposeObserver;
  32132. /** Sets a function to be executed when this scene is disposed. */
  32133. onDispose: () => void;
  32134. /**
  32135. * An event triggered before rendering the scene (right after animations and physics)
  32136. */
  32137. onBeforeRenderObservable: Observable<Scene>;
  32138. private _onBeforeRenderObserver;
  32139. /** Sets a function to be executed before rendering this scene */
  32140. beforeRender: Nullable<() => void>;
  32141. /**
  32142. * An event triggered after rendering the scene
  32143. */
  32144. onAfterRenderObservable: Observable<Scene>;
  32145. private _onAfterRenderObserver;
  32146. /** Sets a function to be executed after rendering this scene */
  32147. afterRender: Nullable<() => void>;
  32148. /**
  32149. * An event triggered before animating the scene
  32150. */
  32151. onBeforeAnimationsObservable: Observable<Scene>;
  32152. /**
  32153. * An event triggered after animations processing
  32154. */
  32155. onAfterAnimationsObservable: Observable<Scene>;
  32156. /**
  32157. * An event triggered before draw calls are ready to be sent
  32158. */
  32159. onBeforeDrawPhaseObservable: Observable<Scene>;
  32160. /**
  32161. * An event triggered after draw calls have been sent
  32162. */
  32163. onAfterDrawPhaseObservable: Observable<Scene>;
  32164. /**
  32165. * An event triggered when the scene is ready
  32166. */
  32167. onReadyObservable: Observable<Scene>;
  32168. /**
  32169. * An event triggered before rendering a camera
  32170. */
  32171. onBeforeCameraRenderObservable: Observable<Camera>;
  32172. private _onBeforeCameraRenderObserver;
  32173. /** Sets a function to be executed before rendering a camera*/
  32174. beforeCameraRender: () => void;
  32175. /**
  32176. * An event triggered after rendering a camera
  32177. */
  32178. onAfterCameraRenderObservable: Observable<Camera>;
  32179. private _onAfterCameraRenderObserver;
  32180. /** Sets a function to be executed after rendering a camera*/
  32181. afterCameraRender: () => void;
  32182. /**
  32183. * An event triggered when active meshes evaluation is about to start
  32184. */
  32185. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32186. /**
  32187. * An event triggered when active meshes evaluation is done
  32188. */
  32189. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32190. /**
  32191. * An event triggered when particles rendering is about to start
  32192. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32193. */
  32194. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32195. /**
  32196. * An event triggered when particles rendering is done
  32197. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32198. */
  32199. onAfterParticlesRenderingObservable: Observable<Scene>;
  32200. /**
  32201. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32202. */
  32203. onDataLoadedObservable: Observable<Scene>;
  32204. /**
  32205. * An event triggered when a camera is created
  32206. */
  32207. onNewCameraAddedObservable: Observable<Camera>;
  32208. /**
  32209. * An event triggered when a camera is removed
  32210. */
  32211. onCameraRemovedObservable: Observable<Camera>;
  32212. /**
  32213. * An event triggered when a light is created
  32214. */
  32215. onNewLightAddedObservable: Observable<Light>;
  32216. /**
  32217. * An event triggered when a light is removed
  32218. */
  32219. onLightRemovedObservable: Observable<Light>;
  32220. /**
  32221. * An event triggered when a geometry is created
  32222. */
  32223. onNewGeometryAddedObservable: Observable<Geometry>;
  32224. /**
  32225. * An event triggered when a geometry is removed
  32226. */
  32227. onGeometryRemovedObservable: Observable<Geometry>;
  32228. /**
  32229. * An event triggered when a transform node is created
  32230. */
  32231. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32232. /**
  32233. * An event triggered when a transform node is removed
  32234. */
  32235. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32236. /**
  32237. * An event triggered when a mesh is created
  32238. */
  32239. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32240. /**
  32241. * An event triggered when a mesh is removed
  32242. */
  32243. onMeshRemovedObservable: Observable<AbstractMesh>;
  32244. /**
  32245. * An event triggered when a skeleton is created
  32246. */
  32247. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32248. /**
  32249. * An event triggered when a skeleton is removed
  32250. */
  32251. onSkeletonRemovedObservable: Observable<Skeleton>;
  32252. /**
  32253. * An event triggered when a material is created
  32254. */
  32255. onNewMaterialAddedObservable: Observable<Material>;
  32256. /**
  32257. * An event triggered when a material is removed
  32258. */
  32259. onMaterialRemovedObservable: Observable<Material>;
  32260. /**
  32261. * An event triggered when a texture is created
  32262. */
  32263. onNewTextureAddedObservable: Observable<BaseTexture>;
  32264. /**
  32265. * An event triggered when a texture is removed
  32266. */
  32267. onTextureRemovedObservable: Observable<BaseTexture>;
  32268. /**
  32269. * An event triggered when render targets are about to be rendered
  32270. * Can happen multiple times per frame.
  32271. */
  32272. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32273. /**
  32274. * An event triggered when render targets were rendered.
  32275. * Can happen multiple times per frame.
  32276. */
  32277. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32278. /**
  32279. * An event triggered before calculating deterministic simulation step
  32280. */
  32281. onBeforeStepObservable: Observable<Scene>;
  32282. /**
  32283. * An event triggered after calculating deterministic simulation step
  32284. */
  32285. onAfterStepObservable: Observable<Scene>;
  32286. /**
  32287. * An event triggered when the activeCamera property is updated
  32288. */
  32289. onActiveCameraChanged: Observable<Scene>;
  32290. /**
  32291. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32292. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32293. * 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)
  32294. */
  32295. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32296. /**
  32297. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32298. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32299. * 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)
  32300. */
  32301. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32302. /**
  32303. * This Observable will when a mesh has been imported into the scene.
  32304. */
  32305. onMeshImportedObservable: Observable<AbstractMesh>;
  32306. /**
  32307. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32308. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32309. */
  32310. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32311. /** @hidden */
  32312. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32313. /**
  32314. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32315. */
  32316. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32317. /**
  32318. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32319. */
  32320. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32321. /**
  32322. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32323. */
  32324. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32325. /** Callback called when a pointer move is detected */
  32326. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32327. /** Callback called when a pointer down is detected */
  32328. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32329. /** Callback called when a pointer up is detected */
  32330. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32331. /** Callback called when a pointer pick is detected */
  32332. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32333. /**
  32334. * 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).
  32335. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32336. */
  32337. onPrePointerObservable: Observable<PointerInfoPre>;
  32338. /**
  32339. * Observable event triggered each time an input event is received from the rendering canvas
  32340. */
  32341. onPointerObservable: Observable<PointerInfo>;
  32342. /**
  32343. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32344. */
  32345. readonly unTranslatedPointer: Vector2;
  32346. /**
  32347. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32348. */
  32349. static DragMovementThreshold: number;
  32350. /**
  32351. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32352. */
  32353. static LongPressDelay: number;
  32354. /**
  32355. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32356. */
  32357. static DoubleClickDelay: number;
  32358. /** If you need to check double click without raising a single click at first click, enable this flag */
  32359. static ExclusiveDoubleClickMode: boolean;
  32360. /** @hidden */
  32361. _mirroredCameraPosition: Nullable<Vector3>;
  32362. /**
  32363. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32364. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32365. */
  32366. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32367. /**
  32368. * Observable event triggered each time an keyboard event is received from the hosting window
  32369. */
  32370. onKeyboardObservable: Observable<KeyboardInfo>;
  32371. private _useRightHandedSystem;
  32372. /**
  32373. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32374. */
  32375. useRightHandedSystem: boolean;
  32376. private _timeAccumulator;
  32377. private _currentStepId;
  32378. private _currentInternalStep;
  32379. /**
  32380. * Sets the step Id used by deterministic lock step
  32381. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32382. * @param newStepId defines the step Id
  32383. */
  32384. setStepId(newStepId: number): void;
  32385. /**
  32386. * Gets the step Id used by deterministic lock step
  32387. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32388. * @returns the step Id
  32389. */
  32390. getStepId(): number;
  32391. /**
  32392. * Gets the internal step used by deterministic lock step
  32393. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32394. * @returns the internal step
  32395. */
  32396. getInternalStep(): number;
  32397. private _fogEnabled;
  32398. /**
  32399. * Gets or sets a boolean indicating if fog is enabled on this scene
  32400. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32401. * (Default is true)
  32402. */
  32403. fogEnabled: boolean;
  32404. private _fogMode;
  32405. /**
  32406. * Gets or sets the fog mode to use
  32407. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32408. * | mode | value |
  32409. * | --- | --- |
  32410. * | FOGMODE_NONE | 0 |
  32411. * | FOGMODE_EXP | 1 |
  32412. * | FOGMODE_EXP2 | 2 |
  32413. * | FOGMODE_LINEAR | 3 |
  32414. */
  32415. fogMode: number;
  32416. /**
  32417. * Gets or sets the fog color to use
  32418. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32419. * (Default is Color3(0.2, 0.2, 0.3))
  32420. */
  32421. fogColor: Color3;
  32422. /**
  32423. * Gets or sets the fog density to use
  32424. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32425. * (Default is 0.1)
  32426. */
  32427. fogDensity: number;
  32428. /**
  32429. * Gets or sets the fog start distance to use
  32430. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32431. * (Default is 0)
  32432. */
  32433. fogStart: number;
  32434. /**
  32435. * Gets or sets the fog end distance to use
  32436. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32437. * (Default is 1000)
  32438. */
  32439. fogEnd: number;
  32440. private _shadowsEnabled;
  32441. /**
  32442. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32443. */
  32444. shadowsEnabled: boolean;
  32445. private _lightsEnabled;
  32446. /**
  32447. * Gets or sets a boolean indicating if lights are enabled on this scene
  32448. */
  32449. lightsEnabled: boolean;
  32450. /** All of the active cameras added to this scene. */
  32451. activeCameras: Camera[];
  32452. /** @hidden */
  32453. _activeCamera: Nullable<Camera>;
  32454. /** Gets or sets the current active camera */
  32455. activeCamera: Nullable<Camera>;
  32456. private _defaultMaterial;
  32457. /** The default material used on meshes when no material is affected */
  32458. /** The default material used on meshes when no material is affected */
  32459. defaultMaterial: Material;
  32460. private _texturesEnabled;
  32461. /**
  32462. * Gets or sets a boolean indicating if textures are enabled on this scene
  32463. */
  32464. texturesEnabled: boolean;
  32465. /**
  32466. * Gets or sets a boolean indicating if particles are enabled on this scene
  32467. */
  32468. particlesEnabled: boolean;
  32469. /**
  32470. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32471. */
  32472. spritesEnabled: boolean;
  32473. private _skeletonsEnabled;
  32474. /**
  32475. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32476. */
  32477. skeletonsEnabled: boolean;
  32478. /**
  32479. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32480. */
  32481. lensFlaresEnabled: boolean;
  32482. /**
  32483. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32485. */
  32486. collisionsEnabled: boolean;
  32487. private _collisionCoordinator;
  32488. /** @hidden */
  32489. readonly collisionCoordinator: ICollisionCoordinator;
  32490. /**
  32491. * Defines the gravity applied to this scene (used only for collisions)
  32492. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32493. */
  32494. gravity: Vector3;
  32495. /**
  32496. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32497. */
  32498. postProcessesEnabled: boolean;
  32499. /**
  32500. * The list of postprocesses added to the scene
  32501. */
  32502. postProcesses: PostProcess[];
  32503. /**
  32504. * Gets the current postprocess manager
  32505. */
  32506. postProcessManager: PostProcessManager;
  32507. /**
  32508. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32509. */
  32510. renderTargetsEnabled: boolean;
  32511. /**
  32512. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32513. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32514. */
  32515. dumpNextRenderTargets: boolean;
  32516. /**
  32517. * The list of user defined render targets added to the scene
  32518. */
  32519. customRenderTargets: RenderTargetTexture[];
  32520. /**
  32521. * Defines if texture loading must be delayed
  32522. * If true, textures will only be loaded when they need to be rendered
  32523. */
  32524. useDelayedTextureLoading: boolean;
  32525. /**
  32526. * Gets the list of meshes imported to the scene through SceneLoader
  32527. */
  32528. importedMeshesFiles: String[];
  32529. /**
  32530. * Gets or sets a boolean indicating if probes are enabled on this scene
  32531. */
  32532. probesEnabled: boolean;
  32533. /**
  32534. * Gets or sets the current offline provider to use to store scene data
  32535. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32536. */
  32537. offlineProvider: IOfflineProvider;
  32538. /**
  32539. * Gets or sets the action manager associated with the scene
  32540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32541. */
  32542. actionManager: AbstractActionManager;
  32543. private _meshesForIntersections;
  32544. /**
  32545. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32546. */
  32547. proceduralTexturesEnabled: boolean;
  32548. private _engine;
  32549. private _totalVertices;
  32550. /** @hidden */
  32551. _activeIndices: PerfCounter;
  32552. /** @hidden */
  32553. _activeParticles: PerfCounter;
  32554. /** @hidden */
  32555. _activeBones: PerfCounter;
  32556. private _animationRatio;
  32557. /** @hidden */
  32558. _animationTimeLast: number;
  32559. /** @hidden */
  32560. _animationTime: number;
  32561. /**
  32562. * Gets or sets a general scale for animation speed
  32563. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32564. */
  32565. animationTimeScale: number;
  32566. /** @hidden */
  32567. _cachedMaterial: Nullable<Material>;
  32568. /** @hidden */
  32569. _cachedEffect: Nullable<Effect>;
  32570. /** @hidden */
  32571. _cachedVisibility: Nullable<number>;
  32572. private _renderId;
  32573. private _frameId;
  32574. private _executeWhenReadyTimeoutId;
  32575. private _intermediateRendering;
  32576. private _viewUpdateFlag;
  32577. private _projectionUpdateFlag;
  32578. /** @hidden */
  32579. _toBeDisposed: Nullable<IDisposable>[];
  32580. private _activeRequests;
  32581. /** @hidden */
  32582. _pendingData: any[];
  32583. private _isDisposed;
  32584. /**
  32585. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32586. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32587. */
  32588. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32589. private _activeMeshes;
  32590. private _processedMaterials;
  32591. private _renderTargets;
  32592. /** @hidden */
  32593. _activeParticleSystems: SmartArray<IParticleSystem>;
  32594. private _activeSkeletons;
  32595. private _softwareSkinnedMeshes;
  32596. private _renderingManager;
  32597. /** @hidden */
  32598. _activeAnimatables: Animatable[];
  32599. private _transformMatrix;
  32600. private _sceneUbo;
  32601. /** @hidden */
  32602. _viewMatrix: Matrix;
  32603. private _projectionMatrix;
  32604. /** @hidden */
  32605. _forcedViewPosition: Nullable<Vector3>;
  32606. /** @hidden */
  32607. _frustumPlanes: Plane[];
  32608. /**
  32609. * Gets the list of frustum planes (built from the active camera)
  32610. */
  32611. readonly frustumPlanes: Plane[];
  32612. /**
  32613. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32614. * This is useful if there are more lights that the maximum simulteanous authorized
  32615. */
  32616. requireLightSorting: boolean;
  32617. /** @hidden */
  32618. readonly useMaterialMeshMap: boolean;
  32619. /** @hidden */
  32620. readonly useClonedMeshhMap: boolean;
  32621. private _externalData;
  32622. private _uid;
  32623. /**
  32624. * @hidden
  32625. * Backing store of defined scene components.
  32626. */
  32627. _components: ISceneComponent[];
  32628. /**
  32629. * @hidden
  32630. * Backing store of defined scene components.
  32631. */
  32632. _serializableComponents: ISceneSerializableComponent[];
  32633. /**
  32634. * List of components to register on the next registration step.
  32635. */
  32636. private _transientComponents;
  32637. /**
  32638. * Registers the transient components if needed.
  32639. */
  32640. private _registerTransientComponents;
  32641. /**
  32642. * @hidden
  32643. * Add a component to the scene.
  32644. * Note that the ccomponent could be registered on th next frame if this is called after
  32645. * the register component stage.
  32646. * @param component Defines the component to add to the scene
  32647. */
  32648. _addComponent(component: ISceneComponent): void;
  32649. /**
  32650. * @hidden
  32651. * Gets a component from the scene.
  32652. * @param name defines the name of the component to retrieve
  32653. * @returns the component or null if not present
  32654. */
  32655. _getComponent(name: string): Nullable<ISceneComponent>;
  32656. /**
  32657. * @hidden
  32658. * Defines the actions happening before camera updates.
  32659. */
  32660. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32661. /**
  32662. * @hidden
  32663. * Defines the actions happening before clear the canvas.
  32664. */
  32665. _beforeClearStage: Stage<SimpleStageAction>;
  32666. /**
  32667. * @hidden
  32668. * Defines the actions when collecting render targets for the frame.
  32669. */
  32670. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32671. /**
  32672. * @hidden
  32673. * Defines the actions happening for one camera in the frame.
  32674. */
  32675. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32676. /**
  32677. * @hidden
  32678. * Defines the actions happening during the per mesh ready checks.
  32679. */
  32680. _isReadyForMeshStage: Stage<MeshStageAction>;
  32681. /**
  32682. * @hidden
  32683. * Defines the actions happening before evaluate active mesh checks.
  32684. */
  32685. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32686. /**
  32687. * @hidden
  32688. * Defines the actions happening during the evaluate sub mesh checks.
  32689. */
  32690. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32691. /**
  32692. * @hidden
  32693. * Defines the actions happening during the active mesh stage.
  32694. */
  32695. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32696. /**
  32697. * @hidden
  32698. * Defines the actions happening during the per camera render target step.
  32699. */
  32700. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32701. /**
  32702. * @hidden
  32703. * Defines the actions happening just before the active camera is drawing.
  32704. */
  32705. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32706. /**
  32707. * @hidden
  32708. * Defines the actions happening just before a render target is drawing.
  32709. */
  32710. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32711. /**
  32712. * @hidden
  32713. * Defines the actions happening just before a rendering group is drawing.
  32714. */
  32715. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32716. /**
  32717. * @hidden
  32718. * Defines the actions happening just before a mesh is drawing.
  32719. */
  32720. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32721. /**
  32722. * @hidden
  32723. * Defines the actions happening just after a mesh has been drawn.
  32724. */
  32725. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32726. /**
  32727. * @hidden
  32728. * Defines the actions happening just after a rendering group has been drawn.
  32729. */
  32730. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32731. /**
  32732. * @hidden
  32733. * Defines the actions happening just after the active camera has been drawn.
  32734. */
  32735. _afterCameraDrawStage: Stage<CameraStageAction>;
  32736. /**
  32737. * @hidden
  32738. * Defines the actions happening just after a render target has been drawn.
  32739. */
  32740. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32741. /**
  32742. * @hidden
  32743. * Defines the actions happening just after rendering all cameras and computing intersections.
  32744. */
  32745. _afterRenderStage: Stage<SimpleStageAction>;
  32746. /**
  32747. * @hidden
  32748. * Defines the actions happening when a pointer move event happens.
  32749. */
  32750. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32751. /**
  32752. * @hidden
  32753. * Defines the actions happening when a pointer down event happens.
  32754. */
  32755. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32756. /**
  32757. * @hidden
  32758. * Defines the actions happening when a pointer up event happens.
  32759. */
  32760. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32761. /**
  32762. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32763. */
  32764. private geometriesByUniqueId;
  32765. /**
  32766. * Creates a new Scene
  32767. * @param engine defines the engine to use to render this scene
  32768. * @param options defines the scene options
  32769. */
  32770. constructor(engine: Engine, options?: SceneOptions);
  32771. /**
  32772. * Gets a string idenfifying the name of the class
  32773. * @returns "Scene" string
  32774. */
  32775. getClassName(): string;
  32776. private _defaultMeshCandidates;
  32777. /**
  32778. * @hidden
  32779. */
  32780. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32781. private _defaultSubMeshCandidates;
  32782. /**
  32783. * @hidden
  32784. */
  32785. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32786. /**
  32787. * Sets the default candidate providers for the scene.
  32788. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32789. * and getCollidingSubMeshCandidates to their default function
  32790. */
  32791. setDefaultCandidateProviders(): void;
  32792. /**
  32793. * Gets the mesh that is currently under the pointer
  32794. */
  32795. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32796. /**
  32797. * Gets or sets the current on-screen X position of the pointer
  32798. */
  32799. pointerX: number;
  32800. /**
  32801. * Gets or sets the current on-screen Y position of the pointer
  32802. */
  32803. pointerY: number;
  32804. /**
  32805. * Gets the cached material (ie. the latest rendered one)
  32806. * @returns the cached material
  32807. */
  32808. getCachedMaterial(): Nullable<Material>;
  32809. /**
  32810. * Gets the cached effect (ie. the latest rendered one)
  32811. * @returns the cached effect
  32812. */
  32813. getCachedEffect(): Nullable<Effect>;
  32814. /**
  32815. * Gets the cached visibility state (ie. the latest rendered one)
  32816. * @returns the cached visibility state
  32817. */
  32818. getCachedVisibility(): Nullable<number>;
  32819. /**
  32820. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32821. * @param material defines the current material
  32822. * @param effect defines the current effect
  32823. * @param visibility defines the current visibility state
  32824. * @returns true if one parameter is not cached
  32825. */
  32826. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32827. /**
  32828. * Gets the engine associated with the scene
  32829. * @returns an Engine
  32830. */
  32831. getEngine(): Engine;
  32832. /**
  32833. * Gets the total number of vertices rendered per frame
  32834. * @returns the total number of vertices rendered per frame
  32835. */
  32836. getTotalVertices(): number;
  32837. /**
  32838. * Gets the performance counter for total vertices
  32839. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32840. */
  32841. readonly totalVerticesPerfCounter: PerfCounter;
  32842. /**
  32843. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32844. * @returns the total number of active indices rendered per frame
  32845. */
  32846. getActiveIndices(): number;
  32847. /**
  32848. * Gets the performance counter for active indices
  32849. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32850. */
  32851. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32852. /**
  32853. * Gets the total number of active particles rendered per frame
  32854. * @returns the total number of active particles rendered per frame
  32855. */
  32856. getActiveParticles(): number;
  32857. /**
  32858. * Gets the performance counter for active particles
  32859. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32860. */
  32861. readonly activeParticlesPerfCounter: PerfCounter;
  32862. /**
  32863. * Gets the total number of active bones rendered per frame
  32864. * @returns the total number of active bones rendered per frame
  32865. */
  32866. getActiveBones(): number;
  32867. /**
  32868. * Gets the performance counter for active bones
  32869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32870. */
  32871. readonly activeBonesPerfCounter: PerfCounter;
  32872. /**
  32873. * Gets the array of active meshes
  32874. * @returns an array of AbstractMesh
  32875. */
  32876. getActiveMeshes(): SmartArray<AbstractMesh>;
  32877. /**
  32878. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32879. * @returns a number
  32880. */
  32881. getAnimationRatio(): number;
  32882. /**
  32883. * Gets an unique Id for the current render phase
  32884. * @returns a number
  32885. */
  32886. getRenderId(): number;
  32887. /**
  32888. * Gets an unique Id for the current frame
  32889. * @returns a number
  32890. */
  32891. getFrameId(): number;
  32892. /** Call this function if you want to manually increment the render Id*/
  32893. incrementRenderId(): void;
  32894. private _createUbo;
  32895. /**
  32896. * Use this method to simulate a pointer move on a mesh
  32897. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32898. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32899. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32900. * @returns the current scene
  32901. */
  32902. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32903. /**
  32904. * Use this method to simulate a pointer down on a mesh
  32905. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32906. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32907. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32908. * @returns the current scene
  32909. */
  32910. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32911. /**
  32912. * Use this method to simulate a pointer up on a mesh
  32913. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32914. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32915. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32916. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32917. * @returns the current scene
  32918. */
  32919. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32920. /**
  32921. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32922. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32923. * @returns true if the pointer was captured
  32924. */
  32925. isPointerCaptured(pointerId?: number): boolean;
  32926. /**
  32927. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32928. * @param attachUp defines if you want to attach events to pointerup
  32929. * @param attachDown defines if you want to attach events to pointerdown
  32930. * @param attachMove defines if you want to attach events to pointermove
  32931. */
  32932. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32933. /** Detaches all event handlers*/
  32934. detachControl(): void;
  32935. /**
  32936. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32937. * Delay loaded resources are not taking in account
  32938. * @return true if all required resources are ready
  32939. */
  32940. isReady(): boolean;
  32941. /** Resets all cached information relative to material (including effect and visibility) */
  32942. resetCachedMaterial(): void;
  32943. /**
  32944. * Registers a function to be called before every frame render
  32945. * @param func defines the function to register
  32946. */
  32947. registerBeforeRender(func: () => void): void;
  32948. /**
  32949. * Unregisters a function called before every frame render
  32950. * @param func defines the function to unregister
  32951. */
  32952. unregisterBeforeRender(func: () => void): void;
  32953. /**
  32954. * Registers a function to be called after every frame render
  32955. * @param func defines the function to register
  32956. */
  32957. registerAfterRender(func: () => void): void;
  32958. /**
  32959. * Unregisters a function called after every frame render
  32960. * @param func defines the function to unregister
  32961. */
  32962. unregisterAfterRender(func: () => void): void;
  32963. private _executeOnceBeforeRender;
  32964. /**
  32965. * The provided function will run before render once and will be disposed afterwards.
  32966. * A timeout delay can be provided so that the function will be executed in N ms.
  32967. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32968. * @param func The function to be executed.
  32969. * @param timeout optional delay in ms
  32970. */
  32971. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32972. /** @hidden */
  32973. _addPendingData(data: any): void;
  32974. /** @hidden */
  32975. _removePendingData(data: any): void;
  32976. /**
  32977. * Returns the number of items waiting to be loaded
  32978. * @returns the number of items waiting to be loaded
  32979. */
  32980. getWaitingItemsCount(): number;
  32981. /**
  32982. * Returns a boolean indicating if the scene is still loading data
  32983. */
  32984. readonly isLoading: boolean;
  32985. /**
  32986. * Registers a function to be executed when the scene is ready
  32987. * @param {Function} func - the function to be executed
  32988. */
  32989. executeWhenReady(func: () => void): void;
  32990. /**
  32991. * Returns a promise that resolves when the scene is ready
  32992. * @returns A promise that resolves when the scene is ready
  32993. */
  32994. whenReadyAsync(): Promise<void>;
  32995. /** @hidden */
  32996. _checkIsReady(): void;
  32997. /**
  32998. * Gets all animatable attached to the scene
  32999. */
  33000. readonly animatables: Animatable[];
  33001. /**
  33002. * Resets the last animation time frame.
  33003. * Useful to override when animations start running when loading a scene for the first time.
  33004. */
  33005. resetLastAnimationTimeFrame(): void;
  33006. /**
  33007. * Gets the current view matrix
  33008. * @returns a Matrix
  33009. */
  33010. getViewMatrix(): Matrix;
  33011. /**
  33012. * Gets the current projection matrix
  33013. * @returns a Matrix
  33014. */
  33015. getProjectionMatrix(): Matrix;
  33016. /**
  33017. * Gets the current transform matrix
  33018. * @returns a Matrix made of View * Projection
  33019. */
  33020. getTransformMatrix(): Matrix;
  33021. /**
  33022. * Sets the current transform matrix
  33023. * @param viewL defines the View matrix to use
  33024. * @param projectionL defines the Projection matrix to use
  33025. * @param viewR defines the right View matrix to use (if provided)
  33026. * @param projectionR defines the right Projection matrix to use (if provided)
  33027. */
  33028. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33029. /**
  33030. * Gets the uniform buffer used to store scene data
  33031. * @returns a UniformBuffer
  33032. */
  33033. getSceneUniformBuffer(): UniformBuffer;
  33034. /**
  33035. * Gets an unique (relatively to the current scene) Id
  33036. * @returns an unique number for the scene
  33037. */
  33038. getUniqueId(): number;
  33039. /**
  33040. * Add a mesh to the list of scene's meshes
  33041. * @param newMesh defines the mesh to add
  33042. * @param recursive if all child meshes should also be added to the scene
  33043. */
  33044. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33045. /**
  33046. * Remove a mesh for the list of scene's meshes
  33047. * @param toRemove defines the mesh to remove
  33048. * @param recursive if all child meshes should also be removed from the scene
  33049. * @returns the index where the mesh was in the mesh list
  33050. */
  33051. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33052. /**
  33053. * Add a transform node to the list of scene's transform nodes
  33054. * @param newTransformNode defines the transform node to add
  33055. */
  33056. addTransformNode(newTransformNode: TransformNode): void;
  33057. /**
  33058. * Remove a transform node for the list of scene's transform nodes
  33059. * @param toRemove defines the transform node to remove
  33060. * @returns the index where the transform node was in the transform node list
  33061. */
  33062. removeTransformNode(toRemove: TransformNode): number;
  33063. /**
  33064. * Remove a skeleton for the list of scene's skeletons
  33065. * @param toRemove defines the skeleton to remove
  33066. * @returns the index where the skeleton was in the skeleton list
  33067. */
  33068. removeSkeleton(toRemove: Skeleton): number;
  33069. /**
  33070. * Remove a morph target for the list of scene's morph targets
  33071. * @param toRemove defines the morph target to remove
  33072. * @returns the index where the morph target was in the morph target list
  33073. */
  33074. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33075. /**
  33076. * Remove a light for the list of scene's lights
  33077. * @param toRemove defines the light to remove
  33078. * @returns the index where the light was in the light list
  33079. */
  33080. removeLight(toRemove: Light): number;
  33081. /**
  33082. * Remove a camera for the list of scene's cameras
  33083. * @param toRemove defines the camera to remove
  33084. * @returns the index where the camera was in the camera list
  33085. */
  33086. removeCamera(toRemove: Camera): number;
  33087. /**
  33088. * Remove a particle system for the list of scene's particle systems
  33089. * @param toRemove defines the particle system to remove
  33090. * @returns the index where the particle system was in the particle system list
  33091. */
  33092. removeParticleSystem(toRemove: IParticleSystem): number;
  33093. /**
  33094. * Remove a animation for the list of scene's animations
  33095. * @param toRemove defines the animation to remove
  33096. * @returns the index where the animation was in the animation list
  33097. */
  33098. removeAnimation(toRemove: Animation): number;
  33099. /**
  33100. * Will stop the animation of the given target
  33101. * @param target - the target
  33102. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33103. * @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)
  33104. */
  33105. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33106. /**
  33107. * Removes the given animation group from this scene.
  33108. * @param toRemove The animation group to remove
  33109. * @returns The index of the removed animation group
  33110. */
  33111. removeAnimationGroup(toRemove: AnimationGroup): number;
  33112. /**
  33113. * Removes the given multi-material from this scene.
  33114. * @param toRemove The multi-material to remove
  33115. * @returns The index of the removed multi-material
  33116. */
  33117. removeMultiMaterial(toRemove: MultiMaterial): number;
  33118. /**
  33119. * Removes the given material from this scene.
  33120. * @param toRemove The material to remove
  33121. * @returns The index of the removed material
  33122. */
  33123. removeMaterial(toRemove: Material): number;
  33124. /**
  33125. * Removes the given action manager from this scene.
  33126. * @param toRemove The action manager to remove
  33127. * @returns The index of the removed action manager
  33128. */
  33129. removeActionManager(toRemove: AbstractActionManager): number;
  33130. /**
  33131. * Removes the given texture from this scene.
  33132. * @param toRemove The texture to remove
  33133. * @returns The index of the removed texture
  33134. */
  33135. removeTexture(toRemove: BaseTexture): number;
  33136. /**
  33137. * Adds the given light to this scene
  33138. * @param newLight The light to add
  33139. */
  33140. addLight(newLight: Light): void;
  33141. /**
  33142. * Sorts the list list based on light priorities
  33143. */
  33144. sortLightsByPriority(): void;
  33145. /**
  33146. * Adds the given camera to this scene
  33147. * @param newCamera The camera to add
  33148. */
  33149. addCamera(newCamera: Camera): void;
  33150. /**
  33151. * Adds the given skeleton to this scene
  33152. * @param newSkeleton The skeleton to add
  33153. */
  33154. addSkeleton(newSkeleton: Skeleton): void;
  33155. /**
  33156. * Adds the given particle system to this scene
  33157. * @param newParticleSystem The particle system to add
  33158. */
  33159. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33160. /**
  33161. * Adds the given animation to this scene
  33162. * @param newAnimation The animation to add
  33163. */
  33164. addAnimation(newAnimation: Animation): void;
  33165. /**
  33166. * Adds the given animation group to this scene.
  33167. * @param newAnimationGroup The animation group to add
  33168. */
  33169. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33170. /**
  33171. * Adds the given multi-material to this scene
  33172. * @param newMultiMaterial The multi-material to add
  33173. */
  33174. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33175. /**
  33176. * Adds the given material to this scene
  33177. * @param newMaterial The material to add
  33178. */
  33179. addMaterial(newMaterial: Material): void;
  33180. /**
  33181. * Adds the given morph target to this scene
  33182. * @param newMorphTargetManager The morph target to add
  33183. */
  33184. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33185. /**
  33186. * Adds the given geometry to this scene
  33187. * @param newGeometry The geometry to add
  33188. */
  33189. addGeometry(newGeometry: Geometry): void;
  33190. /**
  33191. * Adds the given action manager to this scene
  33192. * @param newActionManager The action manager to add
  33193. */
  33194. addActionManager(newActionManager: AbstractActionManager): void;
  33195. /**
  33196. * Adds the given texture to this scene.
  33197. * @param newTexture The texture to add
  33198. */
  33199. addTexture(newTexture: BaseTexture): void;
  33200. /**
  33201. * Switch active camera
  33202. * @param newCamera defines the new active camera
  33203. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33204. */
  33205. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33206. /**
  33207. * sets the active camera of the scene using its ID
  33208. * @param id defines the camera's ID
  33209. * @return the new active camera or null if none found.
  33210. */
  33211. setActiveCameraByID(id: string): Nullable<Camera>;
  33212. /**
  33213. * sets the active camera of the scene using its name
  33214. * @param name defines the camera's name
  33215. * @returns the new active camera or null if none found.
  33216. */
  33217. setActiveCameraByName(name: string): Nullable<Camera>;
  33218. /**
  33219. * get an animation group using its name
  33220. * @param name defines the material's name
  33221. * @return the animation group or null if none found.
  33222. */
  33223. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33224. /**
  33225. * Get a material using its unique id
  33226. * @param uniqueId defines the material's unique id
  33227. * @return the material or null if none found.
  33228. */
  33229. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33230. /**
  33231. * get a material using its id
  33232. * @param id defines the material's ID
  33233. * @return the material or null if none found.
  33234. */
  33235. getMaterialByID(id: string): Nullable<Material>;
  33236. /**
  33237. * Gets a material using its name
  33238. * @param name defines the material's name
  33239. * @return the material or null if none found.
  33240. */
  33241. getMaterialByName(name: string): Nullable<Material>;
  33242. /**
  33243. * Gets a camera using its id
  33244. * @param id defines the id to look for
  33245. * @returns the camera or null if not found
  33246. */
  33247. getCameraByID(id: string): Nullable<Camera>;
  33248. /**
  33249. * Gets a camera using its unique id
  33250. * @param uniqueId defines the unique id to look for
  33251. * @returns the camera or null if not found
  33252. */
  33253. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33254. /**
  33255. * Gets a camera using its name
  33256. * @param name defines the camera's name
  33257. * @return the camera or null if none found.
  33258. */
  33259. getCameraByName(name: string): Nullable<Camera>;
  33260. /**
  33261. * Gets a bone using its id
  33262. * @param id defines the bone's id
  33263. * @return the bone or null if not found
  33264. */
  33265. getBoneByID(id: string): Nullable<Bone>;
  33266. /**
  33267. * Gets a bone using its id
  33268. * @param name defines the bone's name
  33269. * @return the bone or null if not found
  33270. */
  33271. getBoneByName(name: string): Nullable<Bone>;
  33272. /**
  33273. * Gets a light node using its name
  33274. * @param name defines the the light's name
  33275. * @return the light or null if none found.
  33276. */
  33277. getLightByName(name: string): Nullable<Light>;
  33278. /**
  33279. * Gets a light node using its id
  33280. * @param id defines the light's id
  33281. * @return the light or null if none found.
  33282. */
  33283. getLightByID(id: string): Nullable<Light>;
  33284. /**
  33285. * Gets a light node using its scene-generated unique ID
  33286. * @param uniqueId defines the light's unique id
  33287. * @return the light or null if none found.
  33288. */
  33289. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33290. /**
  33291. * Gets a particle system by id
  33292. * @param id defines the particle system id
  33293. * @return the corresponding system or null if none found
  33294. */
  33295. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33296. /**
  33297. * Gets a geometry using its ID
  33298. * @param id defines the geometry's id
  33299. * @return the geometry or null if none found.
  33300. */
  33301. getGeometryByID(id: string): Nullable<Geometry>;
  33302. private _getGeometryByUniqueID;
  33303. /**
  33304. * Add a new geometry to this scene
  33305. * @param geometry defines the geometry to be added to the scene.
  33306. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33307. * @return a boolean defining if the geometry was added or not
  33308. */
  33309. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33310. /**
  33311. * Removes an existing geometry
  33312. * @param geometry defines the geometry to be removed from the scene
  33313. * @return a boolean defining if the geometry was removed or not
  33314. */
  33315. removeGeometry(geometry: Geometry): boolean;
  33316. /**
  33317. * Gets the list of geometries attached to the scene
  33318. * @returns an array of Geometry
  33319. */
  33320. getGeometries(): Geometry[];
  33321. /**
  33322. * Gets the first added mesh found of a given ID
  33323. * @param id defines the id to search for
  33324. * @return the mesh found or null if not found at all
  33325. */
  33326. getMeshByID(id: string): Nullable<AbstractMesh>;
  33327. /**
  33328. * Gets a list of meshes using their id
  33329. * @param id defines the id to search for
  33330. * @returns a list of meshes
  33331. */
  33332. getMeshesByID(id: string): Array<AbstractMesh>;
  33333. /**
  33334. * Gets the first added transform node found of a given ID
  33335. * @param id defines the id to search for
  33336. * @return the found transform node or null if not found at all.
  33337. */
  33338. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33339. /**
  33340. * Gets a transform node with its auto-generated unique id
  33341. * @param uniqueId efines the unique id to search for
  33342. * @return the found transform node or null if not found at all.
  33343. */
  33344. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33345. /**
  33346. * Gets a list of transform nodes using their id
  33347. * @param id defines the id to search for
  33348. * @returns a list of transform nodes
  33349. */
  33350. getTransformNodesByID(id: string): Array<TransformNode>;
  33351. /**
  33352. * Gets a mesh with its auto-generated unique id
  33353. * @param uniqueId defines the unique id to search for
  33354. * @return the found mesh or null if not found at all.
  33355. */
  33356. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33357. /**
  33358. * Gets a the last added mesh using a given id
  33359. * @param id defines the id to search for
  33360. * @return the found mesh or null if not found at all.
  33361. */
  33362. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33363. /**
  33364. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33365. * @param id defines the id to search for
  33366. * @return the found node or null if not found at all
  33367. */
  33368. getLastEntryByID(id: string): Nullable<Node>;
  33369. /**
  33370. * Gets a node (Mesh, Camera, Light) using a given id
  33371. * @param id defines the id to search for
  33372. * @return the found node or null if not found at all
  33373. */
  33374. getNodeByID(id: string): Nullable<Node>;
  33375. /**
  33376. * Gets a node (Mesh, Camera, Light) using a given name
  33377. * @param name defines the name to search for
  33378. * @return the found node or null if not found at all.
  33379. */
  33380. getNodeByName(name: string): Nullable<Node>;
  33381. /**
  33382. * Gets a mesh using a given name
  33383. * @param name defines the name to search for
  33384. * @return the found mesh or null if not found at all.
  33385. */
  33386. getMeshByName(name: string): Nullable<AbstractMesh>;
  33387. /**
  33388. * Gets a transform node using a given name
  33389. * @param name defines the name to search for
  33390. * @return the found transform node or null if not found at all.
  33391. */
  33392. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33393. /**
  33394. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33395. * @param id defines the id to search for
  33396. * @return the found skeleton or null if not found at all.
  33397. */
  33398. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33399. /**
  33400. * Gets a skeleton using a given auto generated unique id
  33401. * @param uniqueId defines the unique id to search for
  33402. * @return the found skeleton or null if not found at all.
  33403. */
  33404. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33405. /**
  33406. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33407. * @param id defines the id to search for
  33408. * @return the found skeleton or null if not found at all.
  33409. */
  33410. getSkeletonById(id: string): Nullable<Skeleton>;
  33411. /**
  33412. * Gets a skeleton using a given name
  33413. * @param name defines the name to search for
  33414. * @return the found skeleton or null if not found at all.
  33415. */
  33416. getSkeletonByName(name: string): Nullable<Skeleton>;
  33417. /**
  33418. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33419. * @param id defines the id to search for
  33420. * @return the found morph target manager or null if not found at all.
  33421. */
  33422. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33423. /**
  33424. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33425. * @param id defines the id to search for
  33426. * @return the found morph target or null if not found at all.
  33427. */
  33428. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33429. /**
  33430. * Gets a boolean indicating if the given mesh is active
  33431. * @param mesh defines the mesh to look for
  33432. * @returns true if the mesh is in the active list
  33433. */
  33434. isActiveMesh(mesh: AbstractMesh): boolean;
  33435. /**
  33436. * Return a unique id as a string which can serve as an identifier for the scene
  33437. */
  33438. readonly uid: string;
  33439. /**
  33440. * Add an externaly attached data from its key.
  33441. * This method call will fail and return false, if such key already exists.
  33442. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33443. * @param key the unique key that identifies the data
  33444. * @param data the data object to associate to the key for this Engine instance
  33445. * @return true if no such key were already present and the data was added successfully, false otherwise
  33446. */
  33447. addExternalData<T>(key: string, data: T): boolean;
  33448. /**
  33449. * Get an externaly attached data from its key
  33450. * @param key the unique key that identifies the data
  33451. * @return the associated data, if present (can be null), or undefined if not present
  33452. */
  33453. getExternalData<T>(key: string): Nullable<T>;
  33454. /**
  33455. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33456. * @param key the unique key that identifies the data
  33457. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33458. * @return the associated data, can be null if the factory returned null.
  33459. */
  33460. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33461. /**
  33462. * Remove an externaly attached data from the Engine instance
  33463. * @param key the unique key that identifies the data
  33464. * @return true if the data was successfully removed, false if it doesn't exist
  33465. */
  33466. removeExternalData(key: string): boolean;
  33467. private _evaluateSubMesh;
  33468. /**
  33469. * Clear the processed materials smart array preventing retention point in material dispose.
  33470. */
  33471. freeProcessedMaterials(): void;
  33472. private _preventFreeActiveMeshesAndRenderingGroups;
  33473. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33474. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33475. * when disposing several meshes in a row or a hierarchy of meshes.
  33476. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33477. */
  33478. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33479. /**
  33480. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33481. */
  33482. freeActiveMeshes(): void;
  33483. /**
  33484. * Clear the info related to rendering groups preventing retention points during dispose.
  33485. */
  33486. freeRenderingGroups(): void;
  33487. /** @hidden */
  33488. _isInIntermediateRendering(): boolean;
  33489. /**
  33490. * Lambda returning the list of potentially active meshes.
  33491. */
  33492. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33493. /**
  33494. * Lambda returning the list of potentially active sub meshes.
  33495. */
  33496. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33497. /**
  33498. * Lambda returning the list of potentially intersecting sub meshes.
  33499. */
  33500. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33501. /**
  33502. * Lambda returning the list of potentially colliding sub meshes.
  33503. */
  33504. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33505. private _activeMeshesFrozen;
  33506. /**
  33507. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33508. * @returns the current scene
  33509. */
  33510. freezeActiveMeshes(): Scene;
  33511. /**
  33512. * Use this function to restart evaluating active meshes on every frame
  33513. * @returns the current scene
  33514. */
  33515. unfreezeActiveMeshes(): Scene;
  33516. private _evaluateActiveMeshes;
  33517. private _activeMesh;
  33518. /**
  33519. * Update the transform matrix to update from the current active camera
  33520. * @param force defines a boolean used to force the update even if cache is up to date
  33521. */
  33522. updateTransformMatrix(force?: boolean): void;
  33523. private _bindFrameBuffer;
  33524. /** @hidden */
  33525. _allowPostProcessClearColor: boolean;
  33526. /** @hidden */
  33527. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33528. private _processSubCameras;
  33529. private _checkIntersections;
  33530. /** @hidden */
  33531. _advancePhysicsEngineStep(step: number): void;
  33532. /**
  33533. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33534. */
  33535. getDeterministicFrameTime: () => number;
  33536. /** @hidden */
  33537. _animate(): void;
  33538. /** Execute all animations (for a frame) */
  33539. animate(): void;
  33540. /**
  33541. * Render the scene
  33542. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33543. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33544. */
  33545. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33546. /**
  33547. * Freeze all materials
  33548. * A frozen material will not be updatable but should be faster to render
  33549. */
  33550. freezeMaterials(): void;
  33551. /**
  33552. * Unfreeze all materials
  33553. * A frozen material will not be updatable but should be faster to render
  33554. */
  33555. unfreezeMaterials(): void;
  33556. /**
  33557. * Releases all held ressources
  33558. */
  33559. dispose(): void;
  33560. /**
  33561. * Gets if the scene is already disposed
  33562. */
  33563. readonly isDisposed: boolean;
  33564. /**
  33565. * Call this function to reduce memory footprint of the scene.
  33566. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33567. */
  33568. clearCachedVertexData(): void;
  33569. /**
  33570. * This function will remove the local cached buffer data from texture.
  33571. * It will save memory but will prevent the texture from being rebuilt
  33572. */
  33573. cleanCachedTextureBuffer(): void;
  33574. /**
  33575. * Get the world extend vectors with an optional filter
  33576. *
  33577. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33578. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33579. */
  33580. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33581. min: Vector3;
  33582. max: Vector3;
  33583. };
  33584. /**
  33585. * Creates a ray that can be used to pick in the scene
  33586. * @param x defines the x coordinate of the origin (on-screen)
  33587. * @param y defines the y coordinate of the origin (on-screen)
  33588. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33589. * @param camera defines the camera to use for the picking
  33590. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33591. * @returns a Ray
  33592. */
  33593. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33594. /**
  33595. * Creates a ray that can be used to pick in the scene
  33596. * @param x defines the x coordinate of the origin (on-screen)
  33597. * @param y defines the y coordinate of the origin (on-screen)
  33598. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33599. * @param result defines the ray where to store the picking ray
  33600. * @param camera defines the camera to use for the picking
  33601. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33602. * @returns the current scene
  33603. */
  33604. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33605. /**
  33606. * Creates a ray that can be used to pick in the scene
  33607. * @param x defines the x coordinate of the origin (on-screen)
  33608. * @param y defines the y coordinate of the origin (on-screen)
  33609. * @param camera defines the camera to use for the picking
  33610. * @returns a Ray
  33611. */
  33612. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33613. /**
  33614. * Creates a ray that can be used to pick in the scene
  33615. * @param x defines the x coordinate of the origin (on-screen)
  33616. * @param y defines the y coordinate of the origin (on-screen)
  33617. * @param result defines the ray where to store the picking ray
  33618. * @param camera defines the camera to use for the picking
  33619. * @returns the current scene
  33620. */
  33621. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33622. /** Launch a ray to try to pick a mesh in the scene
  33623. * @param x position on screen
  33624. * @param y position on screen
  33625. * @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
  33626. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33627. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33628. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33629. * @returns a PickingInfo
  33630. */
  33631. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33632. /** Use the given ray to pick a mesh in the scene
  33633. * @param ray The ray to use to pick meshes
  33634. * @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
  33635. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33636. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33637. * @returns a PickingInfo
  33638. */
  33639. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33640. /**
  33641. * Launch a ray to try to pick a mesh in the scene
  33642. * @param x X position on screen
  33643. * @param y Y position on screen
  33644. * @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
  33645. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33646. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33647. * @returns an array of PickingInfo
  33648. */
  33649. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33650. /**
  33651. * Launch a ray to try to pick a mesh in the scene
  33652. * @param ray Ray to use
  33653. * @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
  33654. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33655. * @returns an array of PickingInfo
  33656. */
  33657. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33658. /**
  33659. * Force the value of meshUnderPointer
  33660. * @param mesh defines the mesh to use
  33661. */
  33662. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33663. /**
  33664. * Gets the mesh under the pointer
  33665. * @returns a Mesh or null if no mesh is under the pointer
  33666. */
  33667. getPointerOverMesh(): Nullable<AbstractMesh>;
  33668. /** @hidden */
  33669. _rebuildGeometries(): void;
  33670. /** @hidden */
  33671. _rebuildTextures(): void;
  33672. private _getByTags;
  33673. /**
  33674. * Get a list of meshes by tags
  33675. * @param tagsQuery defines the tags query to use
  33676. * @param forEach defines a predicate used to filter results
  33677. * @returns an array of Mesh
  33678. */
  33679. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33680. /**
  33681. * Get a list of cameras by tags
  33682. * @param tagsQuery defines the tags query to use
  33683. * @param forEach defines a predicate used to filter results
  33684. * @returns an array of Camera
  33685. */
  33686. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33687. /**
  33688. * Get a list of lights by tags
  33689. * @param tagsQuery defines the tags query to use
  33690. * @param forEach defines a predicate used to filter results
  33691. * @returns an array of Light
  33692. */
  33693. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33694. /**
  33695. * Get a list of materials by tags
  33696. * @param tagsQuery defines the tags query to use
  33697. * @param forEach defines a predicate used to filter results
  33698. * @returns an array of Material
  33699. */
  33700. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33701. /**
  33702. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33703. * This allowed control for front to back rendering or reversly depending of the special needs.
  33704. *
  33705. * @param renderingGroupId The rendering group id corresponding to its index
  33706. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33707. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33708. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33709. */
  33710. 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;
  33711. /**
  33712. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33713. *
  33714. * @param renderingGroupId The rendering group id corresponding to its index
  33715. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33716. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33717. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33718. */
  33719. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33720. /**
  33721. * Gets the current auto clear configuration for one rendering group of the rendering
  33722. * manager.
  33723. * @param index the rendering group index to get the information for
  33724. * @returns The auto clear setup for the requested rendering group
  33725. */
  33726. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33727. private _blockMaterialDirtyMechanism;
  33728. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33729. blockMaterialDirtyMechanism: boolean;
  33730. /**
  33731. * Will flag all materials as dirty to trigger new shader compilation
  33732. * @param flag defines the flag used to specify which material part must be marked as dirty
  33733. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33734. */
  33735. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33736. /** @hidden */
  33737. _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;
  33738. /** @hidden */
  33739. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33740. }
  33741. }
  33742. declare module BABYLON {
  33743. /**
  33744. * Set of assets to keep when moving a scene into an asset container.
  33745. */
  33746. export class KeepAssets extends AbstractScene {
  33747. }
  33748. /**
  33749. * Container with a set of assets that can be added or removed from a scene.
  33750. */
  33751. export class AssetContainer extends AbstractScene {
  33752. /**
  33753. * The scene the AssetContainer belongs to.
  33754. */
  33755. scene: Scene;
  33756. /**
  33757. * Instantiates an AssetContainer.
  33758. * @param scene The scene the AssetContainer belongs to.
  33759. */
  33760. constructor(scene: Scene);
  33761. /**
  33762. * Adds all the assets from the container to the scene.
  33763. */
  33764. addAllToScene(): void;
  33765. /**
  33766. * Removes all the assets in the container from the scene
  33767. */
  33768. removeAllFromScene(): void;
  33769. /**
  33770. * Disposes all the assets in the container
  33771. */
  33772. dispose(): void;
  33773. private _moveAssets;
  33774. /**
  33775. * Removes all the assets contained in the scene and adds them to the container.
  33776. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33777. */
  33778. moveAllFromScene(keepAssets?: KeepAssets): void;
  33779. /**
  33780. * 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.
  33781. * @returns the root mesh
  33782. */
  33783. createRootMesh(): Mesh;
  33784. }
  33785. }
  33786. declare module BABYLON {
  33787. /**
  33788. * Defines how the parser contract is defined.
  33789. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33790. */
  33791. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33792. /**
  33793. * Defines how the individual parser contract is defined.
  33794. * These parser can parse an individual asset
  33795. */
  33796. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33797. /**
  33798. * Base class of the scene acting as a container for the different elements composing a scene.
  33799. * This class is dynamically extended by the different components of the scene increasing
  33800. * flexibility and reducing coupling
  33801. */
  33802. export abstract class AbstractScene {
  33803. /**
  33804. * Stores the list of available parsers in the application.
  33805. */
  33806. private static _BabylonFileParsers;
  33807. /**
  33808. * Stores the list of available individual parsers in the application.
  33809. */
  33810. private static _IndividualBabylonFileParsers;
  33811. /**
  33812. * Adds a parser in the list of available ones
  33813. * @param name Defines the name of the parser
  33814. * @param parser Defines the parser to add
  33815. */
  33816. static AddParser(name: string, parser: BabylonFileParser): void;
  33817. /**
  33818. * Gets a general parser from the list of avaialble ones
  33819. * @param name Defines the name of the parser
  33820. * @returns the requested parser or null
  33821. */
  33822. static GetParser(name: string): Nullable<BabylonFileParser>;
  33823. /**
  33824. * Adds n individual parser in the list of available ones
  33825. * @param name Defines the name of the parser
  33826. * @param parser Defines the parser to add
  33827. */
  33828. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33829. /**
  33830. * Gets an individual parser from the list of avaialble ones
  33831. * @param name Defines the name of the parser
  33832. * @returns the requested parser or null
  33833. */
  33834. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33835. /**
  33836. * Parser json data and populate both a scene and its associated container object
  33837. * @param jsonData Defines the data to parse
  33838. * @param scene Defines the scene to parse the data for
  33839. * @param container Defines the container attached to the parsing sequence
  33840. * @param rootUrl Defines the root url of the data
  33841. */
  33842. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33843. /**
  33844. * Gets the list of root nodes (ie. nodes with no parent)
  33845. */
  33846. rootNodes: Node[];
  33847. /** All of the cameras added to this scene
  33848. * @see http://doc.babylonjs.com/babylon101/cameras
  33849. */
  33850. cameras: Camera[];
  33851. /**
  33852. * All of the lights added to this scene
  33853. * @see http://doc.babylonjs.com/babylon101/lights
  33854. */
  33855. lights: Light[];
  33856. /**
  33857. * All of the (abstract) meshes added to this scene
  33858. */
  33859. meshes: AbstractMesh[];
  33860. /**
  33861. * The list of skeletons added to the scene
  33862. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33863. */
  33864. skeletons: Skeleton[];
  33865. /**
  33866. * All of the particle systems added to this scene
  33867. * @see http://doc.babylonjs.com/babylon101/particles
  33868. */
  33869. particleSystems: IParticleSystem[];
  33870. /**
  33871. * Gets a list of Animations associated with the scene
  33872. */
  33873. animations: Animation[];
  33874. /**
  33875. * All of the animation groups added to this scene
  33876. * @see http://doc.babylonjs.com/how_to/group
  33877. */
  33878. animationGroups: AnimationGroup[];
  33879. /**
  33880. * All of the multi-materials added to this scene
  33881. * @see http://doc.babylonjs.com/how_to/multi_materials
  33882. */
  33883. multiMaterials: MultiMaterial[];
  33884. /**
  33885. * All of the materials added to this scene
  33886. * In the context of a Scene, it is not supposed to be modified manually.
  33887. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33888. * Note also that the order of the Material wihin the array is not significant and might change.
  33889. * @see http://doc.babylonjs.com/babylon101/materials
  33890. */
  33891. materials: Material[];
  33892. /**
  33893. * The list of morph target managers added to the scene
  33894. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33895. */
  33896. morphTargetManagers: MorphTargetManager[];
  33897. /**
  33898. * The list of geometries used in the scene.
  33899. */
  33900. geometries: Geometry[];
  33901. /**
  33902. * All of the tranform nodes added to this scene
  33903. * In the context of a Scene, it is not supposed to be modified manually.
  33904. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33905. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33906. * @see http://doc.babylonjs.com/how_to/transformnode
  33907. */
  33908. transformNodes: TransformNode[];
  33909. /**
  33910. * ActionManagers available on the scene.
  33911. */
  33912. actionManagers: AbstractActionManager[];
  33913. /**
  33914. * Textures to keep.
  33915. */
  33916. textures: BaseTexture[];
  33917. /**
  33918. * Environment texture for the scene
  33919. */
  33920. environmentTexture: Nullable<BaseTexture>;
  33921. }
  33922. }
  33923. declare module BABYLON {
  33924. /**
  33925. * Defines a sound that can be played in the application.
  33926. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33928. */
  33929. export class Sound {
  33930. /**
  33931. * The name of the sound in the scene.
  33932. */
  33933. name: string;
  33934. /**
  33935. * Does the sound autoplay once loaded.
  33936. */
  33937. autoplay: boolean;
  33938. /**
  33939. * Does the sound loop after it finishes playing once.
  33940. */
  33941. loop: boolean;
  33942. /**
  33943. * Does the sound use a custom attenuation curve to simulate the falloff
  33944. * happening when the source gets further away from the camera.
  33945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33946. */
  33947. useCustomAttenuation: boolean;
  33948. /**
  33949. * The sound track id this sound belongs to.
  33950. */
  33951. soundTrackId: number;
  33952. /**
  33953. * Is this sound currently played.
  33954. */
  33955. isPlaying: boolean;
  33956. /**
  33957. * Is this sound currently paused.
  33958. */
  33959. isPaused: boolean;
  33960. /**
  33961. * Does this sound enables spatial sound.
  33962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33963. */
  33964. spatialSound: boolean;
  33965. /**
  33966. * Define the reference distance the sound should be heard perfectly.
  33967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33968. */
  33969. refDistance: number;
  33970. /**
  33971. * Define the roll off factor of spatial sounds.
  33972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33973. */
  33974. rolloffFactor: number;
  33975. /**
  33976. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33978. */
  33979. maxDistance: number;
  33980. /**
  33981. * Define the distance attenuation model the sound will follow.
  33982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33983. */
  33984. distanceModel: string;
  33985. /**
  33986. * @hidden
  33987. * Back Compat
  33988. **/
  33989. onended: () => any;
  33990. /**
  33991. * Observable event when the current playing sound finishes.
  33992. */
  33993. onEndedObservable: Observable<Sound>;
  33994. private _panningModel;
  33995. private _playbackRate;
  33996. private _streaming;
  33997. private _startTime;
  33998. private _startOffset;
  33999. private _position;
  34000. /** @hidden */
  34001. _positionInEmitterSpace: boolean;
  34002. private _localDirection;
  34003. private _volume;
  34004. private _isReadyToPlay;
  34005. private _isDirectional;
  34006. private _readyToPlayCallback;
  34007. private _audioBuffer;
  34008. private _soundSource;
  34009. private _streamingSource;
  34010. private _soundPanner;
  34011. private _soundGain;
  34012. private _inputAudioNode;
  34013. private _outputAudioNode;
  34014. private _coneInnerAngle;
  34015. private _coneOuterAngle;
  34016. private _coneOuterGain;
  34017. private _scene;
  34018. private _connectedTransformNode;
  34019. private _customAttenuationFunction;
  34020. private _registerFunc;
  34021. private _isOutputConnected;
  34022. private _htmlAudioElement;
  34023. private _urlType;
  34024. /** @hidden */
  34025. static _SceneComponentInitialization: (scene: Scene) => void;
  34026. /**
  34027. * Create a sound and attach it to a scene
  34028. * @param name Name of your sound
  34029. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34030. * @param scene defines the scene the sound belongs to
  34031. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34032. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34033. */
  34034. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34035. /**
  34036. * Release the sound and its associated resources
  34037. */
  34038. dispose(): void;
  34039. /**
  34040. * Gets if the sounds is ready to be played or not.
  34041. * @returns true if ready, otherwise false
  34042. */
  34043. isReady(): boolean;
  34044. private _soundLoaded;
  34045. /**
  34046. * Sets the data of the sound from an audiobuffer
  34047. * @param audioBuffer The audioBuffer containing the data
  34048. */
  34049. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34050. /**
  34051. * Updates the current sounds options such as maxdistance, loop...
  34052. * @param options A JSON object containing values named as the object properties
  34053. */
  34054. updateOptions(options: any): void;
  34055. private _createSpatialParameters;
  34056. private _updateSpatialParameters;
  34057. /**
  34058. * Switch the panning model to HRTF:
  34059. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34061. */
  34062. switchPanningModelToHRTF(): void;
  34063. /**
  34064. * Switch the panning model to Equal Power:
  34065. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34067. */
  34068. switchPanningModelToEqualPower(): void;
  34069. private _switchPanningModel;
  34070. /**
  34071. * Connect this sound to a sound track audio node like gain...
  34072. * @param soundTrackAudioNode the sound track audio node to connect to
  34073. */
  34074. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34075. /**
  34076. * Transform this sound into a directional source
  34077. * @param coneInnerAngle Size of the inner cone in degree
  34078. * @param coneOuterAngle Size of the outer cone in degree
  34079. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34080. */
  34081. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34082. /**
  34083. * Gets or sets the inner angle for the directional cone.
  34084. */
  34085. /**
  34086. * Gets or sets the inner angle for the directional cone.
  34087. */
  34088. directionalConeInnerAngle: number;
  34089. /**
  34090. * Gets or sets the outer angle for the directional cone.
  34091. */
  34092. /**
  34093. * Gets or sets the outer angle for the directional cone.
  34094. */
  34095. directionalConeOuterAngle: number;
  34096. /**
  34097. * Sets the position of the emitter if spatial sound is enabled
  34098. * @param newPosition Defines the new posisiton
  34099. */
  34100. setPosition(newPosition: Vector3): void;
  34101. /**
  34102. * Sets the local direction of the emitter if spatial sound is enabled
  34103. * @param newLocalDirection Defines the new local direction
  34104. */
  34105. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34106. private _updateDirection;
  34107. /** @hidden */
  34108. updateDistanceFromListener(): void;
  34109. /**
  34110. * Sets a new custom attenuation function for the sound.
  34111. * @param callback Defines the function used for the attenuation
  34112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34113. */
  34114. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34115. /**
  34116. * Play the sound
  34117. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34118. * @param offset (optional) Start the sound setting it at a specific time
  34119. */
  34120. play(time?: number, offset?: number): void;
  34121. private _onended;
  34122. /**
  34123. * Stop the sound
  34124. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34125. */
  34126. stop(time?: number): void;
  34127. /**
  34128. * Put the sound in pause
  34129. */
  34130. pause(): void;
  34131. /**
  34132. * Sets a dedicated volume for this sounds
  34133. * @param newVolume Define the new volume of the sound
  34134. * @param time Define in how long the sound should be at this value
  34135. */
  34136. setVolume(newVolume: number, time?: number): void;
  34137. /**
  34138. * Set the sound play back rate
  34139. * @param newPlaybackRate Define the playback rate the sound should be played at
  34140. */
  34141. setPlaybackRate(newPlaybackRate: number): void;
  34142. /**
  34143. * Gets the volume of the sound.
  34144. * @returns the volume of the sound
  34145. */
  34146. getVolume(): number;
  34147. /**
  34148. * Attach the sound to a dedicated mesh
  34149. * @param transformNode The transform node to connect the sound with
  34150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34151. */
  34152. attachToMesh(transformNode: TransformNode): void;
  34153. /**
  34154. * Detach the sound from the previously attached mesh
  34155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34156. */
  34157. detachFromMesh(): void;
  34158. private _onRegisterAfterWorldMatrixUpdate;
  34159. /**
  34160. * Clone the current sound in the scene.
  34161. * @returns the new sound clone
  34162. */
  34163. clone(): Nullable<Sound>;
  34164. /**
  34165. * Gets the current underlying audio buffer containing the data
  34166. * @returns the audio buffer
  34167. */
  34168. getAudioBuffer(): Nullable<AudioBuffer>;
  34169. /**
  34170. * Serializes the Sound in a JSON representation
  34171. * @returns the JSON representation of the sound
  34172. */
  34173. serialize(): any;
  34174. /**
  34175. * Parse a JSON representation of a sound to innstantiate in a given scene
  34176. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34177. * @param scene Define the scene the new parsed sound should be created in
  34178. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34179. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34180. * @returns the newly parsed sound
  34181. */
  34182. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34183. }
  34184. }
  34185. declare module BABYLON {
  34186. /**
  34187. * This defines an action helpful to play a defined sound on a triggered action.
  34188. */
  34189. export class PlaySoundAction extends Action {
  34190. private _sound;
  34191. /**
  34192. * Instantiate the action
  34193. * @param triggerOptions defines the trigger options
  34194. * @param sound defines the sound to play
  34195. * @param condition defines the trigger related conditions
  34196. */
  34197. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34198. /** @hidden */
  34199. _prepare(): void;
  34200. /**
  34201. * Execute the action and play the sound.
  34202. */
  34203. execute(): void;
  34204. /**
  34205. * Serializes the actions and its related information.
  34206. * @param parent defines the object to serialize in
  34207. * @returns the serialized object
  34208. */
  34209. serialize(parent: any): any;
  34210. }
  34211. /**
  34212. * This defines an action helpful to stop a defined sound on a triggered action.
  34213. */
  34214. export class StopSoundAction extends Action {
  34215. private _sound;
  34216. /**
  34217. * Instantiate the action
  34218. * @param triggerOptions defines the trigger options
  34219. * @param sound defines the sound to stop
  34220. * @param condition defines the trigger related conditions
  34221. */
  34222. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34223. /** @hidden */
  34224. _prepare(): void;
  34225. /**
  34226. * Execute the action and stop the sound.
  34227. */
  34228. execute(): void;
  34229. /**
  34230. * Serializes the actions and its related information.
  34231. * @param parent defines the object to serialize in
  34232. * @returns the serialized object
  34233. */
  34234. serialize(parent: any): any;
  34235. }
  34236. }
  34237. declare module BABYLON {
  34238. /**
  34239. * This defines an action responsible to change the value of a property
  34240. * by interpolating between its current value and the newly set one once triggered.
  34241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34242. */
  34243. export class InterpolateValueAction extends Action {
  34244. /**
  34245. * Defines the path of the property where the value should be interpolated
  34246. */
  34247. propertyPath: string;
  34248. /**
  34249. * Defines the target value at the end of the interpolation.
  34250. */
  34251. value: any;
  34252. /**
  34253. * Defines the time it will take for the property to interpolate to the value.
  34254. */
  34255. duration: number;
  34256. /**
  34257. * Defines if the other scene animations should be stopped when the action has been triggered
  34258. */
  34259. stopOtherAnimations?: boolean;
  34260. /**
  34261. * Defines a callback raised once the interpolation animation has been done.
  34262. */
  34263. onInterpolationDone?: () => void;
  34264. /**
  34265. * Observable triggered once the interpolation animation has been done.
  34266. */
  34267. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34268. private _target;
  34269. private _effectiveTarget;
  34270. private _property;
  34271. /**
  34272. * Instantiate the action
  34273. * @param triggerOptions defines the trigger options
  34274. * @param target defines the object containing the value to interpolate
  34275. * @param propertyPath defines the path to the property in the target object
  34276. * @param value defines the target value at the end of the interpolation
  34277. * @param duration deines the time it will take for the property to interpolate to the value.
  34278. * @param condition defines the trigger related conditions
  34279. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34280. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34281. */
  34282. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34283. /** @hidden */
  34284. _prepare(): void;
  34285. /**
  34286. * Execute the action starts the value interpolation.
  34287. */
  34288. execute(): void;
  34289. /**
  34290. * Serializes the actions and its related information.
  34291. * @param parent defines the object to serialize in
  34292. * @returns the serialized object
  34293. */
  34294. serialize(parent: any): any;
  34295. }
  34296. }
  34297. declare module BABYLON {
  34298. /**
  34299. * Options allowed during the creation of a sound track.
  34300. */
  34301. export interface ISoundTrackOptions {
  34302. /**
  34303. * The volume the sound track should take during creation
  34304. */
  34305. volume?: number;
  34306. /**
  34307. * Define if the sound track is the main sound track of the scene
  34308. */
  34309. mainTrack?: boolean;
  34310. }
  34311. /**
  34312. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34313. * It will be also used in a future release to apply effects on a specific track.
  34314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34315. */
  34316. export class SoundTrack {
  34317. /**
  34318. * The unique identifier of the sound track in the scene.
  34319. */
  34320. id: number;
  34321. /**
  34322. * The list of sounds included in the sound track.
  34323. */
  34324. soundCollection: Array<Sound>;
  34325. private _outputAudioNode;
  34326. private _scene;
  34327. private _isMainTrack;
  34328. private _connectedAnalyser;
  34329. private _options;
  34330. private _isInitialized;
  34331. /**
  34332. * Creates a new sound track.
  34333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34334. * @param scene Define the scene the sound track belongs to
  34335. * @param options
  34336. */
  34337. constructor(scene: Scene, options?: ISoundTrackOptions);
  34338. private _initializeSoundTrackAudioGraph;
  34339. /**
  34340. * Release the sound track and its associated resources
  34341. */
  34342. dispose(): void;
  34343. /**
  34344. * Adds a sound to this sound track
  34345. * @param sound define the cound to add
  34346. * @ignoreNaming
  34347. */
  34348. AddSound(sound: Sound): void;
  34349. /**
  34350. * Removes a sound to this sound track
  34351. * @param sound define the cound to remove
  34352. * @ignoreNaming
  34353. */
  34354. RemoveSound(sound: Sound): void;
  34355. /**
  34356. * Set a global volume for the full sound track.
  34357. * @param newVolume Define the new volume of the sound track
  34358. */
  34359. setVolume(newVolume: number): void;
  34360. /**
  34361. * Switch the panning model to HRTF:
  34362. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34364. */
  34365. switchPanningModelToHRTF(): void;
  34366. /**
  34367. * Switch the panning model to Equal Power:
  34368. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34370. */
  34371. switchPanningModelToEqualPower(): void;
  34372. /**
  34373. * Connect the sound track to an audio analyser allowing some amazing
  34374. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34376. * @param analyser The analyser to connect to the engine
  34377. */
  34378. connectToAnalyser(analyser: Analyser): void;
  34379. }
  34380. }
  34381. declare module BABYLON {
  34382. interface AbstractScene {
  34383. /**
  34384. * The list of sounds used in the scene.
  34385. */
  34386. sounds: Nullable<Array<Sound>>;
  34387. }
  34388. interface Scene {
  34389. /**
  34390. * @hidden
  34391. * Backing field
  34392. */
  34393. _mainSoundTrack: SoundTrack;
  34394. /**
  34395. * The main sound track played by the scene.
  34396. * It cotains your primary collection of sounds.
  34397. */
  34398. mainSoundTrack: SoundTrack;
  34399. /**
  34400. * The list of sound tracks added to the scene
  34401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34402. */
  34403. soundTracks: Nullable<Array<SoundTrack>>;
  34404. /**
  34405. * Gets a sound using a given name
  34406. * @param name defines the name to search for
  34407. * @return the found sound or null if not found at all.
  34408. */
  34409. getSoundByName(name: string): Nullable<Sound>;
  34410. /**
  34411. * Gets or sets if audio support is enabled
  34412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34413. */
  34414. audioEnabled: boolean;
  34415. /**
  34416. * Gets or sets if audio will be output to headphones
  34417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34418. */
  34419. headphone: boolean;
  34420. }
  34421. /**
  34422. * Defines the sound scene component responsible to manage any sounds
  34423. * in a given scene.
  34424. */
  34425. export class AudioSceneComponent implements ISceneSerializableComponent {
  34426. /**
  34427. * The component name helpfull to identify the component in the list of scene components.
  34428. */
  34429. readonly name: string;
  34430. /**
  34431. * The scene the component belongs to.
  34432. */
  34433. scene: Scene;
  34434. private _audioEnabled;
  34435. /**
  34436. * Gets whether audio is enabled or not.
  34437. * Please use related enable/disable method to switch state.
  34438. */
  34439. readonly audioEnabled: boolean;
  34440. private _headphone;
  34441. /**
  34442. * Gets whether audio is outputing to headphone or not.
  34443. * Please use the according Switch methods to change output.
  34444. */
  34445. readonly headphone: boolean;
  34446. /**
  34447. * Creates a new instance of the component for the given scene
  34448. * @param scene Defines the scene to register the component in
  34449. */
  34450. constructor(scene: Scene);
  34451. /**
  34452. * Registers the component in a given scene
  34453. */
  34454. register(): void;
  34455. /**
  34456. * Rebuilds the elements related to this component in case of
  34457. * context lost for instance.
  34458. */
  34459. rebuild(): void;
  34460. /**
  34461. * Serializes the component data to the specified json object
  34462. * @param serializationObject The object to serialize to
  34463. */
  34464. serialize(serializationObject: any): void;
  34465. /**
  34466. * Adds all the element from the container to the scene
  34467. * @param container the container holding the elements
  34468. */
  34469. addFromContainer(container: AbstractScene): void;
  34470. /**
  34471. * Removes all the elements in the container from the scene
  34472. * @param container contains the elements to remove
  34473. * @param dispose if the removed element should be disposed (default: false)
  34474. */
  34475. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34476. /**
  34477. * Disposes the component and the associated ressources.
  34478. */
  34479. dispose(): void;
  34480. /**
  34481. * Disables audio in the associated scene.
  34482. */
  34483. disableAudio(): void;
  34484. /**
  34485. * Enables audio in the associated scene.
  34486. */
  34487. enableAudio(): void;
  34488. /**
  34489. * Switch audio to headphone output.
  34490. */
  34491. switchAudioModeForHeadphones(): void;
  34492. /**
  34493. * Switch audio to normal speakers.
  34494. */
  34495. switchAudioModeForNormalSpeakers(): void;
  34496. private _afterRender;
  34497. }
  34498. }
  34499. declare module BABYLON {
  34500. /**
  34501. * Wraps one or more Sound objects and selects one with random weight for playback.
  34502. */
  34503. export class WeightedSound {
  34504. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34505. loop: boolean;
  34506. private _coneInnerAngle;
  34507. private _coneOuterAngle;
  34508. private _volume;
  34509. /** A Sound is currently playing. */
  34510. isPlaying: boolean;
  34511. /** A Sound is currently paused. */
  34512. isPaused: boolean;
  34513. private _sounds;
  34514. private _weights;
  34515. private _currentIndex?;
  34516. /**
  34517. * Creates a new WeightedSound from the list of sounds given.
  34518. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34519. * @param sounds Array of Sounds that will be selected from.
  34520. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34521. */
  34522. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34523. /**
  34524. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34525. */
  34526. /**
  34527. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34528. */
  34529. directionalConeInnerAngle: number;
  34530. /**
  34531. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34532. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34533. */
  34534. /**
  34535. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34536. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34537. */
  34538. directionalConeOuterAngle: number;
  34539. /**
  34540. * Playback volume.
  34541. */
  34542. /**
  34543. * Playback volume.
  34544. */
  34545. volume: number;
  34546. private _onended;
  34547. /**
  34548. * Suspend playback
  34549. */
  34550. pause(): void;
  34551. /**
  34552. * Stop playback
  34553. */
  34554. stop(): void;
  34555. /**
  34556. * Start playback.
  34557. * @param startOffset Position the clip head at a specific time in seconds.
  34558. */
  34559. play(startOffset?: number): void;
  34560. }
  34561. }
  34562. declare module BABYLON {
  34563. /**
  34564. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34565. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34566. */
  34567. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34568. /**
  34569. * Gets the name of the behavior.
  34570. */
  34571. readonly name: string;
  34572. /**
  34573. * The easing function used by animations
  34574. */
  34575. static EasingFunction: BackEase;
  34576. /**
  34577. * The easing mode used by animations
  34578. */
  34579. static EasingMode: number;
  34580. /**
  34581. * The duration of the animation, in milliseconds
  34582. */
  34583. transitionDuration: number;
  34584. /**
  34585. * Length of the distance animated by the transition when lower radius is reached
  34586. */
  34587. lowerRadiusTransitionRange: number;
  34588. /**
  34589. * Length of the distance animated by the transition when upper radius is reached
  34590. */
  34591. upperRadiusTransitionRange: number;
  34592. private _autoTransitionRange;
  34593. /**
  34594. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34595. */
  34596. /**
  34597. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34598. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34599. */
  34600. autoTransitionRange: boolean;
  34601. private _attachedCamera;
  34602. private _onAfterCheckInputsObserver;
  34603. private _onMeshTargetChangedObserver;
  34604. /**
  34605. * Initializes the behavior.
  34606. */
  34607. init(): void;
  34608. /**
  34609. * Attaches the behavior to its arc rotate camera.
  34610. * @param camera Defines the camera to attach the behavior to
  34611. */
  34612. attach(camera: ArcRotateCamera): void;
  34613. /**
  34614. * Detaches the behavior from its current arc rotate camera.
  34615. */
  34616. detach(): void;
  34617. private _radiusIsAnimating;
  34618. private _radiusBounceTransition;
  34619. private _animatables;
  34620. private _cachedWheelPrecision;
  34621. /**
  34622. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34623. * @param radiusLimit The limit to check against.
  34624. * @return Bool to indicate if at limit.
  34625. */
  34626. private _isRadiusAtLimit;
  34627. /**
  34628. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34629. * @param radiusDelta The delta by which to animate to. Can be negative.
  34630. */
  34631. private _applyBoundRadiusAnimation;
  34632. /**
  34633. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34634. */
  34635. protected _clearAnimationLocks(): void;
  34636. /**
  34637. * Stops and removes all animations that have been applied to the camera
  34638. */
  34639. stopAllAnimations(): void;
  34640. }
  34641. }
  34642. declare module BABYLON {
  34643. /**
  34644. * 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.
  34645. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34646. */
  34647. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34648. /**
  34649. * Gets the name of the behavior.
  34650. */
  34651. readonly name: string;
  34652. private _mode;
  34653. private _radiusScale;
  34654. private _positionScale;
  34655. private _defaultElevation;
  34656. private _elevationReturnTime;
  34657. private _elevationReturnWaitTime;
  34658. private _zoomStopsAnimation;
  34659. private _framingTime;
  34660. /**
  34661. * The easing function used by animations
  34662. */
  34663. static EasingFunction: ExponentialEase;
  34664. /**
  34665. * The easing mode used by animations
  34666. */
  34667. static EasingMode: number;
  34668. /**
  34669. * Sets the current mode used by the behavior
  34670. */
  34671. /**
  34672. * Gets current mode used by the behavior.
  34673. */
  34674. mode: number;
  34675. /**
  34676. * Sets the scale applied to the radius (1 by default)
  34677. */
  34678. /**
  34679. * Gets the scale applied to the radius
  34680. */
  34681. radiusScale: number;
  34682. /**
  34683. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34684. */
  34685. /**
  34686. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34687. */
  34688. positionScale: number;
  34689. /**
  34690. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34691. * behaviour is triggered, in radians.
  34692. */
  34693. /**
  34694. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34695. * behaviour is triggered, in radians.
  34696. */
  34697. defaultElevation: number;
  34698. /**
  34699. * Sets the time (in milliseconds) taken to return to the default beta position.
  34700. * Negative value indicates camera should not return to default.
  34701. */
  34702. /**
  34703. * Gets the time (in milliseconds) taken to return to the default beta position.
  34704. * Negative value indicates camera should not return to default.
  34705. */
  34706. elevationReturnTime: number;
  34707. /**
  34708. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34709. */
  34710. /**
  34711. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34712. */
  34713. elevationReturnWaitTime: number;
  34714. /**
  34715. * Sets the flag that indicates if user zooming should stop animation.
  34716. */
  34717. /**
  34718. * Gets the flag that indicates if user zooming should stop animation.
  34719. */
  34720. zoomStopsAnimation: boolean;
  34721. /**
  34722. * Sets the transition time when framing the mesh, in milliseconds
  34723. */
  34724. /**
  34725. * Gets the transition time when framing the mesh, in milliseconds
  34726. */
  34727. framingTime: number;
  34728. /**
  34729. * Define if the behavior should automatically change the configured
  34730. * camera limits and sensibilities.
  34731. */
  34732. autoCorrectCameraLimitsAndSensibility: boolean;
  34733. private _onPrePointerObservableObserver;
  34734. private _onAfterCheckInputsObserver;
  34735. private _onMeshTargetChangedObserver;
  34736. private _attachedCamera;
  34737. private _isPointerDown;
  34738. private _lastInteractionTime;
  34739. /**
  34740. * Initializes the behavior.
  34741. */
  34742. init(): void;
  34743. /**
  34744. * Attaches the behavior to its arc rotate camera.
  34745. * @param camera Defines the camera to attach the behavior to
  34746. */
  34747. attach(camera: ArcRotateCamera): void;
  34748. /**
  34749. * Detaches the behavior from its current arc rotate camera.
  34750. */
  34751. detach(): void;
  34752. private _animatables;
  34753. private _betaIsAnimating;
  34754. private _betaTransition;
  34755. private _radiusTransition;
  34756. private _vectorTransition;
  34757. /**
  34758. * Targets the given mesh and updates zoom level accordingly.
  34759. * @param mesh The mesh to target.
  34760. * @param radius Optional. If a cached radius position already exists, overrides default.
  34761. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34762. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34763. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34764. */
  34765. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34766. /**
  34767. * Targets the given mesh with its children and updates zoom level accordingly.
  34768. * @param mesh The mesh to target.
  34769. * @param radius Optional. If a cached radius position already exists, overrides default.
  34770. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34771. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34772. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34773. */
  34774. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34775. /**
  34776. * Targets the given meshes with their children and updates zoom level accordingly.
  34777. * @param meshes The mesh to target.
  34778. * @param radius Optional. If a cached radius position already exists, overrides default.
  34779. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34780. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34781. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34782. */
  34783. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34784. /**
  34785. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34786. * @param minimumWorld Determines the smaller position of the bounding box extend
  34787. * @param maximumWorld Determines the bigger position of the bounding box extend
  34788. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34789. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34790. */
  34791. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34792. /**
  34793. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34794. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34795. * frustum width.
  34796. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34797. * to fully enclose the mesh in the viewing frustum.
  34798. */
  34799. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34800. /**
  34801. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34802. * is automatically returned to its default position (expected to be above ground plane).
  34803. */
  34804. private _maintainCameraAboveGround;
  34805. /**
  34806. * Returns the frustum slope based on the canvas ratio and camera FOV
  34807. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34808. */
  34809. private _getFrustumSlope;
  34810. /**
  34811. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34812. */
  34813. private _clearAnimationLocks;
  34814. /**
  34815. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34816. */
  34817. private _applyUserInteraction;
  34818. /**
  34819. * Stops and removes all animations that have been applied to the camera
  34820. */
  34821. stopAllAnimations(): void;
  34822. /**
  34823. * Gets a value indicating if the user is moving the camera
  34824. */
  34825. readonly isUserIsMoving: boolean;
  34826. /**
  34827. * The camera can move all the way towards the mesh.
  34828. */
  34829. static IgnoreBoundsSizeMode: number;
  34830. /**
  34831. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34832. */
  34833. static FitFrustumSidesMode: number;
  34834. }
  34835. }
  34836. declare module BABYLON {
  34837. /**
  34838. * Base class for Camera Pointer Inputs.
  34839. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34840. * for example usage.
  34841. */
  34842. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34843. /**
  34844. * Defines the camera the input is attached to.
  34845. */
  34846. abstract camera: Camera;
  34847. /**
  34848. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34849. */
  34850. protected _altKey: boolean;
  34851. protected _ctrlKey: boolean;
  34852. protected _metaKey: boolean;
  34853. protected _shiftKey: boolean;
  34854. /**
  34855. * Which mouse buttons were pressed at time of last mouse event.
  34856. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34857. */
  34858. protected _buttonsPressed: number;
  34859. /**
  34860. * Defines the buttons associated with the input to handle camera move.
  34861. */
  34862. buttons: number[];
  34863. /**
  34864. * Attach the input controls to a specific dom element to get the input from.
  34865. * @param element Defines the element the controls should be listened from
  34866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34867. */
  34868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34869. /**
  34870. * Detach the current controls from the specified dom element.
  34871. * @param element Defines the element to stop listening the inputs from
  34872. */
  34873. detachControl(element: Nullable<HTMLElement>): void;
  34874. /**
  34875. * Gets the class name of the current input.
  34876. * @returns the class name
  34877. */
  34878. getClassName(): string;
  34879. /**
  34880. * Get the friendly name associated with the input class.
  34881. * @returns the input friendly name
  34882. */
  34883. getSimpleName(): string;
  34884. /**
  34885. * Called on pointer POINTERDOUBLETAP event.
  34886. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34887. */
  34888. protected onDoubleTap(type: string): void;
  34889. /**
  34890. * Called on pointer POINTERMOVE event if only a single touch is active.
  34891. * Override this method to provide functionality.
  34892. */
  34893. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34894. /**
  34895. * Called on pointer POINTERMOVE event if multiple touches are active.
  34896. * Override this method to provide functionality.
  34897. */
  34898. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34899. /**
  34900. * Called on JS contextmenu event.
  34901. * Override this method to provide functionality.
  34902. */
  34903. protected onContextMenu(evt: PointerEvent): void;
  34904. /**
  34905. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34906. * press.
  34907. * Override this method to provide functionality.
  34908. */
  34909. protected onButtonDown(evt: PointerEvent): void;
  34910. /**
  34911. * Called each time a new POINTERUP event occurs. Ie, for each button
  34912. * release.
  34913. * Override this method to provide functionality.
  34914. */
  34915. protected onButtonUp(evt: PointerEvent): void;
  34916. /**
  34917. * Called when window becomes inactive.
  34918. * Override this method to provide functionality.
  34919. */
  34920. protected onLostFocus(): void;
  34921. private _pointerInput;
  34922. private _observer;
  34923. private _onLostFocus;
  34924. private pointA;
  34925. private pointB;
  34926. }
  34927. }
  34928. declare module BABYLON {
  34929. /**
  34930. * Manage the pointers inputs to control an arc rotate camera.
  34931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34932. */
  34933. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34934. /**
  34935. * Defines the camera the input is attached to.
  34936. */
  34937. camera: ArcRotateCamera;
  34938. /**
  34939. * Gets the class name of the current input.
  34940. * @returns the class name
  34941. */
  34942. getClassName(): string;
  34943. /**
  34944. * Defines the buttons associated with the input to handle camera move.
  34945. */
  34946. buttons: number[];
  34947. /**
  34948. * Defines the pointer angular sensibility along the X axis or how fast is
  34949. * the camera rotating.
  34950. */
  34951. angularSensibilityX: number;
  34952. /**
  34953. * Defines the pointer angular sensibility along the Y axis or how fast is
  34954. * the camera rotating.
  34955. */
  34956. angularSensibilityY: number;
  34957. /**
  34958. * Defines the pointer pinch precision or how fast is the camera zooming.
  34959. */
  34960. pinchPrecision: number;
  34961. /**
  34962. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34963. * from 0.
  34964. * It defines the percentage of current camera.radius to use as delta when
  34965. * pinch zoom is used.
  34966. */
  34967. pinchDeltaPercentage: number;
  34968. /**
  34969. * Defines the pointer panning sensibility or how fast is the camera moving.
  34970. */
  34971. panningSensibility: number;
  34972. /**
  34973. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34974. */
  34975. multiTouchPanning: boolean;
  34976. /**
  34977. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34978. * zoom (pinch) through multitouch.
  34979. */
  34980. multiTouchPanAndZoom: boolean;
  34981. /**
  34982. * Revers pinch action direction.
  34983. */
  34984. pinchInwards: boolean;
  34985. private _isPanClick;
  34986. private _twoFingerActivityCount;
  34987. private _isPinching;
  34988. /**
  34989. * Called on pointer POINTERMOVE event if only a single touch is active.
  34990. */
  34991. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34992. /**
  34993. * Called on pointer POINTERDOUBLETAP event.
  34994. */
  34995. protected onDoubleTap(type: string): void;
  34996. /**
  34997. * Called on pointer POINTERMOVE event if multiple touches are active.
  34998. */
  34999. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35000. /**
  35001. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35002. * press.
  35003. */
  35004. protected onButtonDown(evt: PointerEvent): void;
  35005. /**
  35006. * Called each time a new POINTERUP event occurs. Ie, for each button
  35007. * release.
  35008. */
  35009. protected onButtonUp(evt: PointerEvent): void;
  35010. /**
  35011. * Called when window becomes inactive.
  35012. */
  35013. protected onLostFocus(): void;
  35014. }
  35015. }
  35016. declare module BABYLON {
  35017. /**
  35018. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35020. */
  35021. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35022. /**
  35023. * Defines the camera the input is attached to.
  35024. */
  35025. camera: ArcRotateCamera;
  35026. /**
  35027. * Defines the list of key codes associated with the up action (increase alpha)
  35028. */
  35029. keysUp: number[];
  35030. /**
  35031. * Defines the list of key codes associated with the down action (decrease alpha)
  35032. */
  35033. keysDown: number[];
  35034. /**
  35035. * Defines the list of key codes associated with the left action (increase beta)
  35036. */
  35037. keysLeft: number[];
  35038. /**
  35039. * Defines the list of key codes associated with the right action (decrease beta)
  35040. */
  35041. keysRight: number[];
  35042. /**
  35043. * Defines the list of key codes associated with the reset action.
  35044. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35045. */
  35046. keysReset: number[];
  35047. /**
  35048. * Defines the panning sensibility of the inputs.
  35049. * (How fast is the camera paning)
  35050. */
  35051. panningSensibility: number;
  35052. /**
  35053. * Defines the zooming sensibility of the inputs.
  35054. * (How fast is the camera zooming)
  35055. */
  35056. zoomingSensibility: number;
  35057. /**
  35058. * Defines wether maintaining the alt key down switch the movement mode from
  35059. * orientation to zoom.
  35060. */
  35061. useAltToZoom: boolean;
  35062. /**
  35063. * Rotation speed of the camera
  35064. */
  35065. angularSpeed: number;
  35066. private _keys;
  35067. private _ctrlPressed;
  35068. private _altPressed;
  35069. private _onCanvasBlurObserver;
  35070. private _onKeyboardObserver;
  35071. private _engine;
  35072. private _scene;
  35073. /**
  35074. * Attach the input controls to a specific dom element to get the input from.
  35075. * @param element Defines the element the controls should be listened from
  35076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35077. */
  35078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35079. /**
  35080. * Detach the current controls from the specified dom element.
  35081. * @param element Defines the element to stop listening the inputs from
  35082. */
  35083. detachControl(element: Nullable<HTMLElement>): void;
  35084. /**
  35085. * Update the current camera state depending on the inputs that have been used this frame.
  35086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35087. */
  35088. checkInputs(): void;
  35089. /**
  35090. * Gets the class name of the current intput.
  35091. * @returns the class name
  35092. */
  35093. getClassName(): string;
  35094. /**
  35095. * Get the friendly name associated with the input class.
  35096. * @returns the input friendly name
  35097. */
  35098. getSimpleName(): string;
  35099. }
  35100. }
  35101. declare module BABYLON {
  35102. /**
  35103. * Manage the mouse wheel inputs to control an arc rotate camera.
  35104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35105. */
  35106. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35107. /**
  35108. * Defines the camera the input is attached to.
  35109. */
  35110. camera: ArcRotateCamera;
  35111. /**
  35112. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35113. */
  35114. wheelPrecision: number;
  35115. /**
  35116. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35117. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35118. */
  35119. wheelDeltaPercentage: number;
  35120. private _wheel;
  35121. private _observer;
  35122. private computeDeltaFromMouseWheelLegacyEvent;
  35123. /**
  35124. * Attach the input controls to a specific dom element to get the input from.
  35125. * @param element Defines the element the controls should be listened from
  35126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35127. */
  35128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35129. /**
  35130. * Detach the current controls from the specified dom element.
  35131. * @param element Defines the element to stop listening the inputs from
  35132. */
  35133. detachControl(element: Nullable<HTMLElement>): void;
  35134. /**
  35135. * Gets the class name of the current intput.
  35136. * @returns the class name
  35137. */
  35138. getClassName(): string;
  35139. /**
  35140. * Get the friendly name associated with the input class.
  35141. * @returns the input friendly name
  35142. */
  35143. getSimpleName(): string;
  35144. }
  35145. }
  35146. declare module BABYLON {
  35147. /**
  35148. * Default Inputs manager for the ArcRotateCamera.
  35149. * It groups all the default supported inputs for ease of use.
  35150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35151. */
  35152. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35153. /**
  35154. * Instantiates a new ArcRotateCameraInputsManager.
  35155. * @param camera Defines the camera the inputs belong to
  35156. */
  35157. constructor(camera: ArcRotateCamera);
  35158. /**
  35159. * Add mouse wheel input support to the input manager.
  35160. * @returns the current input manager
  35161. */
  35162. addMouseWheel(): ArcRotateCameraInputsManager;
  35163. /**
  35164. * Add pointers input support to the input manager.
  35165. * @returns the current input manager
  35166. */
  35167. addPointers(): ArcRotateCameraInputsManager;
  35168. /**
  35169. * Add keyboard input support to the input manager.
  35170. * @returns the current input manager
  35171. */
  35172. addKeyboard(): ArcRotateCameraInputsManager;
  35173. }
  35174. }
  35175. declare module BABYLON {
  35176. /**
  35177. * This represents an orbital type of camera.
  35178. *
  35179. * 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.
  35180. * 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.
  35181. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35182. */
  35183. export class ArcRotateCamera extends TargetCamera {
  35184. /**
  35185. * Defines the rotation angle of the camera along the longitudinal axis.
  35186. */
  35187. alpha: number;
  35188. /**
  35189. * Defines the rotation angle of the camera along the latitudinal axis.
  35190. */
  35191. beta: number;
  35192. /**
  35193. * Defines the radius of the camera from it s target point.
  35194. */
  35195. radius: number;
  35196. protected _target: Vector3;
  35197. protected _targetHost: Nullable<AbstractMesh>;
  35198. /**
  35199. * Defines the target point of the camera.
  35200. * The camera looks towards it form the radius distance.
  35201. */
  35202. target: Vector3;
  35203. /**
  35204. * Define the current local position of the camera in the scene
  35205. */
  35206. position: Vector3;
  35207. protected _upVector: Vector3;
  35208. protected _upToYMatrix: Matrix;
  35209. protected _YToUpMatrix: Matrix;
  35210. /**
  35211. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35212. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35213. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35214. */
  35215. upVector: Vector3;
  35216. /**
  35217. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35218. */
  35219. setMatUp(): void;
  35220. /**
  35221. * Current inertia value on the longitudinal axis.
  35222. * The bigger this number the longer it will take for the camera to stop.
  35223. */
  35224. inertialAlphaOffset: number;
  35225. /**
  35226. * Current inertia value on the latitudinal axis.
  35227. * The bigger this number the longer it will take for the camera to stop.
  35228. */
  35229. inertialBetaOffset: number;
  35230. /**
  35231. * Current inertia value on the radius axis.
  35232. * The bigger this number the longer it will take for the camera to stop.
  35233. */
  35234. inertialRadiusOffset: number;
  35235. /**
  35236. * Minimum allowed angle on the longitudinal axis.
  35237. * This can help limiting how the Camera is able to move in the scene.
  35238. */
  35239. lowerAlphaLimit: Nullable<number>;
  35240. /**
  35241. * Maximum allowed angle on the longitudinal axis.
  35242. * This can help limiting how the Camera is able to move in the scene.
  35243. */
  35244. upperAlphaLimit: Nullable<number>;
  35245. /**
  35246. * Minimum allowed angle on the latitudinal axis.
  35247. * This can help limiting how the Camera is able to move in the scene.
  35248. */
  35249. lowerBetaLimit: number;
  35250. /**
  35251. * Maximum allowed angle on the latitudinal axis.
  35252. * This can help limiting how the Camera is able to move in the scene.
  35253. */
  35254. upperBetaLimit: number;
  35255. /**
  35256. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35257. * This can help limiting how the Camera is able to move in the scene.
  35258. */
  35259. lowerRadiusLimit: Nullable<number>;
  35260. /**
  35261. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35262. * This can help limiting how the Camera is able to move in the scene.
  35263. */
  35264. upperRadiusLimit: Nullable<number>;
  35265. /**
  35266. * Defines the current inertia value used during panning of the camera along the X axis.
  35267. */
  35268. inertialPanningX: number;
  35269. /**
  35270. * Defines the current inertia value used during panning of the camera along the Y axis.
  35271. */
  35272. inertialPanningY: number;
  35273. /**
  35274. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35275. * Basically if your fingers moves away from more than this distance you will be considered
  35276. * in pinch mode.
  35277. */
  35278. pinchToPanMaxDistance: number;
  35279. /**
  35280. * Defines the maximum distance the camera can pan.
  35281. * This could help keeping the cammera always in your scene.
  35282. */
  35283. panningDistanceLimit: Nullable<number>;
  35284. /**
  35285. * Defines the target of the camera before paning.
  35286. */
  35287. panningOriginTarget: Vector3;
  35288. /**
  35289. * Defines the value of the inertia used during panning.
  35290. * 0 would mean stop inertia and one would mean no decelleration at all.
  35291. */
  35292. panningInertia: number;
  35293. /**
  35294. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35295. */
  35296. angularSensibilityX: number;
  35297. /**
  35298. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35299. */
  35300. angularSensibilityY: number;
  35301. /**
  35302. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35303. */
  35304. pinchPrecision: number;
  35305. /**
  35306. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35307. * It will be used instead of pinchDeltaPrecision if different from 0.
  35308. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35309. */
  35310. pinchDeltaPercentage: number;
  35311. /**
  35312. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35313. */
  35314. panningSensibility: number;
  35315. /**
  35316. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35317. */
  35318. keysUp: number[];
  35319. /**
  35320. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35321. */
  35322. keysDown: number[];
  35323. /**
  35324. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35325. */
  35326. keysLeft: number[];
  35327. /**
  35328. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35329. */
  35330. keysRight: number[];
  35331. /**
  35332. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35333. */
  35334. wheelPrecision: number;
  35335. /**
  35336. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35337. * It will be used instead of pinchDeltaPrecision if different from 0.
  35338. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35339. */
  35340. wheelDeltaPercentage: number;
  35341. /**
  35342. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35343. */
  35344. zoomOnFactor: number;
  35345. /**
  35346. * Defines a screen offset for the camera position.
  35347. */
  35348. targetScreenOffset: Vector2;
  35349. /**
  35350. * Allows the camera to be completely reversed.
  35351. * If false the camera can not arrive upside down.
  35352. */
  35353. allowUpsideDown: boolean;
  35354. /**
  35355. * Define if double tap/click is used to restore the previously saved state of the camera.
  35356. */
  35357. useInputToRestoreState: boolean;
  35358. /** @hidden */
  35359. _viewMatrix: Matrix;
  35360. /** @hidden */
  35361. _useCtrlForPanning: boolean;
  35362. /** @hidden */
  35363. _panningMouseButton: number;
  35364. /**
  35365. * Defines the input associated to the camera.
  35366. */
  35367. inputs: ArcRotateCameraInputsManager;
  35368. /** @hidden */
  35369. _reset: () => void;
  35370. /**
  35371. * Defines the allowed panning axis.
  35372. */
  35373. panningAxis: Vector3;
  35374. protected _localDirection: Vector3;
  35375. protected _transformedDirection: Vector3;
  35376. private _bouncingBehavior;
  35377. /**
  35378. * Gets the bouncing behavior of the camera if it has been enabled.
  35379. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35380. */
  35381. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35382. /**
  35383. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35384. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35385. */
  35386. useBouncingBehavior: boolean;
  35387. private _framingBehavior;
  35388. /**
  35389. * Gets the framing behavior of the camera if it has been enabled.
  35390. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35391. */
  35392. readonly framingBehavior: Nullable<FramingBehavior>;
  35393. /**
  35394. * Defines if the framing behavior of the camera is enabled on the camera.
  35395. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35396. */
  35397. useFramingBehavior: boolean;
  35398. private _autoRotationBehavior;
  35399. /**
  35400. * Gets the auto rotation behavior of the camera if it has been enabled.
  35401. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35402. */
  35403. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35404. /**
  35405. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35406. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35407. */
  35408. useAutoRotationBehavior: boolean;
  35409. /**
  35410. * Observable triggered when the mesh target has been changed on the camera.
  35411. */
  35412. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35413. /**
  35414. * Event raised when the camera is colliding with a mesh.
  35415. */
  35416. onCollide: (collidedMesh: AbstractMesh) => void;
  35417. /**
  35418. * Defines whether the camera should check collision with the objects oh the scene.
  35419. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35420. */
  35421. checkCollisions: boolean;
  35422. /**
  35423. * Defines the collision radius of the camera.
  35424. * This simulates a sphere around the camera.
  35425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35426. */
  35427. collisionRadius: Vector3;
  35428. protected _collider: Collider;
  35429. protected _previousPosition: Vector3;
  35430. protected _collisionVelocity: Vector3;
  35431. protected _newPosition: Vector3;
  35432. protected _previousAlpha: number;
  35433. protected _previousBeta: number;
  35434. protected _previousRadius: number;
  35435. protected _collisionTriggered: boolean;
  35436. protected _targetBoundingCenter: Nullable<Vector3>;
  35437. private _computationVector;
  35438. /**
  35439. * Instantiates a new ArcRotateCamera in a given scene
  35440. * @param name Defines the name of the camera
  35441. * @param alpha Defines the camera rotation along the logitudinal axis
  35442. * @param beta Defines the camera rotation along the latitudinal axis
  35443. * @param radius Defines the camera distance from its target
  35444. * @param target Defines the camera target
  35445. * @param scene Defines the scene the camera belongs to
  35446. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35447. */
  35448. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35449. /** @hidden */
  35450. _initCache(): void;
  35451. /** @hidden */
  35452. _updateCache(ignoreParentClass?: boolean): void;
  35453. protected _getTargetPosition(): Vector3;
  35454. private _storedAlpha;
  35455. private _storedBeta;
  35456. private _storedRadius;
  35457. private _storedTarget;
  35458. /**
  35459. * Stores the current state of the camera (alpha, beta, radius and target)
  35460. * @returns the camera itself
  35461. */
  35462. storeState(): Camera;
  35463. /**
  35464. * @hidden
  35465. * Restored camera state. You must call storeState() first
  35466. */
  35467. _restoreStateValues(): boolean;
  35468. /** @hidden */
  35469. _isSynchronizedViewMatrix(): boolean;
  35470. /**
  35471. * Attached controls to the current camera.
  35472. * @param element Defines the element the controls should be listened from
  35473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35474. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35475. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35476. */
  35477. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35478. /**
  35479. * Detach the current controls from the camera.
  35480. * The camera will stop reacting to inputs.
  35481. * @param element Defines the element to stop listening the inputs from
  35482. */
  35483. detachControl(element: HTMLElement): void;
  35484. /** @hidden */
  35485. _checkInputs(): void;
  35486. protected _checkLimits(): void;
  35487. /**
  35488. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35489. */
  35490. rebuildAnglesAndRadius(): void;
  35491. /**
  35492. * Use a position to define the current camera related information like aplha, beta and radius
  35493. * @param position Defines the position to set the camera at
  35494. */
  35495. setPosition(position: Vector3): void;
  35496. /**
  35497. * Defines the target the camera should look at.
  35498. * This will automatically adapt alpha beta and radius to fit within the new target.
  35499. * @param target Defines the new target as a Vector or a mesh
  35500. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35501. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35502. */
  35503. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35504. /** @hidden */
  35505. _getViewMatrix(): Matrix;
  35506. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35507. /**
  35508. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35509. * @param meshes Defines the mesh to zoom on
  35510. * @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)
  35511. */
  35512. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35513. /**
  35514. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35515. * The target will be changed but the radius
  35516. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35517. * @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)
  35518. */
  35519. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35520. min: Vector3;
  35521. max: Vector3;
  35522. distance: number;
  35523. }, doNotUpdateMaxZ?: boolean): void;
  35524. /**
  35525. * @override
  35526. * Override Camera.createRigCamera
  35527. */
  35528. createRigCamera(name: string, cameraIndex: number): Camera;
  35529. /**
  35530. * @hidden
  35531. * @override
  35532. * Override Camera._updateRigCameras
  35533. */
  35534. _updateRigCameras(): void;
  35535. /**
  35536. * Destroy the camera and release the current resources hold by it.
  35537. */
  35538. dispose(): void;
  35539. /**
  35540. * Gets the current object class name.
  35541. * @return the class name
  35542. */
  35543. getClassName(): string;
  35544. }
  35545. }
  35546. declare module BABYLON {
  35547. /**
  35548. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35549. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35550. */
  35551. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35552. /**
  35553. * Gets the name of the behavior.
  35554. */
  35555. readonly name: string;
  35556. private _zoomStopsAnimation;
  35557. private _idleRotationSpeed;
  35558. private _idleRotationWaitTime;
  35559. private _idleRotationSpinupTime;
  35560. /**
  35561. * Sets the flag that indicates if user zooming should stop animation.
  35562. */
  35563. /**
  35564. * Gets the flag that indicates if user zooming should stop animation.
  35565. */
  35566. zoomStopsAnimation: boolean;
  35567. /**
  35568. * Sets the default speed at which the camera rotates around the model.
  35569. */
  35570. /**
  35571. * Gets the default speed at which the camera rotates around the model.
  35572. */
  35573. idleRotationSpeed: number;
  35574. /**
  35575. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35576. */
  35577. /**
  35578. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35579. */
  35580. idleRotationWaitTime: number;
  35581. /**
  35582. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35583. */
  35584. /**
  35585. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35586. */
  35587. idleRotationSpinupTime: number;
  35588. /**
  35589. * Gets a value indicating if the camera is currently rotating because of this behavior
  35590. */
  35591. readonly rotationInProgress: boolean;
  35592. private _onPrePointerObservableObserver;
  35593. private _onAfterCheckInputsObserver;
  35594. private _attachedCamera;
  35595. private _isPointerDown;
  35596. private _lastFrameTime;
  35597. private _lastInteractionTime;
  35598. private _cameraRotationSpeed;
  35599. /**
  35600. * Initializes the behavior.
  35601. */
  35602. init(): void;
  35603. /**
  35604. * Attaches the behavior to its arc rotate camera.
  35605. * @param camera Defines the camera to attach the behavior to
  35606. */
  35607. attach(camera: ArcRotateCamera): void;
  35608. /**
  35609. * Detaches the behavior from its current arc rotate camera.
  35610. */
  35611. detach(): void;
  35612. /**
  35613. * Returns true if user is scrolling.
  35614. * @return true if user is scrolling.
  35615. */
  35616. private _userIsZooming;
  35617. private _lastFrameRadius;
  35618. private _shouldAnimationStopForInteraction;
  35619. /**
  35620. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35621. */
  35622. private _applyUserInteraction;
  35623. private _userIsMoving;
  35624. }
  35625. }
  35626. declare module BABYLON {
  35627. /**
  35628. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35629. */
  35630. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35631. private ui;
  35632. /**
  35633. * The name of the behavior
  35634. */
  35635. name: string;
  35636. /**
  35637. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35638. */
  35639. distanceAwayFromFace: number;
  35640. /**
  35641. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35642. */
  35643. distanceAwayFromBottomOfFace: number;
  35644. private _faceVectors;
  35645. private _target;
  35646. private _scene;
  35647. private _onRenderObserver;
  35648. private _tmpMatrix;
  35649. private _tmpVector;
  35650. /**
  35651. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35652. * @param ui The transform node that should be attched to the mesh
  35653. */
  35654. constructor(ui: TransformNode);
  35655. /**
  35656. * Initializes the behavior
  35657. */
  35658. init(): void;
  35659. private _closestFace;
  35660. private _zeroVector;
  35661. private _lookAtTmpMatrix;
  35662. private _lookAtToRef;
  35663. /**
  35664. * Attaches the AttachToBoxBehavior to the passed in mesh
  35665. * @param target The mesh that the specified node will be attached to
  35666. */
  35667. attach(target: Mesh): void;
  35668. /**
  35669. * Detaches the behavior from the mesh
  35670. */
  35671. detach(): void;
  35672. }
  35673. }
  35674. declare module BABYLON {
  35675. /**
  35676. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35677. */
  35678. export class FadeInOutBehavior implements Behavior<Mesh> {
  35679. /**
  35680. * Time in milliseconds to delay before fading in (Default: 0)
  35681. */
  35682. delay: number;
  35683. /**
  35684. * Time in milliseconds for the mesh to fade in (Default: 300)
  35685. */
  35686. fadeInTime: number;
  35687. private _millisecondsPerFrame;
  35688. private _hovered;
  35689. private _hoverValue;
  35690. private _ownerNode;
  35691. /**
  35692. * Instatiates the FadeInOutBehavior
  35693. */
  35694. constructor();
  35695. /**
  35696. * The name of the behavior
  35697. */
  35698. readonly name: string;
  35699. /**
  35700. * Initializes the behavior
  35701. */
  35702. init(): void;
  35703. /**
  35704. * Attaches the fade behavior on the passed in mesh
  35705. * @param ownerNode The mesh that will be faded in/out once attached
  35706. */
  35707. attach(ownerNode: Mesh): void;
  35708. /**
  35709. * Detaches the behavior from the mesh
  35710. */
  35711. detach(): void;
  35712. /**
  35713. * Triggers the mesh to begin fading in or out
  35714. * @param value if the object should fade in or out (true to fade in)
  35715. */
  35716. fadeIn(value: boolean): void;
  35717. private _update;
  35718. private _setAllVisibility;
  35719. }
  35720. }
  35721. declare module BABYLON {
  35722. /**
  35723. * Class containing a set of static utilities functions for managing Pivots
  35724. * @hidden
  35725. */
  35726. export class PivotTools {
  35727. private static _PivotCached;
  35728. private static _OldPivotPoint;
  35729. private static _PivotTranslation;
  35730. private static _PivotTmpVector;
  35731. /** @hidden */
  35732. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35733. /** @hidden */
  35734. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35735. }
  35736. }
  35737. declare module BABYLON {
  35738. /**
  35739. * Class containing static functions to help procedurally build meshes
  35740. */
  35741. export class PlaneBuilder {
  35742. /**
  35743. * Creates a plane mesh
  35744. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35745. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35746. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35748. * * 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
  35749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35750. * @param name defines the name of the mesh
  35751. * @param options defines the options used to create the mesh
  35752. * @param scene defines the hosting scene
  35753. * @returns the plane mesh
  35754. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35755. */
  35756. static CreatePlane(name: string, options: {
  35757. size?: number;
  35758. width?: number;
  35759. height?: number;
  35760. sideOrientation?: number;
  35761. frontUVs?: Vector4;
  35762. backUVs?: Vector4;
  35763. updatable?: boolean;
  35764. sourcePlane?: Plane;
  35765. }, scene?: Nullable<Scene>): Mesh;
  35766. }
  35767. }
  35768. declare module BABYLON {
  35769. /**
  35770. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35771. */
  35772. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35773. private static _AnyMouseID;
  35774. private _attachedNode;
  35775. private _dragPlane;
  35776. private _scene;
  35777. private _pointerObserver;
  35778. private _beforeRenderObserver;
  35779. private static _planeScene;
  35780. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35781. /**
  35782. * 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)
  35783. */
  35784. maxDragAngle: number;
  35785. /**
  35786. * @hidden
  35787. */
  35788. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35789. /**
  35790. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35791. */
  35792. currentDraggingPointerID: number;
  35793. /**
  35794. * The last position where the pointer hit the drag plane in world space
  35795. */
  35796. lastDragPosition: Vector3;
  35797. /**
  35798. * If the behavior is currently in a dragging state
  35799. */
  35800. dragging: boolean;
  35801. /**
  35802. * 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)
  35803. */
  35804. dragDeltaRatio: number;
  35805. /**
  35806. * If the drag plane orientation should be updated during the dragging (Default: true)
  35807. */
  35808. updateDragPlane: boolean;
  35809. private _debugMode;
  35810. private _moving;
  35811. /**
  35812. * Fires each time the attached mesh is dragged with the pointer
  35813. * * delta between last drag position and current drag position in world space
  35814. * * dragDistance along the drag axis
  35815. * * dragPlaneNormal normal of the current drag plane used during the drag
  35816. * * dragPlanePoint in world space where the drag intersects the drag plane
  35817. */
  35818. onDragObservable: Observable<{
  35819. delta: Vector3;
  35820. dragPlanePoint: Vector3;
  35821. dragPlaneNormal: Vector3;
  35822. dragDistance: number;
  35823. pointerId: number;
  35824. }>;
  35825. /**
  35826. * Fires each time a drag begins (eg. mouse down on mesh)
  35827. */
  35828. onDragStartObservable: Observable<{
  35829. dragPlanePoint: Vector3;
  35830. pointerId: number;
  35831. }>;
  35832. /**
  35833. * Fires each time a drag ends (eg. mouse release after drag)
  35834. */
  35835. onDragEndObservable: Observable<{
  35836. dragPlanePoint: Vector3;
  35837. pointerId: number;
  35838. }>;
  35839. /**
  35840. * If the attached mesh should be moved when dragged
  35841. */
  35842. moveAttached: boolean;
  35843. /**
  35844. * If the drag behavior will react to drag events (Default: true)
  35845. */
  35846. enabled: boolean;
  35847. /**
  35848. * If camera controls should be detached during the drag
  35849. */
  35850. detachCameraControls: boolean;
  35851. /**
  35852. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35853. */
  35854. useObjectOrienationForDragging: boolean;
  35855. private _options;
  35856. /**
  35857. * Creates a pointer drag behavior that can be attached to a mesh
  35858. * @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)
  35859. */
  35860. constructor(options?: {
  35861. dragAxis?: Vector3;
  35862. dragPlaneNormal?: Vector3;
  35863. });
  35864. /**
  35865. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35866. */
  35867. validateDrag: (targetPosition: Vector3) => boolean;
  35868. /**
  35869. * The name of the behavior
  35870. */
  35871. readonly name: string;
  35872. /**
  35873. * Initializes the behavior
  35874. */
  35875. init(): void;
  35876. private _tmpVector;
  35877. private _alternatePickedPoint;
  35878. private _worldDragAxis;
  35879. private _targetPosition;
  35880. private _attachedElement;
  35881. /**
  35882. * Attaches the drag behavior the passed in mesh
  35883. * @param ownerNode The mesh that will be dragged around once attached
  35884. */
  35885. attach(ownerNode: AbstractMesh): void;
  35886. /**
  35887. * Force relase the drag action by code.
  35888. */
  35889. releaseDrag(): void;
  35890. private _startDragRay;
  35891. private _lastPointerRay;
  35892. /**
  35893. * Simulates the start of a pointer drag event on the behavior
  35894. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35895. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35896. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35897. */
  35898. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35899. private _startDrag;
  35900. private _dragDelta;
  35901. private _moveDrag;
  35902. private _pickWithRayOnDragPlane;
  35903. private _pointA;
  35904. private _pointB;
  35905. private _pointC;
  35906. private _lineA;
  35907. private _lineB;
  35908. private _localAxis;
  35909. private _lookAt;
  35910. private _updateDragPlanePosition;
  35911. /**
  35912. * Detaches the behavior from the mesh
  35913. */
  35914. detach(): void;
  35915. }
  35916. }
  35917. declare module BABYLON {
  35918. /**
  35919. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35920. */
  35921. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35922. private _dragBehaviorA;
  35923. private _dragBehaviorB;
  35924. private _startDistance;
  35925. private _initialScale;
  35926. private _targetScale;
  35927. private _ownerNode;
  35928. private _sceneRenderObserver;
  35929. /**
  35930. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35931. */
  35932. constructor();
  35933. /**
  35934. * The name of the behavior
  35935. */
  35936. readonly name: string;
  35937. /**
  35938. * Initializes the behavior
  35939. */
  35940. init(): void;
  35941. private _getCurrentDistance;
  35942. /**
  35943. * Attaches the scale behavior the passed in mesh
  35944. * @param ownerNode The mesh that will be scaled around once attached
  35945. */
  35946. attach(ownerNode: Mesh): void;
  35947. /**
  35948. * Detaches the behavior from the mesh
  35949. */
  35950. detach(): void;
  35951. }
  35952. }
  35953. declare module BABYLON {
  35954. /**
  35955. * 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
  35956. */
  35957. export class SixDofDragBehavior implements Behavior<Mesh> {
  35958. private static _virtualScene;
  35959. private _ownerNode;
  35960. private _sceneRenderObserver;
  35961. private _scene;
  35962. private _targetPosition;
  35963. private _virtualOriginMesh;
  35964. private _virtualDragMesh;
  35965. private _pointerObserver;
  35966. private _moving;
  35967. private _startingOrientation;
  35968. /**
  35969. * 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)
  35970. */
  35971. private zDragFactor;
  35972. /**
  35973. * If the object should rotate to face the drag origin
  35974. */
  35975. rotateDraggedObject: boolean;
  35976. /**
  35977. * If the behavior is currently in a dragging state
  35978. */
  35979. dragging: boolean;
  35980. /**
  35981. * 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)
  35982. */
  35983. dragDeltaRatio: number;
  35984. /**
  35985. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35986. */
  35987. currentDraggingPointerID: number;
  35988. /**
  35989. * If camera controls should be detached during the drag
  35990. */
  35991. detachCameraControls: boolean;
  35992. /**
  35993. * Fires each time a drag starts
  35994. */
  35995. onDragStartObservable: Observable<{}>;
  35996. /**
  35997. * Fires each time a drag ends (eg. mouse release after drag)
  35998. */
  35999. onDragEndObservable: Observable<{}>;
  36000. /**
  36001. * 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
  36002. */
  36003. constructor();
  36004. /**
  36005. * The name of the behavior
  36006. */
  36007. readonly name: string;
  36008. /**
  36009. * Initializes the behavior
  36010. */
  36011. init(): void;
  36012. /**
  36013. * Attaches the scale behavior the passed in mesh
  36014. * @param ownerNode The mesh that will be scaled around once attached
  36015. */
  36016. attach(ownerNode: Mesh): void;
  36017. /**
  36018. * Detaches the behavior from the mesh
  36019. */
  36020. detach(): void;
  36021. }
  36022. }
  36023. declare module BABYLON {
  36024. /**
  36025. * Class used to apply inverse kinematics to bones
  36026. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36027. */
  36028. export class BoneIKController {
  36029. private static _tmpVecs;
  36030. private static _tmpQuat;
  36031. private static _tmpMats;
  36032. /**
  36033. * Gets or sets the target mesh
  36034. */
  36035. targetMesh: AbstractMesh;
  36036. /** Gets or sets the mesh used as pole */
  36037. poleTargetMesh: AbstractMesh;
  36038. /**
  36039. * Gets or sets the bone used as pole
  36040. */
  36041. poleTargetBone: Nullable<Bone>;
  36042. /**
  36043. * Gets or sets the target position
  36044. */
  36045. targetPosition: Vector3;
  36046. /**
  36047. * Gets or sets the pole target position
  36048. */
  36049. poleTargetPosition: Vector3;
  36050. /**
  36051. * Gets or sets the pole target local offset
  36052. */
  36053. poleTargetLocalOffset: Vector3;
  36054. /**
  36055. * Gets or sets the pole angle
  36056. */
  36057. poleAngle: number;
  36058. /**
  36059. * Gets or sets the mesh associated with the controller
  36060. */
  36061. mesh: AbstractMesh;
  36062. /**
  36063. * 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)
  36064. */
  36065. slerpAmount: number;
  36066. private _bone1Quat;
  36067. private _bone1Mat;
  36068. private _bone2Ang;
  36069. private _bone1;
  36070. private _bone2;
  36071. private _bone1Length;
  36072. private _bone2Length;
  36073. private _maxAngle;
  36074. private _maxReach;
  36075. private _rightHandedSystem;
  36076. private _bendAxis;
  36077. private _slerping;
  36078. private _adjustRoll;
  36079. /**
  36080. * Gets or sets maximum allowed angle
  36081. */
  36082. maxAngle: number;
  36083. /**
  36084. * Creates a new BoneIKController
  36085. * @param mesh defines the mesh to control
  36086. * @param bone defines the bone to control
  36087. * @param options defines options to set up the controller
  36088. */
  36089. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36090. targetMesh?: AbstractMesh;
  36091. poleTargetMesh?: AbstractMesh;
  36092. poleTargetBone?: Bone;
  36093. poleTargetLocalOffset?: Vector3;
  36094. poleAngle?: number;
  36095. bendAxis?: Vector3;
  36096. maxAngle?: number;
  36097. slerpAmount?: number;
  36098. });
  36099. private _setMaxAngle;
  36100. /**
  36101. * Force the controller to update the bones
  36102. */
  36103. update(): void;
  36104. }
  36105. }
  36106. declare module BABYLON {
  36107. /**
  36108. * Class used to make a bone look toward a point in space
  36109. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36110. */
  36111. export class BoneLookController {
  36112. private static _tmpVecs;
  36113. private static _tmpQuat;
  36114. private static _tmpMats;
  36115. /**
  36116. * The target Vector3 that the bone will look at
  36117. */
  36118. target: Vector3;
  36119. /**
  36120. * The mesh that the bone is attached to
  36121. */
  36122. mesh: AbstractMesh;
  36123. /**
  36124. * The bone that will be looking to the target
  36125. */
  36126. bone: Bone;
  36127. /**
  36128. * The up axis of the coordinate system that is used when the bone is rotated
  36129. */
  36130. upAxis: Vector3;
  36131. /**
  36132. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36133. */
  36134. upAxisSpace: Space;
  36135. /**
  36136. * Used to make an adjustment to the yaw of the bone
  36137. */
  36138. adjustYaw: number;
  36139. /**
  36140. * Used to make an adjustment to the pitch of the bone
  36141. */
  36142. adjustPitch: number;
  36143. /**
  36144. * Used to make an adjustment to the roll of the bone
  36145. */
  36146. adjustRoll: number;
  36147. /**
  36148. * 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)
  36149. */
  36150. slerpAmount: number;
  36151. private _minYaw;
  36152. private _maxYaw;
  36153. private _minPitch;
  36154. private _maxPitch;
  36155. private _minYawSin;
  36156. private _minYawCos;
  36157. private _maxYawSin;
  36158. private _maxYawCos;
  36159. private _midYawConstraint;
  36160. private _minPitchTan;
  36161. private _maxPitchTan;
  36162. private _boneQuat;
  36163. private _slerping;
  36164. private _transformYawPitch;
  36165. private _transformYawPitchInv;
  36166. private _firstFrameSkipped;
  36167. private _yawRange;
  36168. private _fowardAxis;
  36169. /**
  36170. * Gets or sets the minimum yaw angle that the bone can look to
  36171. */
  36172. minYaw: number;
  36173. /**
  36174. * Gets or sets the maximum yaw angle that the bone can look to
  36175. */
  36176. maxYaw: number;
  36177. /**
  36178. * Gets or sets the minimum pitch angle that the bone can look to
  36179. */
  36180. minPitch: number;
  36181. /**
  36182. * Gets or sets the maximum pitch angle that the bone can look to
  36183. */
  36184. maxPitch: number;
  36185. /**
  36186. * Create a BoneLookController
  36187. * @param mesh the mesh that the bone belongs to
  36188. * @param bone the bone that will be looking to the target
  36189. * @param target the target Vector3 to look at
  36190. * @param options optional settings:
  36191. * * maxYaw: the maximum angle the bone will yaw to
  36192. * * minYaw: the minimum angle the bone will yaw to
  36193. * * maxPitch: the maximum angle the bone will pitch to
  36194. * * minPitch: the minimum angle the bone will yaw to
  36195. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36196. * * upAxis: the up axis of the coordinate system
  36197. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36198. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36199. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36200. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36201. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36202. * * adjustRoll: used to make an adjustment to the roll of the bone
  36203. **/
  36204. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36205. maxYaw?: number;
  36206. minYaw?: number;
  36207. maxPitch?: number;
  36208. minPitch?: number;
  36209. slerpAmount?: number;
  36210. upAxis?: Vector3;
  36211. upAxisSpace?: Space;
  36212. yawAxis?: Vector3;
  36213. pitchAxis?: Vector3;
  36214. adjustYaw?: number;
  36215. adjustPitch?: number;
  36216. adjustRoll?: number;
  36217. });
  36218. /**
  36219. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36220. */
  36221. update(): void;
  36222. private _getAngleDiff;
  36223. private _getAngleBetween;
  36224. private _isAngleBetween;
  36225. }
  36226. }
  36227. declare module BABYLON {
  36228. /**
  36229. * Manage the gamepad inputs to control an arc rotate camera.
  36230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36231. */
  36232. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36233. /**
  36234. * Defines the camera the input is attached to.
  36235. */
  36236. camera: ArcRotateCamera;
  36237. /**
  36238. * Defines the gamepad the input is gathering event from.
  36239. */
  36240. gamepad: Nullable<Gamepad>;
  36241. /**
  36242. * Defines the gamepad rotation sensiblity.
  36243. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36244. */
  36245. gamepadRotationSensibility: number;
  36246. /**
  36247. * Defines the gamepad move sensiblity.
  36248. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36249. */
  36250. gamepadMoveSensibility: number;
  36251. private _onGamepadConnectedObserver;
  36252. private _onGamepadDisconnectedObserver;
  36253. /**
  36254. * Attach the input controls to a specific dom element to get the input from.
  36255. * @param element Defines the element the controls should be listened from
  36256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36257. */
  36258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36259. /**
  36260. * Detach the current controls from the specified dom element.
  36261. * @param element Defines the element to stop listening the inputs from
  36262. */
  36263. detachControl(element: Nullable<HTMLElement>): void;
  36264. /**
  36265. * Update the current camera state depending on the inputs that have been used this frame.
  36266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36267. */
  36268. checkInputs(): void;
  36269. /**
  36270. * Gets the class name of the current intput.
  36271. * @returns the class name
  36272. */
  36273. getClassName(): string;
  36274. /**
  36275. * Get the friendly name associated with the input class.
  36276. * @returns the input friendly name
  36277. */
  36278. getSimpleName(): string;
  36279. }
  36280. }
  36281. declare module BABYLON {
  36282. interface ArcRotateCameraInputsManager {
  36283. /**
  36284. * Add orientation input support to the input manager.
  36285. * @returns the current input manager
  36286. */
  36287. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36288. }
  36289. /**
  36290. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36292. */
  36293. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36294. /**
  36295. * Defines the camera the input is attached to.
  36296. */
  36297. camera: ArcRotateCamera;
  36298. /**
  36299. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36300. */
  36301. alphaCorrection: number;
  36302. /**
  36303. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36304. */
  36305. gammaCorrection: number;
  36306. private _alpha;
  36307. private _gamma;
  36308. private _dirty;
  36309. private _deviceOrientationHandler;
  36310. /**
  36311. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36312. */
  36313. constructor();
  36314. /**
  36315. * Attach the input controls to a specific dom element to get the input from.
  36316. * @param element Defines the element the controls should be listened from
  36317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36318. */
  36319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36320. /** @hidden */
  36321. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36322. /**
  36323. * Update the current camera state depending on the inputs that have been used this frame.
  36324. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36325. */
  36326. checkInputs(): void;
  36327. /**
  36328. * Detach the current controls from the specified dom element.
  36329. * @param element Defines the element to stop listening the inputs from
  36330. */
  36331. detachControl(element: Nullable<HTMLElement>): void;
  36332. /**
  36333. * Gets the class name of the current intput.
  36334. * @returns the class name
  36335. */
  36336. getClassName(): string;
  36337. /**
  36338. * Get the friendly name associated with the input class.
  36339. * @returns the input friendly name
  36340. */
  36341. getSimpleName(): string;
  36342. }
  36343. }
  36344. declare module BABYLON {
  36345. /**
  36346. * Listen to mouse events to control the camera.
  36347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36348. */
  36349. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36350. /**
  36351. * Defines the camera the input is attached to.
  36352. */
  36353. camera: FlyCamera;
  36354. /**
  36355. * Defines if touch is enabled. (Default is true.)
  36356. */
  36357. touchEnabled: boolean;
  36358. /**
  36359. * Defines the buttons associated with the input to handle camera rotation.
  36360. */
  36361. buttons: number[];
  36362. /**
  36363. * Assign buttons for Yaw control.
  36364. */
  36365. buttonsYaw: number[];
  36366. /**
  36367. * Assign buttons for Pitch control.
  36368. */
  36369. buttonsPitch: number[];
  36370. /**
  36371. * Assign buttons for Roll control.
  36372. */
  36373. buttonsRoll: number[];
  36374. /**
  36375. * Detect if any button is being pressed while mouse is moved.
  36376. * -1 = Mouse locked.
  36377. * 0 = Left button.
  36378. * 1 = Middle Button.
  36379. * 2 = Right Button.
  36380. */
  36381. activeButton: number;
  36382. /**
  36383. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36384. * Higher values reduce its sensitivity.
  36385. */
  36386. angularSensibility: number;
  36387. private _mousemoveCallback;
  36388. private _observer;
  36389. private _rollObserver;
  36390. private previousPosition;
  36391. private noPreventDefault;
  36392. private element;
  36393. /**
  36394. * Listen to mouse events to control the camera.
  36395. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36397. */
  36398. constructor(touchEnabled?: boolean);
  36399. /**
  36400. * Attach the mouse control to the HTML DOM element.
  36401. * @param element Defines the element that listens to the input events.
  36402. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36403. */
  36404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36405. /**
  36406. * Detach the current controls from the specified dom element.
  36407. * @param element Defines the element to stop listening the inputs from
  36408. */
  36409. detachControl(element: Nullable<HTMLElement>): void;
  36410. /**
  36411. * Gets the class name of the current input.
  36412. * @returns the class name.
  36413. */
  36414. getClassName(): string;
  36415. /**
  36416. * Get the friendly name associated with the input class.
  36417. * @returns the input's friendly name.
  36418. */
  36419. getSimpleName(): string;
  36420. private _pointerInput;
  36421. private _onMouseMove;
  36422. /**
  36423. * Rotate camera by mouse offset.
  36424. */
  36425. private rotateCamera;
  36426. }
  36427. }
  36428. declare module BABYLON {
  36429. /**
  36430. * Default Inputs manager for the FlyCamera.
  36431. * It groups all the default supported inputs for ease of use.
  36432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36433. */
  36434. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36435. /**
  36436. * Instantiates a new FlyCameraInputsManager.
  36437. * @param camera Defines the camera the inputs belong to.
  36438. */
  36439. constructor(camera: FlyCamera);
  36440. /**
  36441. * Add keyboard input support to the input manager.
  36442. * @returns the new FlyCameraKeyboardMoveInput().
  36443. */
  36444. addKeyboard(): FlyCameraInputsManager;
  36445. /**
  36446. * Add mouse input support to the input manager.
  36447. * @param touchEnabled Enable touch screen support.
  36448. * @returns the new FlyCameraMouseInput().
  36449. */
  36450. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36451. }
  36452. }
  36453. declare module BABYLON {
  36454. /**
  36455. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36456. * such as in a 3D Space Shooter or a Flight Simulator.
  36457. */
  36458. export class FlyCamera extends TargetCamera {
  36459. /**
  36460. * Define the collision ellipsoid of the camera.
  36461. * This is helpful for simulating a camera body, like a player's body.
  36462. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36463. */
  36464. ellipsoid: Vector3;
  36465. /**
  36466. * Define an offset for the position of the ellipsoid around the camera.
  36467. * This can be helpful if the camera is attached away from the player's body center,
  36468. * such as at its head.
  36469. */
  36470. ellipsoidOffset: Vector3;
  36471. /**
  36472. * Enable or disable collisions of the camera with the rest of the scene objects.
  36473. */
  36474. checkCollisions: boolean;
  36475. /**
  36476. * Enable or disable gravity on the camera.
  36477. */
  36478. applyGravity: boolean;
  36479. /**
  36480. * Define the current direction the camera is moving to.
  36481. */
  36482. cameraDirection: Vector3;
  36483. /**
  36484. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36485. * This overrides and empties cameraRotation.
  36486. */
  36487. rotationQuaternion: Quaternion;
  36488. /**
  36489. * Track Roll to maintain the wanted Rolling when looking around.
  36490. */
  36491. _trackRoll: number;
  36492. /**
  36493. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36494. */
  36495. rollCorrect: number;
  36496. /**
  36497. * Mimic a banked turn, Rolling the camera when Yawing.
  36498. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36499. */
  36500. bankedTurn: boolean;
  36501. /**
  36502. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36503. */
  36504. bankedTurnLimit: number;
  36505. /**
  36506. * Value of 0 disables the banked Roll.
  36507. * Value of 1 is equal to the Yaw angle in radians.
  36508. */
  36509. bankedTurnMultiplier: number;
  36510. /**
  36511. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36512. */
  36513. inputs: FlyCameraInputsManager;
  36514. /**
  36515. * Gets the input sensibility for mouse input.
  36516. * Higher values reduce sensitivity.
  36517. */
  36518. /**
  36519. * Sets the input sensibility for a mouse input.
  36520. * Higher values reduce sensitivity.
  36521. */
  36522. angularSensibility: number;
  36523. /**
  36524. * Get the keys for camera movement forward.
  36525. */
  36526. /**
  36527. * Set the keys for camera movement forward.
  36528. */
  36529. keysForward: number[];
  36530. /**
  36531. * Get the keys for camera movement backward.
  36532. */
  36533. keysBackward: number[];
  36534. /**
  36535. * Get the keys for camera movement up.
  36536. */
  36537. /**
  36538. * Set the keys for camera movement up.
  36539. */
  36540. keysUp: number[];
  36541. /**
  36542. * Get the keys for camera movement down.
  36543. */
  36544. /**
  36545. * Set the keys for camera movement down.
  36546. */
  36547. keysDown: number[];
  36548. /**
  36549. * Get the keys for camera movement left.
  36550. */
  36551. /**
  36552. * Set the keys for camera movement left.
  36553. */
  36554. keysLeft: number[];
  36555. /**
  36556. * Set the keys for camera movement right.
  36557. */
  36558. /**
  36559. * Set the keys for camera movement right.
  36560. */
  36561. keysRight: number[];
  36562. /**
  36563. * Event raised when the camera collides with a mesh in the scene.
  36564. */
  36565. onCollide: (collidedMesh: AbstractMesh) => void;
  36566. private _collider;
  36567. private _needMoveForGravity;
  36568. private _oldPosition;
  36569. private _diffPosition;
  36570. private _newPosition;
  36571. /** @hidden */
  36572. _localDirection: Vector3;
  36573. /** @hidden */
  36574. _transformedDirection: Vector3;
  36575. /**
  36576. * Instantiates a FlyCamera.
  36577. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36578. * such as in a 3D Space Shooter or a Flight Simulator.
  36579. * @param name Define the name of the camera in the scene.
  36580. * @param position Define the starting position of the camera in the scene.
  36581. * @param scene Define the scene the camera belongs to.
  36582. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36583. */
  36584. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36585. /**
  36586. * Attach a control to the HTML DOM element.
  36587. * @param element Defines the element that listens to the input events.
  36588. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36589. */
  36590. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36591. /**
  36592. * Detach a control from the HTML DOM element.
  36593. * The camera will stop reacting to that input.
  36594. * @param element Defines the element that listens to the input events.
  36595. */
  36596. detachControl(element: HTMLElement): void;
  36597. private _collisionMask;
  36598. /**
  36599. * Get the mask that the camera ignores in collision events.
  36600. */
  36601. /**
  36602. * Set the mask that the camera ignores in collision events.
  36603. */
  36604. collisionMask: number;
  36605. /** @hidden */
  36606. _collideWithWorld(displacement: Vector3): void;
  36607. /** @hidden */
  36608. private _onCollisionPositionChange;
  36609. /** @hidden */
  36610. _checkInputs(): void;
  36611. /** @hidden */
  36612. _decideIfNeedsToMove(): boolean;
  36613. /** @hidden */
  36614. _updatePosition(): void;
  36615. /**
  36616. * Restore the Roll to its target value at the rate specified.
  36617. * @param rate - Higher means slower restoring.
  36618. * @hidden
  36619. */
  36620. restoreRoll(rate: number): void;
  36621. /**
  36622. * Destroy the camera and release the current resources held by it.
  36623. */
  36624. dispose(): void;
  36625. /**
  36626. * Get the current object class name.
  36627. * @returns the class name.
  36628. */
  36629. getClassName(): string;
  36630. }
  36631. }
  36632. declare module BABYLON {
  36633. /**
  36634. * Listen to keyboard events to control the camera.
  36635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36636. */
  36637. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36638. /**
  36639. * Defines the camera the input is attached to.
  36640. */
  36641. camera: FlyCamera;
  36642. /**
  36643. * The list of keyboard keys used to control the forward move of the camera.
  36644. */
  36645. keysForward: number[];
  36646. /**
  36647. * The list of keyboard keys used to control the backward move of the camera.
  36648. */
  36649. keysBackward: number[];
  36650. /**
  36651. * The list of keyboard keys used to control the forward move of the camera.
  36652. */
  36653. keysUp: number[];
  36654. /**
  36655. * The list of keyboard keys used to control the backward move of the camera.
  36656. */
  36657. keysDown: number[];
  36658. /**
  36659. * The list of keyboard keys used to control the right strafe move of the camera.
  36660. */
  36661. keysRight: number[];
  36662. /**
  36663. * The list of keyboard keys used to control the left strafe move of the camera.
  36664. */
  36665. keysLeft: number[];
  36666. private _keys;
  36667. private _onCanvasBlurObserver;
  36668. private _onKeyboardObserver;
  36669. private _engine;
  36670. private _scene;
  36671. /**
  36672. * Attach the input controls to a specific dom element to get the input from.
  36673. * @param element Defines the element the controls should be listened from
  36674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36675. */
  36676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36677. /**
  36678. * Detach the current controls from the specified dom element.
  36679. * @param element Defines the element to stop listening the inputs from
  36680. */
  36681. detachControl(element: Nullable<HTMLElement>): void;
  36682. /**
  36683. * Gets the class name of the current intput.
  36684. * @returns the class name
  36685. */
  36686. getClassName(): string;
  36687. /** @hidden */
  36688. _onLostFocus(e: FocusEvent): void;
  36689. /**
  36690. * Get the friendly name associated with the input class.
  36691. * @returns the input friendly name
  36692. */
  36693. getSimpleName(): string;
  36694. /**
  36695. * Update the current camera state depending on the inputs that have been used this frame.
  36696. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36697. */
  36698. checkInputs(): void;
  36699. }
  36700. }
  36701. declare module BABYLON {
  36702. /**
  36703. * Manage the mouse wheel inputs to control a follow camera.
  36704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36705. */
  36706. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36707. /**
  36708. * Defines the camera the input is attached to.
  36709. */
  36710. camera: FollowCamera;
  36711. /**
  36712. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36713. */
  36714. axisControlRadius: boolean;
  36715. /**
  36716. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36717. */
  36718. axisControlHeight: boolean;
  36719. /**
  36720. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36721. */
  36722. axisControlRotation: boolean;
  36723. /**
  36724. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36725. * relation to mouseWheel events.
  36726. */
  36727. wheelPrecision: number;
  36728. /**
  36729. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36730. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36731. */
  36732. wheelDeltaPercentage: number;
  36733. private _wheel;
  36734. private _observer;
  36735. /**
  36736. * Attach the input controls to a specific dom element to get the input from.
  36737. * @param element Defines the element the controls should be listened from
  36738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36739. */
  36740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36741. /**
  36742. * Detach the current controls from the specified dom element.
  36743. * @param element Defines the element to stop listening the inputs from
  36744. */
  36745. detachControl(element: Nullable<HTMLElement>): void;
  36746. /**
  36747. * Gets the class name of the current intput.
  36748. * @returns the class name
  36749. */
  36750. getClassName(): string;
  36751. /**
  36752. * Get the friendly name associated with the input class.
  36753. * @returns the input friendly name
  36754. */
  36755. getSimpleName(): string;
  36756. }
  36757. }
  36758. declare module BABYLON {
  36759. /**
  36760. * Manage the pointers inputs to control an follow camera.
  36761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36762. */
  36763. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36764. /**
  36765. * Defines the camera the input is attached to.
  36766. */
  36767. camera: FollowCamera;
  36768. /**
  36769. * Gets the class name of the current input.
  36770. * @returns the class name
  36771. */
  36772. getClassName(): string;
  36773. /**
  36774. * Defines the pointer angular sensibility along the X axis or how fast is
  36775. * the camera rotating.
  36776. * A negative number will reverse the axis direction.
  36777. */
  36778. angularSensibilityX: number;
  36779. /**
  36780. * Defines the pointer angular sensibility along the Y axis or how fast is
  36781. * the camera rotating.
  36782. * A negative number will reverse the axis direction.
  36783. */
  36784. angularSensibilityY: number;
  36785. /**
  36786. * Defines the pointer pinch precision or how fast is the camera zooming.
  36787. * A negative number will reverse the axis direction.
  36788. */
  36789. pinchPrecision: number;
  36790. /**
  36791. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36792. * from 0.
  36793. * It defines the percentage of current camera.radius to use as delta when
  36794. * pinch zoom is used.
  36795. */
  36796. pinchDeltaPercentage: number;
  36797. /**
  36798. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36799. */
  36800. axisXControlRadius: boolean;
  36801. /**
  36802. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36803. */
  36804. axisXControlHeight: boolean;
  36805. /**
  36806. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36807. */
  36808. axisXControlRotation: boolean;
  36809. /**
  36810. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36811. */
  36812. axisYControlRadius: boolean;
  36813. /**
  36814. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36815. */
  36816. axisYControlHeight: boolean;
  36817. /**
  36818. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36819. */
  36820. axisYControlRotation: boolean;
  36821. /**
  36822. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36823. */
  36824. axisPinchControlRadius: boolean;
  36825. /**
  36826. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36827. */
  36828. axisPinchControlHeight: boolean;
  36829. /**
  36830. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36831. */
  36832. axisPinchControlRotation: boolean;
  36833. /**
  36834. * Log error messages if basic misconfiguration has occurred.
  36835. */
  36836. warningEnable: boolean;
  36837. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36838. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36839. private _warningCounter;
  36840. private _warning;
  36841. }
  36842. }
  36843. declare module BABYLON {
  36844. /**
  36845. * Default Inputs manager for the FollowCamera.
  36846. * It groups all the default supported inputs for ease of use.
  36847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36848. */
  36849. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36850. /**
  36851. * Instantiates a new FollowCameraInputsManager.
  36852. * @param camera Defines the camera the inputs belong to
  36853. */
  36854. constructor(camera: FollowCamera);
  36855. /**
  36856. * Add keyboard input support to the input manager.
  36857. * @returns the current input manager
  36858. */
  36859. addKeyboard(): FollowCameraInputsManager;
  36860. /**
  36861. * Add mouse wheel input support to the input manager.
  36862. * @returns the current input manager
  36863. */
  36864. addMouseWheel(): FollowCameraInputsManager;
  36865. /**
  36866. * Add pointers input support to the input manager.
  36867. * @returns the current input manager
  36868. */
  36869. addPointers(): FollowCameraInputsManager;
  36870. /**
  36871. * Add orientation input support to the input manager.
  36872. * @returns the current input manager
  36873. */
  36874. addVRDeviceOrientation(): FollowCameraInputsManager;
  36875. }
  36876. }
  36877. declare module BABYLON {
  36878. /**
  36879. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36880. * an arc rotate version arcFollowCamera are available.
  36881. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36882. */
  36883. export class FollowCamera extends TargetCamera {
  36884. /**
  36885. * Distance the follow camera should follow an object at
  36886. */
  36887. radius: number;
  36888. /**
  36889. * Minimum allowed distance of the camera to the axis of rotation
  36890. * (The camera can not get closer).
  36891. * This can help limiting how the Camera is able to move in the scene.
  36892. */
  36893. lowerRadiusLimit: Nullable<number>;
  36894. /**
  36895. * Maximum allowed distance of the camera to the axis of rotation
  36896. * (The camera can not get further).
  36897. * This can help limiting how the Camera is able to move in the scene.
  36898. */
  36899. upperRadiusLimit: Nullable<number>;
  36900. /**
  36901. * Define a rotation offset between the camera and the object it follows
  36902. */
  36903. rotationOffset: number;
  36904. /**
  36905. * Minimum allowed angle to camera position relative to target object.
  36906. * This can help limiting how the Camera is able to move in the scene.
  36907. */
  36908. lowerRotationOffsetLimit: Nullable<number>;
  36909. /**
  36910. * Maximum allowed angle to camera position relative to target object.
  36911. * This can help limiting how the Camera is able to move in the scene.
  36912. */
  36913. upperRotationOffsetLimit: Nullable<number>;
  36914. /**
  36915. * Define a height offset between the camera and the object it follows.
  36916. * It can help following an object from the top (like a car chaing a plane)
  36917. */
  36918. heightOffset: number;
  36919. /**
  36920. * Minimum allowed height of camera position relative to target object.
  36921. * This can help limiting how the Camera is able to move in the scene.
  36922. */
  36923. lowerHeightOffsetLimit: Nullable<number>;
  36924. /**
  36925. * Maximum allowed height of camera position relative to target object.
  36926. * This can help limiting how the Camera is able to move in the scene.
  36927. */
  36928. upperHeightOffsetLimit: Nullable<number>;
  36929. /**
  36930. * Define how fast the camera can accelerate to follow it s target.
  36931. */
  36932. cameraAcceleration: number;
  36933. /**
  36934. * Define the speed limit of the camera following an object.
  36935. */
  36936. maxCameraSpeed: number;
  36937. /**
  36938. * Define the target of the camera.
  36939. */
  36940. lockedTarget: Nullable<AbstractMesh>;
  36941. /**
  36942. * Defines the input associated with the camera.
  36943. */
  36944. inputs: FollowCameraInputsManager;
  36945. /**
  36946. * Instantiates the follow camera.
  36947. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36948. * @param name Define the name of the camera in the scene
  36949. * @param position Define the position of the camera
  36950. * @param scene Define the scene the camera belong to
  36951. * @param lockedTarget Define the target of the camera
  36952. */
  36953. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36954. private _follow;
  36955. /**
  36956. * Attached controls to the current camera.
  36957. * @param element Defines the element the controls should be listened from
  36958. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36959. */
  36960. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36961. /**
  36962. * Detach the current controls from the camera.
  36963. * The camera will stop reacting to inputs.
  36964. * @param element Defines the element to stop listening the inputs from
  36965. */
  36966. detachControl(element: HTMLElement): void;
  36967. /** @hidden */
  36968. _checkInputs(): void;
  36969. private _checkLimits;
  36970. /**
  36971. * Gets the camera class name.
  36972. * @returns the class name
  36973. */
  36974. getClassName(): string;
  36975. }
  36976. /**
  36977. * Arc Rotate version of the follow camera.
  36978. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36979. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36980. */
  36981. export class ArcFollowCamera extends TargetCamera {
  36982. /** The longitudinal angle of the camera */
  36983. alpha: number;
  36984. /** The latitudinal angle of the camera */
  36985. beta: number;
  36986. /** The radius of the camera from its target */
  36987. radius: number;
  36988. /** Define the camera target (the messh it should follow) */
  36989. target: Nullable<AbstractMesh>;
  36990. private _cartesianCoordinates;
  36991. /**
  36992. * Instantiates a new ArcFollowCamera
  36993. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36994. * @param name Define the name of the camera
  36995. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36996. * @param beta Define the rotation angle of the camera around the elevation axis
  36997. * @param radius Define the radius of the camera from its target point
  36998. * @param target Define the target of the camera
  36999. * @param scene Define the scene the camera belongs to
  37000. */
  37001. constructor(name: string,
  37002. /** The longitudinal angle of the camera */
  37003. alpha: number,
  37004. /** The latitudinal angle of the camera */
  37005. beta: number,
  37006. /** The radius of the camera from its target */
  37007. radius: number,
  37008. /** Define the camera target (the messh it should follow) */
  37009. target: Nullable<AbstractMesh>, scene: Scene);
  37010. private _follow;
  37011. /** @hidden */
  37012. _checkInputs(): void;
  37013. /**
  37014. * Returns the class name of the object.
  37015. * It is mostly used internally for serialization purposes.
  37016. */
  37017. getClassName(): string;
  37018. }
  37019. }
  37020. declare module BABYLON {
  37021. /**
  37022. * Manage the keyboard inputs to control the movement of a follow camera.
  37023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37024. */
  37025. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37026. /**
  37027. * Defines the camera the input is attached to.
  37028. */
  37029. camera: FollowCamera;
  37030. /**
  37031. * Defines the list of key codes associated with the up action (increase heightOffset)
  37032. */
  37033. keysHeightOffsetIncr: number[];
  37034. /**
  37035. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37036. */
  37037. keysHeightOffsetDecr: number[];
  37038. /**
  37039. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37040. */
  37041. keysHeightOffsetModifierAlt: boolean;
  37042. /**
  37043. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37044. */
  37045. keysHeightOffsetModifierCtrl: boolean;
  37046. /**
  37047. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37048. */
  37049. keysHeightOffsetModifierShift: boolean;
  37050. /**
  37051. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37052. */
  37053. keysRotationOffsetIncr: number[];
  37054. /**
  37055. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37056. */
  37057. keysRotationOffsetDecr: number[];
  37058. /**
  37059. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37060. */
  37061. keysRotationOffsetModifierAlt: boolean;
  37062. /**
  37063. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37064. */
  37065. keysRotationOffsetModifierCtrl: boolean;
  37066. /**
  37067. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37068. */
  37069. keysRotationOffsetModifierShift: boolean;
  37070. /**
  37071. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37072. */
  37073. keysRadiusIncr: number[];
  37074. /**
  37075. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37076. */
  37077. keysRadiusDecr: number[];
  37078. /**
  37079. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37080. */
  37081. keysRadiusModifierAlt: boolean;
  37082. /**
  37083. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37084. */
  37085. keysRadiusModifierCtrl: boolean;
  37086. /**
  37087. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37088. */
  37089. keysRadiusModifierShift: boolean;
  37090. /**
  37091. * Defines the rate of change of heightOffset.
  37092. */
  37093. heightSensibility: number;
  37094. /**
  37095. * Defines the rate of change of rotationOffset.
  37096. */
  37097. rotationSensibility: number;
  37098. /**
  37099. * Defines the rate of change of radius.
  37100. */
  37101. radiusSensibility: number;
  37102. private _keys;
  37103. private _ctrlPressed;
  37104. private _altPressed;
  37105. private _shiftPressed;
  37106. private _onCanvasBlurObserver;
  37107. private _onKeyboardObserver;
  37108. private _engine;
  37109. private _scene;
  37110. /**
  37111. * Attach the input controls to a specific dom element to get the input from.
  37112. * @param element Defines the element the controls should be listened from
  37113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37114. */
  37115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37116. /**
  37117. * Detach the current controls from the specified dom element.
  37118. * @param element Defines the element to stop listening the inputs from
  37119. */
  37120. detachControl(element: Nullable<HTMLElement>): void;
  37121. /**
  37122. * Update the current camera state depending on the inputs that have been used this frame.
  37123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37124. */
  37125. checkInputs(): void;
  37126. /**
  37127. * Gets the class name of the current input.
  37128. * @returns the class name
  37129. */
  37130. getClassName(): string;
  37131. /**
  37132. * Get the friendly name associated with the input class.
  37133. * @returns the input friendly name
  37134. */
  37135. getSimpleName(): string;
  37136. /**
  37137. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37138. * allow modification of the heightOffset value.
  37139. */
  37140. private _modifierHeightOffset;
  37141. /**
  37142. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37143. * allow modification of the rotationOffset value.
  37144. */
  37145. private _modifierRotationOffset;
  37146. /**
  37147. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37148. * allow modification of the radius value.
  37149. */
  37150. private _modifierRadius;
  37151. }
  37152. }
  37153. declare module BABYLON {
  37154. interface FreeCameraInputsManager {
  37155. /**
  37156. * @hidden
  37157. */
  37158. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37159. /**
  37160. * Add orientation input support to the input manager.
  37161. * @returns the current input manager
  37162. */
  37163. addDeviceOrientation(): FreeCameraInputsManager;
  37164. }
  37165. /**
  37166. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37167. * Screen rotation is taken into account.
  37168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37169. */
  37170. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37171. private _camera;
  37172. private _screenOrientationAngle;
  37173. private _constantTranform;
  37174. private _screenQuaternion;
  37175. private _alpha;
  37176. private _beta;
  37177. private _gamma;
  37178. /**
  37179. * @hidden
  37180. */
  37181. _onDeviceOrientationChangedObservable: Observable<void>;
  37182. /**
  37183. * Instantiates a new input
  37184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37185. */
  37186. constructor();
  37187. /**
  37188. * Define the camera controlled by the input.
  37189. */
  37190. camera: FreeCamera;
  37191. /**
  37192. * Attach the input controls to a specific dom element to get the input from.
  37193. * @param element Defines the element the controls should be listened from
  37194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37195. */
  37196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37197. private _orientationChanged;
  37198. private _deviceOrientation;
  37199. /**
  37200. * Detach the current controls from the specified dom element.
  37201. * @param element Defines the element to stop listening the inputs from
  37202. */
  37203. detachControl(element: Nullable<HTMLElement>): void;
  37204. /**
  37205. * Update the current camera state depending on the inputs that have been used this frame.
  37206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37207. */
  37208. checkInputs(): void;
  37209. /**
  37210. * Gets the class name of the current intput.
  37211. * @returns the class name
  37212. */
  37213. getClassName(): string;
  37214. /**
  37215. * Get the friendly name associated with the input class.
  37216. * @returns the input friendly name
  37217. */
  37218. getSimpleName(): string;
  37219. }
  37220. }
  37221. declare module BABYLON {
  37222. /**
  37223. * Manage the gamepad inputs to control a free camera.
  37224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37225. */
  37226. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37227. /**
  37228. * Define the camera the input is attached to.
  37229. */
  37230. camera: FreeCamera;
  37231. /**
  37232. * Define the Gamepad controlling the input
  37233. */
  37234. gamepad: Nullable<Gamepad>;
  37235. /**
  37236. * Defines the gamepad rotation sensiblity.
  37237. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37238. */
  37239. gamepadAngularSensibility: number;
  37240. /**
  37241. * Defines the gamepad move sensiblity.
  37242. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37243. */
  37244. gamepadMoveSensibility: number;
  37245. private _onGamepadConnectedObserver;
  37246. private _onGamepadDisconnectedObserver;
  37247. private _cameraTransform;
  37248. private _deltaTransform;
  37249. private _vector3;
  37250. private _vector2;
  37251. /**
  37252. * Attach the input controls to a specific dom element to get the input from.
  37253. * @param element Defines the element the controls should be listened from
  37254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37255. */
  37256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37257. /**
  37258. * Detach the current controls from the specified dom element.
  37259. * @param element Defines the element to stop listening the inputs from
  37260. */
  37261. detachControl(element: Nullable<HTMLElement>): void;
  37262. /**
  37263. * Update the current camera state depending on the inputs that have been used this frame.
  37264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37265. */
  37266. checkInputs(): void;
  37267. /**
  37268. * Gets the class name of the current intput.
  37269. * @returns the class name
  37270. */
  37271. getClassName(): string;
  37272. /**
  37273. * Get the friendly name associated with the input class.
  37274. * @returns the input friendly name
  37275. */
  37276. getSimpleName(): string;
  37277. }
  37278. }
  37279. declare module BABYLON {
  37280. /**
  37281. * Defines the potential axis of a Joystick
  37282. */
  37283. export enum JoystickAxis {
  37284. /** X axis */
  37285. X = 0,
  37286. /** Y axis */
  37287. Y = 1,
  37288. /** Z axis */
  37289. Z = 2
  37290. }
  37291. /**
  37292. * Class used to define virtual joystick (used in touch mode)
  37293. */
  37294. export class VirtualJoystick {
  37295. /**
  37296. * Gets or sets a boolean indicating that left and right values must be inverted
  37297. */
  37298. reverseLeftRight: boolean;
  37299. /**
  37300. * Gets or sets a boolean indicating that up and down values must be inverted
  37301. */
  37302. reverseUpDown: boolean;
  37303. /**
  37304. * Gets the offset value for the position (ie. the change of the position value)
  37305. */
  37306. deltaPosition: Vector3;
  37307. /**
  37308. * Gets a boolean indicating if the virtual joystick was pressed
  37309. */
  37310. pressed: boolean;
  37311. /**
  37312. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37313. */
  37314. static Canvas: Nullable<HTMLCanvasElement>;
  37315. private static _globalJoystickIndex;
  37316. private static vjCanvasContext;
  37317. private static vjCanvasWidth;
  37318. private static vjCanvasHeight;
  37319. private static halfWidth;
  37320. private _action;
  37321. private _axisTargetedByLeftAndRight;
  37322. private _axisTargetedByUpAndDown;
  37323. private _joystickSensibility;
  37324. private _inversedSensibility;
  37325. private _joystickPointerID;
  37326. private _joystickColor;
  37327. private _joystickPointerPos;
  37328. private _joystickPreviousPointerPos;
  37329. private _joystickPointerStartPos;
  37330. private _deltaJoystickVector;
  37331. private _leftJoystick;
  37332. private _touches;
  37333. private _onPointerDownHandlerRef;
  37334. private _onPointerMoveHandlerRef;
  37335. private _onPointerUpHandlerRef;
  37336. private _onResize;
  37337. /**
  37338. * Creates a new virtual joystick
  37339. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37340. */
  37341. constructor(leftJoystick?: boolean);
  37342. /**
  37343. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37344. * @param newJoystickSensibility defines the new sensibility
  37345. */
  37346. setJoystickSensibility(newJoystickSensibility: number): void;
  37347. private _onPointerDown;
  37348. private _onPointerMove;
  37349. private _onPointerUp;
  37350. /**
  37351. * Change the color of the virtual joystick
  37352. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37353. */
  37354. setJoystickColor(newColor: string): void;
  37355. /**
  37356. * Defines a callback to call when the joystick is touched
  37357. * @param action defines the callback
  37358. */
  37359. setActionOnTouch(action: () => any): void;
  37360. /**
  37361. * Defines which axis you'd like to control for left & right
  37362. * @param axis defines the axis to use
  37363. */
  37364. setAxisForLeftRight(axis: JoystickAxis): void;
  37365. /**
  37366. * Defines which axis you'd like to control for up & down
  37367. * @param axis defines the axis to use
  37368. */
  37369. setAxisForUpDown(axis: JoystickAxis): void;
  37370. private _drawVirtualJoystick;
  37371. /**
  37372. * Release internal HTML canvas
  37373. */
  37374. releaseCanvas(): void;
  37375. }
  37376. }
  37377. declare module BABYLON {
  37378. interface FreeCameraInputsManager {
  37379. /**
  37380. * Add virtual joystick input support to the input manager.
  37381. * @returns the current input manager
  37382. */
  37383. addVirtualJoystick(): FreeCameraInputsManager;
  37384. }
  37385. /**
  37386. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37387. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37388. */
  37389. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37390. /**
  37391. * Defines the camera the input is attached to.
  37392. */
  37393. camera: FreeCamera;
  37394. private _leftjoystick;
  37395. private _rightjoystick;
  37396. /**
  37397. * Gets the left stick of the virtual joystick.
  37398. * @returns The virtual Joystick
  37399. */
  37400. getLeftJoystick(): VirtualJoystick;
  37401. /**
  37402. * Gets the right stick of the virtual joystick.
  37403. * @returns The virtual Joystick
  37404. */
  37405. getRightJoystick(): VirtualJoystick;
  37406. /**
  37407. * Update the current camera state depending on the inputs that have been used this frame.
  37408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37409. */
  37410. checkInputs(): void;
  37411. /**
  37412. * Attach the input controls to a specific dom element to get the input from.
  37413. * @param element Defines the element the controls should be listened from
  37414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37415. */
  37416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37417. /**
  37418. * Detach the current controls from the specified dom element.
  37419. * @param element Defines the element to stop listening the inputs from
  37420. */
  37421. detachControl(element: Nullable<HTMLElement>): void;
  37422. /**
  37423. * Gets the class name of the current intput.
  37424. * @returns the class name
  37425. */
  37426. getClassName(): string;
  37427. /**
  37428. * Get the friendly name associated with the input class.
  37429. * @returns the input friendly name
  37430. */
  37431. getSimpleName(): string;
  37432. }
  37433. }
  37434. declare module BABYLON {
  37435. /**
  37436. * This represents a FPS type of camera controlled by touch.
  37437. * This is like a universal camera minus the Gamepad controls.
  37438. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37439. */
  37440. export class TouchCamera extends FreeCamera {
  37441. /**
  37442. * Defines the touch sensibility for rotation.
  37443. * The higher the faster.
  37444. */
  37445. touchAngularSensibility: number;
  37446. /**
  37447. * Defines the touch sensibility for move.
  37448. * The higher the faster.
  37449. */
  37450. touchMoveSensibility: number;
  37451. /**
  37452. * Instantiates a new touch camera.
  37453. * This represents a FPS type of camera controlled by touch.
  37454. * This is like a universal camera minus the Gamepad controls.
  37455. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37456. * @param name Define the name of the camera in the scene
  37457. * @param position Define the start position of the camera in the scene
  37458. * @param scene Define the scene the camera belongs to
  37459. */
  37460. constructor(name: string, position: Vector3, scene: Scene);
  37461. /**
  37462. * Gets the current object class name.
  37463. * @return the class name
  37464. */
  37465. getClassName(): string;
  37466. /** @hidden */
  37467. _setupInputs(): void;
  37468. }
  37469. }
  37470. declare module BABYLON {
  37471. /**
  37472. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37473. * being tilted forward or back and left or right.
  37474. */
  37475. export class DeviceOrientationCamera extends FreeCamera {
  37476. private _initialQuaternion;
  37477. private _quaternionCache;
  37478. private _tmpDragQuaternion;
  37479. /**
  37480. * Creates a new device orientation camera
  37481. * @param name The name of the camera
  37482. * @param position The start position camera
  37483. * @param scene The scene the camera belongs to
  37484. */
  37485. constructor(name: string, position: Vector3, scene: Scene);
  37486. /**
  37487. * @hidden
  37488. * Disabled pointer input on first orientation sensor update (Default: true)
  37489. */
  37490. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37491. private _dragFactor;
  37492. /**
  37493. * Enabled turning on the y axis when the orientation sensor is active
  37494. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37495. */
  37496. enableHorizontalDragging(dragFactor?: number): void;
  37497. /**
  37498. * Gets the current instance class name ("DeviceOrientationCamera").
  37499. * This helps avoiding instanceof at run time.
  37500. * @returns the class name
  37501. */
  37502. getClassName(): string;
  37503. /**
  37504. * @hidden
  37505. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37506. */
  37507. _checkInputs(): void;
  37508. /**
  37509. * Reset the camera to its default orientation on the specified axis only.
  37510. * @param axis The axis to reset
  37511. */
  37512. resetToCurrentRotation(axis?: Axis): void;
  37513. }
  37514. }
  37515. declare module BABYLON {
  37516. /**
  37517. * Defines supported buttons for XBox360 compatible gamepads
  37518. */
  37519. export enum Xbox360Button {
  37520. /** A */
  37521. A = 0,
  37522. /** B */
  37523. B = 1,
  37524. /** X */
  37525. X = 2,
  37526. /** Y */
  37527. Y = 3,
  37528. /** Start */
  37529. Start = 4,
  37530. /** Back */
  37531. Back = 5,
  37532. /** Left button */
  37533. LB = 6,
  37534. /** Right button */
  37535. RB = 7,
  37536. /** Left stick */
  37537. LeftStick = 8,
  37538. /** Right stick */
  37539. RightStick = 9
  37540. }
  37541. /** Defines values for XBox360 DPad */
  37542. export enum Xbox360Dpad {
  37543. /** Up */
  37544. Up = 0,
  37545. /** Down */
  37546. Down = 1,
  37547. /** Left */
  37548. Left = 2,
  37549. /** Right */
  37550. Right = 3
  37551. }
  37552. /**
  37553. * Defines a XBox360 gamepad
  37554. */
  37555. export class Xbox360Pad extends Gamepad {
  37556. private _leftTrigger;
  37557. private _rightTrigger;
  37558. private _onlefttriggerchanged;
  37559. private _onrighttriggerchanged;
  37560. private _onbuttondown;
  37561. private _onbuttonup;
  37562. private _ondpaddown;
  37563. private _ondpadup;
  37564. /** Observable raised when a button is pressed */
  37565. onButtonDownObservable: Observable<Xbox360Button>;
  37566. /** Observable raised when a button is released */
  37567. onButtonUpObservable: Observable<Xbox360Button>;
  37568. /** Observable raised when a pad is pressed */
  37569. onPadDownObservable: Observable<Xbox360Dpad>;
  37570. /** Observable raised when a pad is released */
  37571. onPadUpObservable: Observable<Xbox360Dpad>;
  37572. private _buttonA;
  37573. private _buttonB;
  37574. private _buttonX;
  37575. private _buttonY;
  37576. private _buttonBack;
  37577. private _buttonStart;
  37578. private _buttonLB;
  37579. private _buttonRB;
  37580. private _buttonLeftStick;
  37581. private _buttonRightStick;
  37582. private _dPadUp;
  37583. private _dPadDown;
  37584. private _dPadLeft;
  37585. private _dPadRight;
  37586. private _isXboxOnePad;
  37587. /**
  37588. * Creates a new XBox360 gamepad object
  37589. * @param id defines the id of this gamepad
  37590. * @param index defines its index
  37591. * @param gamepad defines the internal HTML gamepad object
  37592. * @param xboxOne defines if it is a XBox One gamepad
  37593. */
  37594. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37595. /**
  37596. * Defines the callback to call when left trigger is pressed
  37597. * @param callback defines the callback to use
  37598. */
  37599. onlefttriggerchanged(callback: (value: number) => void): void;
  37600. /**
  37601. * Defines the callback to call when right trigger is pressed
  37602. * @param callback defines the callback to use
  37603. */
  37604. onrighttriggerchanged(callback: (value: number) => void): void;
  37605. /**
  37606. * Gets the left trigger value
  37607. */
  37608. /**
  37609. * Sets the left trigger value
  37610. */
  37611. leftTrigger: number;
  37612. /**
  37613. * Gets the right trigger value
  37614. */
  37615. /**
  37616. * Sets the right trigger value
  37617. */
  37618. rightTrigger: number;
  37619. /**
  37620. * Defines the callback to call when a button is pressed
  37621. * @param callback defines the callback to use
  37622. */
  37623. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37624. /**
  37625. * Defines the callback to call when a button is released
  37626. * @param callback defines the callback to use
  37627. */
  37628. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37629. /**
  37630. * Defines the callback to call when a pad is pressed
  37631. * @param callback defines the callback to use
  37632. */
  37633. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37634. /**
  37635. * Defines the callback to call when a pad is released
  37636. * @param callback defines the callback to use
  37637. */
  37638. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37639. private _setButtonValue;
  37640. private _setDPadValue;
  37641. /**
  37642. * Gets the value of the `A` button
  37643. */
  37644. /**
  37645. * Sets the value of the `A` button
  37646. */
  37647. buttonA: number;
  37648. /**
  37649. * Gets the value of the `B` button
  37650. */
  37651. /**
  37652. * Sets the value of the `B` button
  37653. */
  37654. buttonB: number;
  37655. /**
  37656. * Gets the value of the `X` button
  37657. */
  37658. /**
  37659. * Sets the value of the `X` button
  37660. */
  37661. buttonX: number;
  37662. /**
  37663. * Gets the value of the `Y` button
  37664. */
  37665. /**
  37666. * Sets the value of the `Y` button
  37667. */
  37668. buttonY: number;
  37669. /**
  37670. * Gets the value of the `Start` button
  37671. */
  37672. /**
  37673. * Sets the value of the `Start` button
  37674. */
  37675. buttonStart: number;
  37676. /**
  37677. * Gets the value of the `Back` button
  37678. */
  37679. /**
  37680. * Sets the value of the `Back` button
  37681. */
  37682. buttonBack: number;
  37683. /**
  37684. * Gets the value of the `Left` button
  37685. */
  37686. /**
  37687. * Sets the value of the `Left` button
  37688. */
  37689. buttonLB: number;
  37690. /**
  37691. * Gets the value of the `Right` button
  37692. */
  37693. /**
  37694. * Sets the value of the `Right` button
  37695. */
  37696. buttonRB: number;
  37697. /**
  37698. * Gets the value of the Left joystick
  37699. */
  37700. /**
  37701. * Sets the value of the Left joystick
  37702. */
  37703. buttonLeftStick: number;
  37704. /**
  37705. * Gets the value of the Right joystick
  37706. */
  37707. /**
  37708. * Sets the value of the Right joystick
  37709. */
  37710. buttonRightStick: number;
  37711. /**
  37712. * Gets the value of D-pad up
  37713. */
  37714. /**
  37715. * Sets the value of D-pad up
  37716. */
  37717. dPadUp: number;
  37718. /**
  37719. * Gets the value of D-pad down
  37720. */
  37721. /**
  37722. * Sets the value of D-pad down
  37723. */
  37724. dPadDown: number;
  37725. /**
  37726. * Gets the value of D-pad left
  37727. */
  37728. /**
  37729. * Sets the value of D-pad left
  37730. */
  37731. dPadLeft: number;
  37732. /**
  37733. * Gets the value of D-pad right
  37734. */
  37735. /**
  37736. * Sets the value of D-pad right
  37737. */
  37738. dPadRight: number;
  37739. /**
  37740. * Force the gamepad to synchronize with device values
  37741. */
  37742. update(): void;
  37743. /**
  37744. * Disposes the gamepad
  37745. */
  37746. dispose(): void;
  37747. }
  37748. }
  37749. declare module BABYLON {
  37750. /**
  37751. * Manager for handling gamepads
  37752. */
  37753. export class GamepadManager {
  37754. private _scene?;
  37755. private _babylonGamepads;
  37756. private _oneGamepadConnected;
  37757. /** @hidden */
  37758. _isMonitoring: boolean;
  37759. private _gamepadEventSupported;
  37760. private _gamepadSupport;
  37761. /**
  37762. * observable to be triggered when the gamepad controller has been connected
  37763. */
  37764. onGamepadConnectedObservable: Observable<Gamepad>;
  37765. /**
  37766. * observable to be triggered when the gamepad controller has been disconnected
  37767. */
  37768. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37769. private _onGamepadConnectedEvent;
  37770. private _onGamepadDisconnectedEvent;
  37771. /**
  37772. * Initializes the gamepad manager
  37773. * @param _scene BabylonJS scene
  37774. */
  37775. constructor(_scene?: Scene | undefined);
  37776. /**
  37777. * The gamepads in the game pad manager
  37778. */
  37779. readonly gamepads: Gamepad[];
  37780. /**
  37781. * Get the gamepad controllers based on type
  37782. * @param type The type of gamepad controller
  37783. * @returns Nullable gamepad
  37784. */
  37785. getGamepadByType(type?: number): Nullable<Gamepad>;
  37786. /**
  37787. * Disposes the gamepad manager
  37788. */
  37789. dispose(): void;
  37790. private _addNewGamepad;
  37791. private _startMonitoringGamepads;
  37792. private _stopMonitoringGamepads;
  37793. /** @hidden */
  37794. _checkGamepadsStatus(): void;
  37795. private _updateGamepadObjects;
  37796. }
  37797. }
  37798. declare module BABYLON {
  37799. interface Scene {
  37800. /** @hidden */
  37801. _gamepadManager: Nullable<GamepadManager>;
  37802. /**
  37803. * Gets the gamepad manager associated with the scene
  37804. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37805. */
  37806. gamepadManager: GamepadManager;
  37807. }
  37808. /**
  37809. * Interface representing a free camera inputs manager
  37810. */
  37811. interface FreeCameraInputsManager {
  37812. /**
  37813. * Adds gamepad input support to the FreeCameraInputsManager.
  37814. * @returns the FreeCameraInputsManager
  37815. */
  37816. addGamepad(): FreeCameraInputsManager;
  37817. }
  37818. /**
  37819. * Interface representing an arc rotate camera inputs manager
  37820. */
  37821. interface ArcRotateCameraInputsManager {
  37822. /**
  37823. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37824. * @returns the camera inputs manager
  37825. */
  37826. addGamepad(): ArcRotateCameraInputsManager;
  37827. }
  37828. /**
  37829. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37830. */
  37831. export class GamepadSystemSceneComponent implements ISceneComponent {
  37832. /**
  37833. * The component name helpfull to identify the component in the list of scene components.
  37834. */
  37835. readonly name: string;
  37836. /**
  37837. * The scene the component belongs to.
  37838. */
  37839. scene: Scene;
  37840. /**
  37841. * Creates a new instance of the component for the given scene
  37842. * @param scene Defines the scene to register the component in
  37843. */
  37844. constructor(scene: Scene);
  37845. /**
  37846. * Registers the component in a given scene
  37847. */
  37848. register(): void;
  37849. /**
  37850. * Rebuilds the elements related to this component in case of
  37851. * context lost for instance.
  37852. */
  37853. rebuild(): void;
  37854. /**
  37855. * Disposes the component and the associated ressources
  37856. */
  37857. dispose(): void;
  37858. private _beforeCameraUpdate;
  37859. }
  37860. }
  37861. declare module BABYLON {
  37862. /**
  37863. * 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,
  37864. * which still works and will still be found in many Playgrounds.
  37865. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37866. */
  37867. export class UniversalCamera extends TouchCamera {
  37868. /**
  37869. * Defines the gamepad rotation sensiblity.
  37870. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37871. */
  37872. gamepadAngularSensibility: number;
  37873. /**
  37874. * Defines the gamepad move sensiblity.
  37875. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37876. */
  37877. gamepadMoveSensibility: number;
  37878. /**
  37879. * 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,
  37880. * which still works and will still be found in many Playgrounds.
  37881. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37882. * @param name Define the name of the camera in the scene
  37883. * @param position Define the start position of the camera in the scene
  37884. * @param scene Define the scene the camera belongs to
  37885. */
  37886. constructor(name: string, position: Vector3, scene: Scene);
  37887. /**
  37888. * Gets the current object class name.
  37889. * @return the class name
  37890. */
  37891. getClassName(): string;
  37892. }
  37893. }
  37894. declare module BABYLON {
  37895. /**
  37896. * This represents a FPS type of camera. This is only here for back compat purpose.
  37897. * Please use the UniversalCamera instead as both are identical.
  37898. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37899. */
  37900. export class GamepadCamera extends UniversalCamera {
  37901. /**
  37902. * Instantiates a new Gamepad Camera
  37903. * This represents a FPS type of camera. This is only here for back compat purpose.
  37904. * Please use the UniversalCamera instead as both are identical.
  37905. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37906. * @param name Define the name of the camera in the scene
  37907. * @param position Define the start position of the camera in the scene
  37908. * @param scene Define the scene the camera belongs to
  37909. */
  37910. constructor(name: string, position: Vector3, scene: Scene);
  37911. /**
  37912. * Gets the current object class name.
  37913. * @return the class name
  37914. */
  37915. getClassName(): string;
  37916. }
  37917. }
  37918. declare module BABYLON {
  37919. /** @hidden */
  37920. export var passPixelShader: {
  37921. name: string;
  37922. shader: string;
  37923. };
  37924. }
  37925. declare module BABYLON {
  37926. /** @hidden */
  37927. export var passCubePixelShader: {
  37928. name: string;
  37929. shader: string;
  37930. };
  37931. }
  37932. declare module BABYLON {
  37933. /**
  37934. * PassPostProcess which produces an output the same as it's input
  37935. */
  37936. export class PassPostProcess extends PostProcess {
  37937. /**
  37938. * Creates the PassPostProcess
  37939. * @param name The name of the effect.
  37940. * @param options The required width/height ratio to downsize to before computing the render pass.
  37941. * @param camera The camera to apply the render pass to.
  37942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37943. * @param engine The engine which the post process will be applied. (default: current engine)
  37944. * @param reusable If the post process can be reused on the same frame. (default: false)
  37945. * @param textureType The type of texture to be used when performing the post processing.
  37946. * @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)
  37947. */
  37948. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37949. }
  37950. /**
  37951. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37952. */
  37953. export class PassCubePostProcess extends PostProcess {
  37954. private _face;
  37955. /**
  37956. * Gets or sets the cube face to display.
  37957. * * 0 is +X
  37958. * * 1 is -X
  37959. * * 2 is +Y
  37960. * * 3 is -Y
  37961. * * 4 is +Z
  37962. * * 5 is -Z
  37963. */
  37964. face: number;
  37965. /**
  37966. * Creates the PassCubePostProcess
  37967. * @param name The name of the effect.
  37968. * @param options The required width/height ratio to downsize to before computing the render pass.
  37969. * @param camera The camera to apply the render pass to.
  37970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37971. * @param engine The engine which the post process will be applied. (default: current engine)
  37972. * @param reusable If the post process can be reused on the same frame. (default: false)
  37973. * @param textureType The type of texture to be used when performing the post processing.
  37974. * @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)
  37975. */
  37976. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37977. }
  37978. }
  37979. declare module BABYLON {
  37980. /** @hidden */
  37981. export var anaglyphPixelShader: {
  37982. name: string;
  37983. shader: string;
  37984. };
  37985. }
  37986. declare module BABYLON {
  37987. /**
  37988. * Postprocess used to generate anaglyphic rendering
  37989. */
  37990. export class AnaglyphPostProcess extends PostProcess {
  37991. private _passedProcess;
  37992. /**
  37993. * Creates a new AnaglyphPostProcess
  37994. * @param name defines postprocess name
  37995. * @param options defines creation options or target ratio scale
  37996. * @param rigCameras defines cameras using this postprocess
  37997. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37998. * @param engine defines hosting engine
  37999. * @param reusable defines if the postprocess will be reused multiple times per frame
  38000. */
  38001. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38002. }
  38003. }
  38004. declare module BABYLON {
  38005. /**
  38006. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38007. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38008. */
  38009. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38010. /**
  38011. * Creates a new AnaglyphArcRotateCamera
  38012. * @param name defines camera name
  38013. * @param alpha defines alpha angle (in radians)
  38014. * @param beta defines beta angle (in radians)
  38015. * @param radius defines radius
  38016. * @param target defines camera target
  38017. * @param interaxialDistance defines distance between each color axis
  38018. * @param scene defines the hosting scene
  38019. */
  38020. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38021. /**
  38022. * Gets camera class name
  38023. * @returns AnaglyphArcRotateCamera
  38024. */
  38025. getClassName(): string;
  38026. }
  38027. }
  38028. declare module BABYLON {
  38029. /**
  38030. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38031. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38032. */
  38033. export class AnaglyphFreeCamera extends FreeCamera {
  38034. /**
  38035. * Creates a new AnaglyphFreeCamera
  38036. * @param name defines camera name
  38037. * @param position defines initial position
  38038. * @param interaxialDistance defines distance between each color axis
  38039. * @param scene defines the hosting scene
  38040. */
  38041. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38042. /**
  38043. * Gets camera class name
  38044. * @returns AnaglyphFreeCamera
  38045. */
  38046. getClassName(): string;
  38047. }
  38048. }
  38049. declare module BABYLON {
  38050. /**
  38051. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38052. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38053. */
  38054. export class AnaglyphGamepadCamera extends GamepadCamera {
  38055. /**
  38056. * Creates a new AnaglyphGamepadCamera
  38057. * @param name defines camera name
  38058. * @param position defines initial position
  38059. * @param interaxialDistance defines distance between each color axis
  38060. * @param scene defines the hosting scene
  38061. */
  38062. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38063. /**
  38064. * Gets camera class name
  38065. * @returns AnaglyphGamepadCamera
  38066. */
  38067. getClassName(): string;
  38068. }
  38069. }
  38070. declare module BABYLON {
  38071. /**
  38072. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38073. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38074. */
  38075. export class AnaglyphUniversalCamera extends UniversalCamera {
  38076. /**
  38077. * Creates a new AnaglyphUniversalCamera
  38078. * @param name defines camera name
  38079. * @param position defines initial position
  38080. * @param interaxialDistance defines distance between each color axis
  38081. * @param scene defines the hosting scene
  38082. */
  38083. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38084. /**
  38085. * Gets camera class name
  38086. * @returns AnaglyphUniversalCamera
  38087. */
  38088. getClassName(): string;
  38089. }
  38090. }
  38091. declare module BABYLON {
  38092. /** @hidden */
  38093. export var stereoscopicInterlacePixelShader: {
  38094. name: string;
  38095. shader: string;
  38096. };
  38097. }
  38098. declare module BABYLON {
  38099. /**
  38100. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38101. */
  38102. export class StereoscopicInterlacePostProcess extends PostProcess {
  38103. private _stepSize;
  38104. private _passedProcess;
  38105. /**
  38106. * Initializes a StereoscopicInterlacePostProcess
  38107. * @param name The name of the effect.
  38108. * @param rigCameras The rig cameras to be appled to the post process
  38109. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38111. * @param engine The engine which the post process will be applied. (default: current engine)
  38112. * @param reusable If the post process can be reused on the same frame. (default: false)
  38113. */
  38114. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38115. }
  38116. }
  38117. declare module BABYLON {
  38118. /**
  38119. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38120. * @see http://doc.babylonjs.com/features/cameras
  38121. */
  38122. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38123. /**
  38124. * Creates a new StereoscopicArcRotateCamera
  38125. * @param name defines camera name
  38126. * @param alpha defines alpha angle (in radians)
  38127. * @param beta defines beta angle (in radians)
  38128. * @param radius defines radius
  38129. * @param target defines camera target
  38130. * @param interaxialDistance defines distance between each color axis
  38131. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38132. * @param scene defines the hosting scene
  38133. */
  38134. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38135. /**
  38136. * Gets camera class name
  38137. * @returns StereoscopicArcRotateCamera
  38138. */
  38139. getClassName(): string;
  38140. }
  38141. }
  38142. declare module BABYLON {
  38143. /**
  38144. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38145. * @see http://doc.babylonjs.com/features/cameras
  38146. */
  38147. export class StereoscopicFreeCamera extends FreeCamera {
  38148. /**
  38149. * Creates a new StereoscopicFreeCamera
  38150. * @param name defines camera name
  38151. * @param position defines initial position
  38152. * @param interaxialDistance defines distance between each color axis
  38153. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38154. * @param scene defines the hosting scene
  38155. */
  38156. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38157. /**
  38158. * Gets camera class name
  38159. * @returns StereoscopicFreeCamera
  38160. */
  38161. getClassName(): string;
  38162. }
  38163. }
  38164. declare module BABYLON {
  38165. /**
  38166. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38167. * @see http://doc.babylonjs.com/features/cameras
  38168. */
  38169. export class StereoscopicGamepadCamera extends GamepadCamera {
  38170. /**
  38171. * Creates a new StereoscopicGamepadCamera
  38172. * @param name defines camera name
  38173. * @param position defines initial position
  38174. * @param interaxialDistance defines distance between each color axis
  38175. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38176. * @param scene defines the hosting scene
  38177. */
  38178. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38179. /**
  38180. * Gets camera class name
  38181. * @returns StereoscopicGamepadCamera
  38182. */
  38183. getClassName(): string;
  38184. }
  38185. }
  38186. declare module BABYLON {
  38187. /**
  38188. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38189. * @see http://doc.babylonjs.com/features/cameras
  38190. */
  38191. export class StereoscopicUniversalCamera extends UniversalCamera {
  38192. /**
  38193. * Creates a new StereoscopicUniversalCamera
  38194. * @param name defines camera name
  38195. * @param position defines initial position
  38196. * @param interaxialDistance defines distance between each color axis
  38197. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38198. * @param scene defines the hosting scene
  38199. */
  38200. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38201. /**
  38202. * Gets camera class name
  38203. * @returns StereoscopicUniversalCamera
  38204. */
  38205. getClassName(): string;
  38206. }
  38207. }
  38208. declare module BABYLON {
  38209. /**
  38210. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38211. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38212. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38213. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38214. */
  38215. export class VirtualJoysticksCamera extends FreeCamera {
  38216. /**
  38217. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38218. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38219. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38220. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38221. * @param name Define the name of the camera in the scene
  38222. * @param position Define the start position of the camera in the scene
  38223. * @param scene Define the scene the camera belongs to
  38224. */
  38225. constructor(name: string, position: Vector3, scene: Scene);
  38226. /**
  38227. * Gets the current object class name.
  38228. * @return the class name
  38229. */
  38230. getClassName(): string;
  38231. }
  38232. }
  38233. declare module BABYLON {
  38234. /**
  38235. * This represents all the required metrics to create a VR camera.
  38236. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38237. */
  38238. export class VRCameraMetrics {
  38239. /**
  38240. * Define the horizontal resolution off the screen.
  38241. */
  38242. hResolution: number;
  38243. /**
  38244. * Define the vertical resolution off the screen.
  38245. */
  38246. vResolution: number;
  38247. /**
  38248. * Define the horizontal screen size.
  38249. */
  38250. hScreenSize: number;
  38251. /**
  38252. * Define the vertical screen size.
  38253. */
  38254. vScreenSize: number;
  38255. /**
  38256. * Define the vertical screen center position.
  38257. */
  38258. vScreenCenter: number;
  38259. /**
  38260. * Define the distance of the eyes to the screen.
  38261. */
  38262. eyeToScreenDistance: number;
  38263. /**
  38264. * Define the distance between both lenses
  38265. */
  38266. lensSeparationDistance: number;
  38267. /**
  38268. * Define the distance between both viewer's eyes.
  38269. */
  38270. interpupillaryDistance: number;
  38271. /**
  38272. * Define the distortion factor of the VR postprocess.
  38273. * Please, touch with care.
  38274. */
  38275. distortionK: number[];
  38276. /**
  38277. * Define the chromatic aberration correction factors for the VR post process.
  38278. */
  38279. chromaAbCorrection: number[];
  38280. /**
  38281. * Define the scale factor of the post process.
  38282. * The smaller the better but the slower.
  38283. */
  38284. postProcessScaleFactor: number;
  38285. /**
  38286. * Define an offset for the lens center.
  38287. */
  38288. lensCenterOffset: number;
  38289. /**
  38290. * Define if the current vr camera should compensate the distortion of the lense or not.
  38291. */
  38292. compensateDistortion: boolean;
  38293. /**
  38294. * Defines if multiview should be enabled when rendering (Default: false)
  38295. */
  38296. multiviewEnabled: boolean;
  38297. /**
  38298. * Gets the rendering aspect ratio based on the provided resolutions.
  38299. */
  38300. readonly aspectRatio: number;
  38301. /**
  38302. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38303. */
  38304. readonly aspectRatioFov: number;
  38305. /**
  38306. * @hidden
  38307. */
  38308. readonly leftHMatrix: Matrix;
  38309. /**
  38310. * @hidden
  38311. */
  38312. readonly rightHMatrix: Matrix;
  38313. /**
  38314. * @hidden
  38315. */
  38316. readonly leftPreViewMatrix: Matrix;
  38317. /**
  38318. * @hidden
  38319. */
  38320. readonly rightPreViewMatrix: Matrix;
  38321. /**
  38322. * Get the default VRMetrics based on the most generic setup.
  38323. * @returns the default vr metrics
  38324. */
  38325. static GetDefault(): VRCameraMetrics;
  38326. }
  38327. }
  38328. declare module BABYLON {
  38329. /** @hidden */
  38330. export var vrDistortionCorrectionPixelShader: {
  38331. name: string;
  38332. shader: string;
  38333. };
  38334. }
  38335. declare module BABYLON {
  38336. /**
  38337. * VRDistortionCorrectionPostProcess used for mobile VR
  38338. */
  38339. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38340. private _isRightEye;
  38341. private _distortionFactors;
  38342. private _postProcessScaleFactor;
  38343. private _lensCenterOffset;
  38344. private _scaleIn;
  38345. private _scaleFactor;
  38346. private _lensCenter;
  38347. /**
  38348. * Initializes the VRDistortionCorrectionPostProcess
  38349. * @param name The name of the effect.
  38350. * @param camera The camera to apply the render pass to.
  38351. * @param isRightEye If this is for the right eye distortion
  38352. * @param vrMetrics All the required metrics for the VR camera
  38353. */
  38354. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38355. }
  38356. }
  38357. declare module BABYLON {
  38358. /**
  38359. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38360. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38361. */
  38362. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38363. /**
  38364. * Creates a new VRDeviceOrientationArcRotateCamera
  38365. * @param name defines camera name
  38366. * @param alpha defines the camera rotation along the logitudinal axis
  38367. * @param beta defines the camera rotation along the latitudinal axis
  38368. * @param radius defines the camera distance from its target
  38369. * @param target defines the camera target
  38370. * @param scene defines the scene the camera belongs to
  38371. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38372. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38373. */
  38374. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38375. /**
  38376. * Gets camera class name
  38377. * @returns VRDeviceOrientationArcRotateCamera
  38378. */
  38379. getClassName(): string;
  38380. }
  38381. }
  38382. declare module BABYLON {
  38383. /**
  38384. * Camera used to simulate VR rendering (based on FreeCamera)
  38385. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38386. */
  38387. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38388. /**
  38389. * Creates a new VRDeviceOrientationFreeCamera
  38390. * @param name defines camera name
  38391. * @param position defines the start position of the camera
  38392. * @param scene defines the scene the camera belongs to
  38393. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38394. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38395. */
  38396. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38397. /**
  38398. * Gets camera class name
  38399. * @returns VRDeviceOrientationFreeCamera
  38400. */
  38401. getClassName(): string;
  38402. }
  38403. }
  38404. declare module BABYLON {
  38405. /**
  38406. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38407. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38408. */
  38409. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38410. /**
  38411. * Creates a new VRDeviceOrientationGamepadCamera
  38412. * @param name defines camera name
  38413. * @param position defines the start position of the camera
  38414. * @param scene defines the scene the camera belongs to
  38415. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38416. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38417. */
  38418. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38419. /**
  38420. * Gets camera class name
  38421. * @returns VRDeviceOrientationGamepadCamera
  38422. */
  38423. getClassName(): string;
  38424. }
  38425. }
  38426. declare module BABYLON {
  38427. /**
  38428. * Base class of materials working in push mode in babylon JS
  38429. * @hidden
  38430. */
  38431. export class PushMaterial extends Material {
  38432. protected _activeEffect: Effect;
  38433. protected _normalMatrix: Matrix;
  38434. /**
  38435. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38436. * This means that the material can keep using a previous shader while a new one is being compiled.
  38437. * This is mostly used when shader parallel compilation is supported (true by default)
  38438. */
  38439. allowShaderHotSwapping: boolean;
  38440. constructor(name: string, scene: Scene);
  38441. getEffect(): Effect;
  38442. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38443. /**
  38444. * Binds the given world matrix to the active effect
  38445. *
  38446. * @param world the matrix to bind
  38447. */
  38448. bindOnlyWorldMatrix(world: Matrix): void;
  38449. /**
  38450. * Binds the given normal matrix to the active effect
  38451. *
  38452. * @param normalMatrix the matrix to bind
  38453. */
  38454. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38455. bind(world: Matrix, mesh?: Mesh): void;
  38456. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38457. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38458. }
  38459. }
  38460. declare module BABYLON {
  38461. /**
  38462. * This groups all the flags used to control the materials channel.
  38463. */
  38464. export class MaterialFlags {
  38465. private static _DiffuseTextureEnabled;
  38466. /**
  38467. * Are diffuse textures enabled in the application.
  38468. */
  38469. static DiffuseTextureEnabled: boolean;
  38470. private static _AmbientTextureEnabled;
  38471. /**
  38472. * Are ambient textures enabled in the application.
  38473. */
  38474. static AmbientTextureEnabled: boolean;
  38475. private static _OpacityTextureEnabled;
  38476. /**
  38477. * Are opacity textures enabled in the application.
  38478. */
  38479. static OpacityTextureEnabled: boolean;
  38480. private static _ReflectionTextureEnabled;
  38481. /**
  38482. * Are reflection textures enabled in the application.
  38483. */
  38484. static ReflectionTextureEnabled: boolean;
  38485. private static _EmissiveTextureEnabled;
  38486. /**
  38487. * Are emissive textures enabled in the application.
  38488. */
  38489. static EmissiveTextureEnabled: boolean;
  38490. private static _SpecularTextureEnabled;
  38491. /**
  38492. * Are specular textures enabled in the application.
  38493. */
  38494. static SpecularTextureEnabled: boolean;
  38495. private static _BumpTextureEnabled;
  38496. /**
  38497. * Are bump textures enabled in the application.
  38498. */
  38499. static BumpTextureEnabled: boolean;
  38500. private static _LightmapTextureEnabled;
  38501. /**
  38502. * Are lightmap textures enabled in the application.
  38503. */
  38504. static LightmapTextureEnabled: boolean;
  38505. private static _RefractionTextureEnabled;
  38506. /**
  38507. * Are refraction textures enabled in the application.
  38508. */
  38509. static RefractionTextureEnabled: boolean;
  38510. private static _ColorGradingTextureEnabled;
  38511. /**
  38512. * Are color grading textures enabled in the application.
  38513. */
  38514. static ColorGradingTextureEnabled: boolean;
  38515. private static _FresnelEnabled;
  38516. /**
  38517. * Are fresnels enabled in the application.
  38518. */
  38519. static FresnelEnabled: boolean;
  38520. private static _ClearCoatTextureEnabled;
  38521. /**
  38522. * Are clear coat textures enabled in the application.
  38523. */
  38524. static ClearCoatTextureEnabled: boolean;
  38525. private static _ClearCoatBumpTextureEnabled;
  38526. /**
  38527. * Are clear coat bump textures enabled in the application.
  38528. */
  38529. static ClearCoatBumpTextureEnabled: boolean;
  38530. private static _ClearCoatTintTextureEnabled;
  38531. /**
  38532. * Are clear coat tint textures enabled in the application.
  38533. */
  38534. static ClearCoatTintTextureEnabled: boolean;
  38535. private static _SheenTextureEnabled;
  38536. /**
  38537. * Are sheen textures enabled in the application.
  38538. */
  38539. static SheenTextureEnabled: boolean;
  38540. private static _AnisotropicTextureEnabled;
  38541. /**
  38542. * Are anisotropic textures enabled in the application.
  38543. */
  38544. static AnisotropicTextureEnabled: boolean;
  38545. private static _ThicknessTextureEnabled;
  38546. /**
  38547. * Are thickness textures enabled in the application.
  38548. */
  38549. static ThicknessTextureEnabled: boolean;
  38550. }
  38551. }
  38552. declare module BABYLON {
  38553. /** @hidden */
  38554. export var defaultFragmentDeclaration: {
  38555. name: string;
  38556. shader: string;
  38557. };
  38558. }
  38559. declare module BABYLON {
  38560. /** @hidden */
  38561. export var defaultUboDeclaration: {
  38562. name: string;
  38563. shader: string;
  38564. };
  38565. }
  38566. declare module BABYLON {
  38567. /** @hidden */
  38568. export var lightFragmentDeclaration: {
  38569. name: string;
  38570. shader: string;
  38571. };
  38572. }
  38573. declare module BABYLON {
  38574. /** @hidden */
  38575. export var lightUboDeclaration: {
  38576. name: string;
  38577. shader: string;
  38578. };
  38579. }
  38580. declare module BABYLON {
  38581. /** @hidden */
  38582. export var lightsFragmentFunctions: {
  38583. name: string;
  38584. shader: string;
  38585. };
  38586. }
  38587. declare module BABYLON {
  38588. /** @hidden */
  38589. export var shadowsFragmentFunctions: {
  38590. name: string;
  38591. shader: string;
  38592. };
  38593. }
  38594. declare module BABYLON {
  38595. /** @hidden */
  38596. export var fresnelFunction: {
  38597. name: string;
  38598. shader: string;
  38599. };
  38600. }
  38601. declare module BABYLON {
  38602. /** @hidden */
  38603. export var reflectionFunction: {
  38604. name: string;
  38605. shader: string;
  38606. };
  38607. }
  38608. declare module BABYLON {
  38609. /** @hidden */
  38610. export var bumpFragmentFunctions: {
  38611. name: string;
  38612. shader: string;
  38613. };
  38614. }
  38615. declare module BABYLON {
  38616. /** @hidden */
  38617. export var logDepthDeclaration: {
  38618. name: string;
  38619. shader: string;
  38620. };
  38621. }
  38622. declare module BABYLON {
  38623. /** @hidden */
  38624. export var bumpFragment: {
  38625. name: string;
  38626. shader: string;
  38627. };
  38628. }
  38629. declare module BABYLON {
  38630. /** @hidden */
  38631. export var depthPrePass: {
  38632. name: string;
  38633. shader: string;
  38634. };
  38635. }
  38636. declare module BABYLON {
  38637. /** @hidden */
  38638. export var lightFragment: {
  38639. name: string;
  38640. shader: string;
  38641. };
  38642. }
  38643. declare module BABYLON {
  38644. /** @hidden */
  38645. export var logDepthFragment: {
  38646. name: string;
  38647. shader: string;
  38648. };
  38649. }
  38650. declare module BABYLON {
  38651. /** @hidden */
  38652. export var defaultPixelShader: {
  38653. name: string;
  38654. shader: string;
  38655. };
  38656. }
  38657. declare module BABYLON {
  38658. /** @hidden */
  38659. export var defaultVertexDeclaration: {
  38660. name: string;
  38661. shader: string;
  38662. };
  38663. }
  38664. declare module BABYLON {
  38665. /** @hidden */
  38666. export var bumpVertexDeclaration: {
  38667. name: string;
  38668. shader: string;
  38669. };
  38670. }
  38671. declare module BABYLON {
  38672. /** @hidden */
  38673. export var bumpVertex: {
  38674. name: string;
  38675. shader: string;
  38676. };
  38677. }
  38678. declare module BABYLON {
  38679. /** @hidden */
  38680. export var fogVertex: {
  38681. name: string;
  38682. shader: string;
  38683. };
  38684. }
  38685. declare module BABYLON {
  38686. /** @hidden */
  38687. export var shadowsVertex: {
  38688. name: string;
  38689. shader: string;
  38690. };
  38691. }
  38692. declare module BABYLON {
  38693. /** @hidden */
  38694. export var pointCloudVertex: {
  38695. name: string;
  38696. shader: string;
  38697. };
  38698. }
  38699. declare module BABYLON {
  38700. /** @hidden */
  38701. export var logDepthVertex: {
  38702. name: string;
  38703. shader: string;
  38704. };
  38705. }
  38706. declare module BABYLON {
  38707. /** @hidden */
  38708. export var defaultVertexShader: {
  38709. name: string;
  38710. shader: string;
  38711. };
  38712. }
  38713. declare module BABYLON {
  38714. /** @hidden */
  38715. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38716. MAINUV1: boolean;
  38717. MAINUV2: boolean;
  38718. DIFFUSE: boolean;
  38719. DIFFUSEDIRECTUV: number;
  38720. AMBIENT: boolean;
  38721. AMBIENTDIRECTUV: number;
  38722. OPACITY: boolean;
  38723. OPACITYDIRECTUV: number;
  38724. OPACITYRGB: boolean;
  38725. REFLECTION: boolean;
  38726. EMISSIVE: boolean;
  38727. EMISSIVEDIRECTUV: number;
  38728. SPECULAR: boolean;
  38729. SPECULARDIRECTUV: number;
  38730. BUMP: boolean;
  38731. BUMPDIRECTUV: number;
  38732. PARALLAX: boolean;
  38733. PARALLAXOCCLUSION: boolean;
  38734. SPECULAROVERALPHA: boolean;
  38735. CLIPPLANE: boolean;
  38736. CLIPPLANE2: boolean;
  38737. CLIPPLANE3: boolean;
  38738. CLIPPLANE4: boolean;
  38739. ALPHATEST: boolean;
  38740. DEPTHPREPASS: boolean;
  38741. ALPHAFROMDIFFUSE: boolean;
  38742. POINTSIZE: boolean;
  38743. FOG: boolean;
  38744. SPECULARTERM: boolean;
  38745. DIFFUSEFRESNEL: boolean;
  38746. OPACITYFRESNEL: boolean;
  38747. REFLECTIONFRESNEL: boolean;
  38748. REFRACTIONFRESNEL: boolean;
  38749. EMISSIVEFRESNEL: boolean;
  38750. FRESNEL: boolean;
  38751. NORMAL: boolean;
  38752. UV1: boolean;
  38753. UV2: boolean;
  38754. VERTEXCOLOR: boolean;
  38755. VERTEXALPHA: boolean;
  38756. NUM_BONE_INFLUENCERS: number;
  38757. BonesPerMesh: number;
  38758. BONETEXTURE: boolean;
  38759. INSTANCES: boolean;
  38760. GLOSSINESS: boolean;
  38761. ROUGHNESS: boolean;
  38762. EMISSIVEASILLUMINATION: boolean;
  38763. LINKEMISSIVEWITHDIFFUSE: boolean;
  38764. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38765. LIGHTMAP: boolean;
  38766. LIGHTMAPDIRECTUV: number;
  38767. OBJECTSPACE_NORMALMAP: boolean;
  38768. USELIGHTMAPASSHADOWMAP: boolean;
  38769. REFLECTIONMAP_3D: boolean;
  38770. REFLECTIONMAP_SPHERICAL: boolean;
  38771. REFLECTIONMAP_PLANAR: boolean;
  38772. REFLECTIONMAP_CUBIC: boolean;
  38773. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38774. REFLECTIONMAP_PROJECTION: boolean;
  38775. REFLECTIONMAP_SKYBOX: boolean;
  38776. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38777. REFLECTIONMAP_EXPLICIT: boolean;
  38778. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38779. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38780. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38781. INVERTCUBICMAP: boolean;
  38782. LOGARITHMICDEPTH: boolean;
  38783. REFRACTION: boolean;
  38784. REFRACTIONMAP_3D: boolean;
  38785. REFLECTIONOVERALPHA: boolean;
  38786. TWOSIDEDLIGHTING: boolean;
  38787. SHADOWFLOAT: boolean;
  38788. MORPHTARGETS: boolean;
  38789. MORPHTARGETS_NORMAL: boolean;
  38790. MORPHTARGETS_TANGENT: boolean;
  38791. NUM_MORPH_INFLUENCERS: number;
  38792. NONUNIFORMSCALING: boolean;
  38793. PREMULTIPLYALPHA: boolean;
  38794. IMAGEPROCESSING: boolean;
  38795. VIGNETTE: boolean;
  38796. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38797. VIGNETTEBLENDMODEOPAQUE: boolean;
  38798. TONEMAPPING: boolean;
  38799. TONEMAPPING_ACES: boolean;
  38800. CONTRAST: boolean;
  38801. COLORCURVES: boolean;
  38802. COLORGRADING: boolean;
  38803. COLORGRADING3D: boolean;
  38804. SAMPLER3DGREENDEPTH: boolean;
  38805. SAMPLER3DBGRMAP: boolean;
  38806. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38807. MULTIVIEW: boolean;
  38808. /**
  38809. * If the reflection texture on this material is in linear color space
  38810. * @hidden
  38811. */
  38812. IS_REFLECTION_LINEAR: boolean;
  38813. /**
  38814. * If the refraction texture on this material is in linear color space
  38815. * @hidden
  38816. */
  38817. IS_REFRACTION_LINEAR: boolean;
  38818. EXPOSURE: boolean;
  38819. constructor();
  38820. setReflectionMode(modeToEnable: string): void;
  38821. }
  38822. /**
  38823. * This is the default material used in Babylon. It is the best trade off between quality
  38824. * and performances.
  38825. * @see http://doc.babylonjs.com/babylon101/materials
  38826. */
  38827. export class StandardMaterial extends PushMaterial {
  38828. private _diffuseTexture;
  38829. /**
  38830. * The basic texture of the material as viewed under a light.
  38831. */
  38832. diffuseTexture: Nullable<BaseTexture>;
  38833. private _ambientTexture;
  38834. /**
  38835. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38836. */
  38837. ambientTexture: Nullable<BaseTexture>;
  38838. private _opacityTexture;
  38839. /**
  38840. * Define the transparency of the material from a texture.
  38841. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38842. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38843. */
  38844. opacityTexture: Nullable<BaseTexture>;
  38845. private _reflectionTexture;
  38846. /**
  38847. * Define the texture used to display the reflection.
  38848. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38849. */
  38850. reflectionTexture: Nullable<BaseTexture>;
  38851. private _emissiveTexture;
  38852. /**
  38853. * Define texture of the material as if self lit.
  38854. * This will be mixed in the final result even in the absence of light.
  38855. */
  38856. emissiveTexture: Nullable<BaseTexture>;
  38857. private _specularTexture;
  38858. /**
  38859. * Define how the color and intensity of the highlight given by the light in the material.
  38860. */
  38861. specularTexture: Nullable<BaseTexture>;
  38862. private _bumpTexture;
  38863. /**
  38864. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38865. * 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.
  38866. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38867. */
  38868. bumpTexture: Nullable<BaseTexture>;
  38869. private _lightmapTexture;
  38870. /**
  38871. * Complex lighting can be computationally expensive to compute at runtime.
  38872. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38873. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38874. */
  38875. lightmapTexture: Nullable<BaseTexture>;
  38876. private _refractionTexture;
  38877. /**
  38878. * Define the texture used to display the refraction.
  38879. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38880. */
  38881. refractionTexture: Nullable<BaseTexture>;
  38882. /**
  38883. * The color of the material lit by the environmental background lighting.
  38884. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38885. */
  38886. ambientColor: Color3;
  38887. /**
  38888. * The basic color of the material as viewed under a light.
  38889. */
  38890. diffuseColor: Color3;
  38891. /**
  38892. * Define how the color and intensity of the highlight given by the light in the material.
  38893. */
  38894. specularColor: Color3;
  38895. /**
  38896. * Define the color of the material as if self lit.
  38897. * This will be mixed in the final result even in the absence of light.
  38898. */
  38899. emissiveColor: Color3;
  38900. /**
  38901. * Defines how sharp are the highlights in the material.
  38902. * The bigger the value the sharper giving a more glossy feeling to the result.
  38903. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38904. */
  38905. specularPower: number;
  38906. private _useAlphaFromDiffuseTexture;
  38907. /**
  38908. * Does the transparency come from the diffuse texture alpha channel.
  38909. */
  38910. useAlphaFromDiffuseTexture: boolean;
  38911. private _useEmissiveAsIllumination;
  38912. /**
  38913. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38914. */
  38915. useEmissiveAsIllumination: boolean;
  38916. private _linkEmissiveWithDiffuse;
  38917. /**
  38918. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38919. * the emissive level when the final color is close to one.
  38920. */
  38921. linkEmissiveWithDiffuse: boolean;
  38922. private _useSpecularOverAlpha;
  38923. /**
  38924. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38925. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38926. */
  38927. useSpecularOverAlpha: boolean;
  38928. private _useReflectionOverAlpha;
  38929. /**
  38930. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38931. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38932. */
  38933. useReflectionOverAlpha: boolean;
  38934. private _disableLighting;
  38935. /**
  38936. * Does lights from the scene impacts this material.
  38937. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38938. */
  38939. disableLighting: boolean;
  38940. private _useObjectSpaceNormalMap;
  38941. /**
  38942. * Allows using an object space normal map (instead of tangent space).
  38943. */
  38944. useObjectSpaceNormalMap: boolean;
  38945. private _useParallax;
  38946. /**
  38947. * Is parallax enabled or not.
  38948. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38949. */
  38950. useParallax: boolean;
  38951. private _useParallaxOcclusion;
  38952. /**
  38953. * Is parallax occlusion enabled or not.
  38954. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38955. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38956. */
  38957. useParallaxOcclusion: boolean;
  38958. /**
  38959. * 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.
  38960. */
  38961. parallaxScaleBias: number;
  38962. private _roughness;
  38963. /**
  38964. * Helps to define how blurry the reflections should appears in the material.
  38965. */
  38966. roughness: number;
  38967. /**
  38968. * In case of refraction, define the value of the indice of refraction.
  38969. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38970. */
  38971. indexOfRefraction: number;
  38972. /**
  38973. * Invert the refraction texture alongside the y axis.
  38974. * It can be useful with procedural textures or probe for instance.
  38975. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38976. */
  38977. invertRefractionY: boolean;
  38978. /**
  38979. * Defines the alpha limits in alpha test mode.
  38980. */
  38981. alphaCutOff: number;
  38982. private _useLightmapAsShadowmap;
  38983. /**
  38984. * In case of light mapping, define whether the map contains light or shadow informations.
  38985. */
  38986. useLightmapAsShadowmap: boolean;
  38987. private _diffuseFresnelParameters;
  38988. /**
  38989. * Define the diffuse fresnel parameters of the material.
  38990. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38991. */
  38992. diffuseFresnelParameters: FresnelParameters;
  38993. private _opacityFresnelParameters;
  38994. /**
  38995. * Define the opacity fresnel parameters of the material.
  38996. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38997. */
  38998. opacityFresnelParameters: FresnelParameters;
  38999. private _reflectionFresnelParameters;
  39000. /**
  39001. * Define the reflection fresnel parameters of the material.
  39002. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39003. */
  39004. reflectionFresnelParameters: FresnelParameters;
  39005. private _refractionFresnelParameters;
  39006. /**
  39007. * Define the refraction fresnel parameters of the material.
  39008. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39009. */
  39010. refractionFresnelParameters: FresnelParameters;
  39011. private _emissiveFresnelParameters;
  39012. /**
  39013. * Define the emissive fresnel parameters of the material.
  39014. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39015. */
  39016. emissiveFresnelParameters: FresnelParameters;
  39017. private _useReflectionFresnelFromSpecular;
  39018. /**
  39019. * If true automatically deducts the fresnels values from the material specularity.
  39020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39021. */
  39022. useReflectionFresnelFromSpecular: boolean;
  39023. private _useGlossinessFromSpecularMapAlpha;
  39024. /**
  39025. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39026. */
  39027. useGlossinessFromSpecularMapAlpha: boolean;
  39028. private _maxSimultaneousLights;
  39029. /**
  39030. * Defines the maximum number of lights that can be used in the material
  39031. */
  39032. maxSimultaneousLights: number;
  39033. private _invertNormalMapX;
  39034. /**
  39035. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39036. */
  39037. invertNormalMapX: boolean;
  39038. private _invertNormalMapY;
  39039. /**
  39040. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39041. */
  39042. invertNormalMapY: boolean;
  39043. private _twoSidedLighting;
  39044. /**
  39045. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39046. */
  39047. twoSidedLighting: boolean;
  39048. /**
  39049. * Default configuration related to image processing available in the standard Material.
  39050. */
  39051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39052. /**
  39053. * Gets the image processing configuration used either in this material.
  39054. */
  39055. /**
  39056. * Sets the Default image processing configuration used either in the this material.
  39057. *
  39058. * If sets to null, the scene one is in use.
  39059. */
  39060. imageProcessingConfiguration: ImageProcessingConfiguration;
  39061. /**
  39062. * Keep track of the image processing observer to allow dispose and replace.
  39063. */
  39064. private _imageProcessingObserver;
  39065. /**
  39066. * Attaches a new image processing configuration to the Standard Material.
  39067. * @param configuration
  39068. */
  39069. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39070. /**
  39071. * Gets wether the color curves effect is enabled.
  39072. */
  39073. /**
  39074. * Sets wether the color curves effect is enabled.
  39075. */
  39076. cameraColorCurvesEnabled: boolean;
  39077. /**
  39078. * Gets wether the color grading effect is enabled.
  39079. */
  39080. /**
  39081. * Gets wether the color grading effect is enabled.
  39082. */
  39083. cameraColorGradingEnabled: boolean;
  39084. /**
  39085. * Gets wether tonemapping is enabled or not.
  39086. */
  39087. /**
  39088. * Sets wether tonemapping is enabled or not
  39089. */
  39090. cameraToneMappingEnabled: boolean;
  39091. /**
  39092. * The camera exposure used on this material.
  39093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39094. * This corresponds to a photographic exposure.
  39095. */
  39096. /**
  39097. * The camera exposure used on this material.
  39098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39099. * This corresponds to a photographic exposure.
  39100. */
  39101. cameraExposure: number;
  39102. /**
  39103. * Gets The camera contrast used on this material.
  39104. */
  39105. /**
  39106. * Sets The camera contrast used on this material.
  39107. */
  39108. cameraContrast: number;
  39109. /**
  39110. * Gets the Color Grading 2D Lookup Texture.
  39111. */
  39112. /**
  39113. * Sets the Color Grading 2D Lookup Texture.
  39114. */
  39115. cameraColorGradingTexture: Nullable<BaseTexture>;
  39116. /**
  39117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39119. * 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;
  39120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39121. */
  39122. /**
  39123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39125. * 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;
  39126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39127. */
  39128. cameraColorCurves: Nullable<ColorCurves>;
  39129. /**
  39130. * Custom callback helping to override the default shader used in the material.
  39131. */
  39132. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39133. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39134. protected _worldViewProjectionMatrix: Matrix;
  39135. protected _globalAmbientColor: Color3;
  39136. protected _useLogarithmicDepth: boolean;
  39137. /**
  39138. * Instantiates a new standard material.
  39139. * This is the default material used in Babylon. It is the best trade off between quality
  39140. * and performances.
  39141. * @see http://doc.babylonjs.com/babylon101/materials
  39142. * @param name Define the name of the material in the scene
  39143. * @param scene Define the scene the material belong to
  39144. */
  39145. constructor(name: string, scene: Scene);
  39146. /**
  39147. * Gets a boolean indicating that current material needs to register RTT
  39148. */
  39149. readonly hasRenderTargetTextures: boolean;
  39150. /**
  39151. * Gets the current class name of the material e.g. "StandardMaterial"
  39152. * Mainly use in serialization.
  39153. * @returns the class name
  39154. */
  39155. getClassName(): string;
  39156. /**
  39157. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39158. * You can try switching to logarithmic depth.
  39159. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39160. */
  39161. useLogarithmicDepth: boolean;
  39162. /**
  39163. * Specifies if the material will require alpha blending
  39164. * @returns a boolean specifying if alpha blending is needed
  39165. */
  39166. needAlphaBlending(): boolean;
  39167. /**
  39168. * Specifies if this material should be rendered in alpha test mode
  39169. * @returns a boolean specifying if an alpha test is needed.
  39170. */
  39171. needAlphaTesting(): boolean;
  39172. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39173. /**
  39174. * Get the texture used for alpha test purpose.
  39175. * @returns the diffuse texture in case of the standard material.
  39176. */
  39177. getAlphaTestTexture(): Nullable<BaseTexture>;
  39178. /**
  39179. * Get if the submesh is ready to be used and all its information available.
  39180. * Child classes can use it to update shaders
  39181. * @param mesh defines the mesh to check
  39182. * @param subMesh defines which submesh to check
  39183. * @param useInstances specifies that instances should be used
  39184. * @returns a boolean indicating that the submesh is ready or not
  39185. */
  39186. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39187. /**
  39188. * Builds the material UBO layouts.
  39189. * Used internally during the effect preparation.
  39190. */
  39191. buildUniformLayout(): void;
  39192. /**
  39193. * Unbinds the material from the mesh
  39194. */
  39195. unbind(): void;
  39196. /**
  39197. * Binds the submesh to this material by preparing the effect and shader to draw
  39198. * @param world defines the world transformation matrix
  39199. * @param mesh defines the mesh containing the submesh
  39200. * @param subMesh defines the submesh to bind the material to
  39201. */
  39202. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39203. /**
  39204. * Get the list of animatables in the material.
  39205. * @returns the list of animatables object used in the material
  39206. */
  39207. getAnimatables(): IAnimatable[];
  39208. /**
  39209. * Gets the active textures from the material
  39210. * @returns an array of textures
  39211. */
  39212. getActiveTextures(): BaseTexture[];
  39213. /**
  39214. * Specifies if the material uses a texture
  39215. * @param texture defines the texture to check against the material
  39216. * @returns a boolean specifying if the material uses the texture
  39217. */
  39218. hasTexture(texture: BaseTexture): boolean;
  39219. /**
  39220. * Disposes the material
  39221. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39222. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39223. */
  39224. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39225. /**
  39226. * Makes a duplicate of the material, and gives it a new name
  39227. * @param name defines the new name for the duplicated material
  39228. * @returns the cloned material
  39229. */
  39230. clone(name: string): StandardMaterial;
  39231. /**
  39232. * Serializes this material in a JSON representation
  39233. * @returns the serialized material object
  39234. */
  39235. serialize(): any;
  39236. /**
  39237. * Creates a standard material from parsed material data
  39238. * @param source defines the JSON representation of the material
  39239. * @param scene defines the hosting scene
  39240. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39241. * @returns a new standard material
  39242. */
  39243. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39244. /**
  39245. * Are diffuse textures enabled in the application.
  39246. */
  39247. static DiffuseTextureEnabled: boolean;
  39248. /**
  39249. * Are ambient textures enabled in the application.
  39250. */
  39251. static AmbientTextureEnabled: boolean;
  39252. /**
  39253. * Are opacity textures enabled in the application.
  39254. */
  39255. static OpacityTextureEnabled: boolean;
  39256. /**
  39257. * Are reflection textures enabled in the application.
  39258. */
  39259. static ReflectionTextureEnabled: boolean;
  39260. /**
  39261. * Are emissive textures enabled in the application.
  39262. */
  39263. static EmissiveTextureEnabled: boolean;
  39264. /**
  39265. * Are specular textures enabled in the application.
  39266. */
  39267. static SpecularTextureEnabled: boolean;
  39268. /**
  39269. * Are bump textures enabled in the application.
  39270. */
  39271. static BumpTextureEnabled: boolean;
  39272. /**
  39273. * Are lightmap textures enabled in the application.
  39274. */
  39275. static LightmapTextureEnabled: boolean;
  39276. /**
  39277. * Are refraction textures enabled in the application.
  39278. */
  39279. static RefractionTextureEnabled: boolean;
  39280. /**
  39281. * Are color grading textures enabled in the application.
  39282. */
  39283. static ColorGradingTextureEnabled: boolean;
  39284. /**
  39285. * Are fresnels enabled in the application.
  39286. */
  39287. static FresnelEnabled: boolean;
  39288. }
  39289. }
  39290. declare module BABYLON {
  39291. /**
  39292. * A class extending Texture allowing drawing on a texture
  39293. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39294. */
  39295. export class DynamicTexture extends Texture {
  39296. private _generateMipMaps;
  39297. private _canvas;
  39298. private _context;
  39299. private _engine;
  39300. /**
  39301. * Creates a DynamicTexture
  39302. * @param name defines the name of the texture
  39303. * @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
  39304. * @param scene defines the scene where you want the texture
  39305. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39306. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39307. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39308. */
  39309. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39310. /**
  39311. * Get the current class name of the texture useful for serialization or dynamic coding.
  39312. * @returns "DynamicTexture"
  39313. */
  39314. getClassName(): string;
  39315. /**
  39316. * Gets the current state of canRescale
  39317. */
  39318. readonly canRescale: boolean;
  39319. private _recreate;
  39320. /**
  39321. * Scales the texture
  39322. * @param ratio the scale factor to apply to both width and height
  39323. */
  39324. scale(ratio: number): void;
  39325. /**
  39326. * Resizes the texture
  39327. * @param width the new width
  39328. * @param height the new height
  39329. */
  39330. scaleTo(width: number, height: number): void;
  39331. /**
  39332. * Gets the context of the canvas used by the texture
  39333. * @returns the canvas context of the dynamic texture
  39334. */
  39335. getContext(): CanvasRenderingContext2D;
  39336. /**
  39337. * Clears the texture
  39338. */
  39339. clear(): void;
  39340. /**
  39341. * Updates the texture
  39342. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39343. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39344. */
  39345. update(invertY?: boolean, premulAlpha?: boolean): void;
  39346. /**
  39347. * Draws text onto the texture
  39348. * @param text defines the text to be drawn
  39349. * @param x defines the placement of the text from the left
  39350. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39351. * @param font defines the font to be used with font-style, font-size, font-name
  39352. * @param color defines the color used for the text
  39353. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39354. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39355. * @param update defines whether texture is immediately update (default is true)
  39356. */
  39357. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39358. /**
  39359. * Clones the texture
  39360. * @returns the clone of the texture.
  39361. */
  39362. clone(): DynamicTexture;
  39363. /**
  39364. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39365. * @returns a serialized dynamic texture object
  39366. */
  39367. serialize(): any;
  39368. /** @hidden */
  39369. _rebuild(): void;
  39370. }
  39371. }
  39372. declare module BABYLON {
  39373. /** @hidden */
  39374. export var imageProcessingPixelShader: {
  39375. name: string;
  39376. shader: string;
  39377. };
  39378. }
  39379. declare module BABYLON {
  39380. /**
  39381. * ImageProcessingPostProcess
  39382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39383. */
  39384. export class ImageProcessingPostProcess extends PostProcess {
  39385. /**
  39386. * Default configuration related to image processing available in the PBR Material.
  39387. */
  39388. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39389. /**
  39390. * Gets the image processing configuration used either in this material.
  39391. */
  39392. /**
  39393. * Sets the Default image processing configuration used either in the this material.
  39394. *
  39395. * If sets to null, the scene one is in use.
  39396. */
  39397. imageProcessingConfiguration: ImageProcessingConfiguration;
  39398. /**
  39399. * Keep track of the image processing observer to allow dispose and replace.
  39400. */
  39401. private _imageProcessingObserver;
  39402. /**
  39403. * Attaches a new image processing configuration to the PBR Material.
  39404. * @param configuration
  39405. */
  39406. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39407. /**
  39408. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39409. */
  39410. /**
  39411. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39412. */
  39413. colorCurves: Nullable<ColorCurves>;
  39414. /**
  39415. * Gets wether the color curves effect is enabled.
  39416. */
  39417. /**
  39418. * Sets wether the color curves effect is enabled.
  39419. */
  39420. colorCurvesEnabled: boolean;
  39421. /**
  39422. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39423. */
  39424. /**
  39425. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39426. */
  39427. colorGradingTexture: Nullable<BaseTexture>;
  39428. /**
  39429. * Gets wether the color grading effect is enabled.
  39430. */
  39431. /**
  39432. * Gets wether the color grading effect is enabled.
  39433. */
  39434. colorGradingEnabled: boolean;
  39435. /**
  39436. * Gets exposure used in the effect.
  39437. */
  39438. /**
  39439. * Sets exposure used in the effect.
  39440. */
  39441. exposure: number;
  39442. /**
  39443. * Gets wether tonemapping is enabled or not.
  39444. */
  39445. /**
  39446. * Sets wether tonemapping is enabled or not
  39447. */
  39448. toneMappingEnabled: boolean;
  39449. /**
  39450. * Gets the type of tone mapping effect.
  39451. */
  39452. /**
  39453. * Sets the type of tone mapping effect.
  39454. */
  39455. toneMappingType: number;
  39456. /**
  39457. * Gets contrast used in the effect.
  39458. */
  39459. /**
  39460. * Sets contrast used in the effect.
  39461. */
  39462. contrast: number;
  39463. /**
  39464. * Gets Vignette stretch size.
  39465. */
  39466. /**
  39467. * Sets Vignette stretch size.
  39468. */
  39469. vignetteStretch: number;
  39470. /**
  39471. * Gets Vignette centre X Offset.
  39472. */
  39473. /**
  39474. * Sets Vignette centre X Offset.
  39475. */
  39476. vignetteCentreX: number;
  39477. /**
  39478. * Gets Vignette centre Y Offset.
  39479. */
  39480. /**
  39481. * Sets Vignette centre Y Offset.
  39482. */
  39483. vignetteCentreY: number;
  39484. /**
  39485. * Gets Vignette weight or intensity of the vignette effect.
  39486. */
  39487. /**
  39488. * Sets Vignette weight or intensity of the vignette effect.
  39489. */
  39490. vignetteWeight: number;
  39491. /**
  39492. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39493. * if vignetteEnabled is set to true.
  39494. */
  39495. /**
  39496. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39497. * if vignetteEnabled is set to true.
  39498. */
  39499. vignetteColor: Color4;
  39500. /**
  39501. * Gets Camera field of view used by the Vignette effect.
  39502. */
  39503. /**
  39504. * Sets Camera field of view used by the Vignette effect.
  39505. */
  39506. vignetteCameraFov: number;
  39507. /**
  39508. * Gets the vignette blend mode allowing different kind of effect.
  39509. */
  39510. /**
  39511. * Sets the vignette blend mode allowing different kind of effect.
  39512. */
  39513. vignetteBlendMode: number;
  39514. /**
  39515. * Gets wether the vignette effect is enabled.
  39516. */
  39517. /**
  39518. * Sets wether the vignette effect is enabled.
  39519. */
  39520. vignetteEnabled: boolean;
  39521. private _fromLinearSpace;
  39522. /**
  39523. * Gets wether the input of the processing is in Gamma or Linear Space.
  39524. */
  39525. /**
  39526. * Sets wether the input of the processing is in Gamma or Linear Space.
  39527. */
  39528. fromLinearSpace: boolean;
  39529. /**
  39530. * Defines cache preventing GC.
  39531. */
  39532. private _defines;
  39533. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39534. /**
  39535. * "ImageProcessingPostProcess"
  39536. * @returns "ImageProcessingPostProcess"
  39537. */
  39538. getClassName(): string;
  39539. protected _updateParameters(): void;
  39540. dispose(camera?: Camera): void;
  39541. }
  39542. }
  39543. declare module BABYLON {
  39544. /**
  39545. * Class containing static functions to help procedurally build meshes
  39546. */
  39547. export class GroundBuilder {
  39548. /**
  39549. * Creates a ground mesh
  39550. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39551. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39553. * @param name defines the name of the mesh
  39554. * @param options defines the options used to create the mesh
  39555. * @param scene defines the hosting scene
  39556. * @returns the ground mesh
  39557. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39558. */
  39559. static CreateGround(name: string, options: {
  39560. width?: number;
  39561. height?: number;
  39562. subdivisions?: number;
  39563. subdivisionsX?: number;
  39564. subdivisionsY?: number;
  39565. updatable?: boolean;
  39566. }, scene: any): Mesh;
  39567. /**
  39568. * Creates a tiled ground mesh
  39569. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39570. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39571. * * 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
  39572. * * 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
  39573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39574. * @param name defines the name of the mesh
  39575. * @param options defines the options used to create the mesh
  39576. * @param scene defines the hosting scene
  39577. * @returns the tiled ground mesh
  39578. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39579. */
  39580. static CreateTiledGround(name: string, options: {
  39581. xmin: number;
  39582. zmin: number;
  39583. xmax: number;
  39584. zmax: number;
  39585. subdivisions?: {
  39586. w: number;
  39587. h: number;
  39588. };
  39589. precision?: {
  39590. w: number;
  39591. h: number;
  39592. };
  39593. updatable?: boolean;
  39594. }, scene?: Nullable<Scene>): Mesh;
  39595. /**
  39596. * Creates a ground mesh from a height map
  39597. * * The parameter `url` sets the URL of the height map image resource.
  39598. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39599. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39600. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39601. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39602. * * 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.
  39603. * * 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).
  39604. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39606. * @param name defines the name of the mesh
  39607. * @param url defines the url to the height map
  39608. * @param options defines the options used to create the mesh
  39609. * @param scene defines the hosting scene
  39610. * @returns the ground mesh
  39611. * @see https://doc.babylonjs.com/babylon101/height_map
  39612. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39613. */
  39614. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39615. width?: number;
  39616. height?: number;
  39617. subdivisions?: number;
  39618. minHeight?: number;
  39619. maxHeight?: number;
  39620. colorFilter?: Color3;
  39621. alphaFilter?: number;
  39622. updatable?: boolean;
  39623. onReady?: (mesh: GroundMesh) => void;
  39624. }, scene?: Nullable<Scene>): GroundMesh;
  39625. }
  39626. }
  39627. declare module BABYLON {
  39628. /**
  39629. * Class containing static functions to help procedurally build meshes
  39630. */
  39631. export class TorusBuilder {
  39632. /**
  39633. * Creates a torus mesh
  39634. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39635. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39636. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39638. * * 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
  39639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39640. * @param name defines the name of the mesh
  39641. * @param options defines the options used to create the mesh
  39642. * @param scene defines the hosting scene
  39643. * @returns the torus mesh
  39644. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39645. */
  39646. static CreateTorus(name: string, options: {
  39647. diameter?: number;
  39648. thickness?: number;
  39649. tessellation?: number;
  39650. updatable?: boolean;
  39651. sideOrientation?: number;
  39652. frontUVs?: Vector4;
  39653. backUVs?: Vector4;
  39654. }, scene: any): Mesh;
  39655. }
  39656. }
  39657. declare module BABYLON {
  39658. /**
  39659. * Class containing static functions to help procedurally build meshes
  39660. */
  39661. export class CylinderBuilder {
  39662. /**
  39663. * Creates a cylinder or a cone mesh
  39664. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39665. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39666. * * 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.
  39667. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39668. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39669. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39670. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39671. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39672. * * 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).
  39673. * * 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
  39674. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39675. * * 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
  39676. * * 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.
  39677. * * If `enclose` is false, a ring surface is one element.
  39678. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39679. * * 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
  39680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39681. * * 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
  39682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39683. * @param name defines the name of the mesh
  39684. * @param options defines the options used to create the mesh
  39685. * @param scene defines the hosting scene
  39686. * @returns the cylinder mesh
  39687. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39688. */
  39689. static CreateCylinder(name: string, options: {
  39690. height?: number;
  39691. diameterTop?: number;
  39692. diameterBottom?: number;
  39693. diameter?: number;
  39694. tessellation?: number;
  39695. subdivisions?: number;
  39696. arc?: number;
  39697. faceColors?: Color4[];
  39698. faceUV?: Vector4[];
  39699. updatable?: boolean;
  39700. hasRings?: boolean;
  39701. enclose?: boolean;
  39702. sideOrientation?: number;
  39703. frontUVs?: Vector4;
  39704. backUVs?: Vector4;
  39705. }, scene: any): Mesh;
  39706. }
  39707. }
  39708. declare module BABYLON {
  39709. /**
  39710. * Options to modify the vr teleportation behavior.
  39711. */
  39712. export interface VRTeleportationOptions {
  39713. /**
  39714. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39715. */
  39716. floorMeshName?: string;
  39717. /**
  39718. * A list of meshes to be used as the teleportation floor. (default: empty)
  39719. */
  39720. floorMeshes?: Mesh[];
  39721. }
  39722. /**
  39723. * Options to modify the vr experience helper's behavior.
  39724. */
  39725. export interface VRExperienceHelperOptions extends WebVROptions {
  39726. /**
  39727. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39728. */
  39729. createDeviceOrientationCamera?: boolean;
  39730. /**
  39731. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39732. */
  39733. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39734. /**
  39735. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39736. */
  39737. laserToggle?: boolean;
  39738. /**
  39739. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39740. */
  39741. floorMeshes?: Mesh[];
  39742. /**
  39743. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39744. */
  39745. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39746. }
  39747. /**
  39748. * Event containing information after VR has been entered
  39749. */
  39750. export class OnAfterEnteringVRObservableEvent {
  39751. /**
  39752. * If entering vr was successful
  39753. */
  39754. success: boolean;
  39755. }
  39756. /**
  39757. * Helps to quickly add VR support to an existing scene.
  39758. * See http://doc.babylonjs.com/how_to/webvr_helper
  39759. */
  39760. export class VRExperienceHelper {
  39761. /** Options to modify the vr experience helper's behavior. */
  39762. webVROptions: VRExperienceHelperOptions;
  39763. private _scene;
  39764. private _position;
  39765. private _btnVR;
  39766. private _btnVRDisplayed;
  39767. private _webVRsupported;
  39768. private _webVRready;
  39769. private _webVRrequesting;
  39770. private _webVRpresenting;
  39771. private _hasEnteredVR;
  39772. private _fullscreenVRpresenting;
  39773. private _canvas;
  39774. private _webVRCamera;
  39775. private _vrDeviceOrientationCamera;
  39776. private _deviceOrientationCamera;
  39777. private _existingCamera;
  39778. private _onKeyDown;
  39779. private _onVrDisplayPresentChange;
  39780. private _onVRDisplayChanged;
  39781. private _onVRRequestPresentStart;
  39782. private _onVRRequestPresentComplete;
  39783. /**
  39784. * Observable raised right before entering VR.
  39785. */
  39786. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39787. /**
  39788. * Observable raised when entering VR has completed.
  39789. */
  39790. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39791. /**
  39792. * Observable raised when exiting VR.
  39793. */
  39794. onExitingVRObservable: Observable<VRExperienceHelper>;
  39795. /**
  39796. * Observable raised when controller mesh is loaded.
  39797. */
  39798. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39799. /** Return this.onEnteringVRObservable
  39800. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39801. */
  39802. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39803. /** Return this.onExitingVRObservable
  39804. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39805. */
  39806. readonly onExitingVR: Observable<VRExperienceHelper>;
  39807. /** Return this.onControllerMeshLoadedObservable
  39808. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39809. */
  39810. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39811. private _rayLength;
  39812. private _useCustomVRButton;
  39813. private _teleportationRequested;
  39814. private _teleportActive;
  39815. private _floorMeshName;
  39816. private _floorMeshesCollection;
  39817. private _rotationAllowed;
  39818. private _teleportBackwardsVector;
  39819. private _teleportationTarget;
  39820. private _isDefaultTeleportationTarget;
  39821. private _postProcessMove;
  39822. private _teleportationFillColor;
  39823. private _teleportationBorderColor;
  39824. private _rotationAngle;
  39825. private _haloCenter;
  39826. private _cameraGazer;
  39827. private _padSensibilityUp;
  39828. private _padSensibilityDown;
  39829. private _leftController;
  39830. private _rightController;
  39831. /**
  39832. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39833. */
  39834. onNewMeshSelected: Observable<AbstractMesh>;
  39835. /**
  39836. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39837. */
  39838. onNewMeshPicked: Observable<PickingInfo>;
  39839. private _circleEase;
  39840. /**
  39841. * Observable raised before camera teleportation
  39842. */
  39843. onBeforeCameraTeleport: Observable<Vector3>;
  39844. /**
  39845. * Observable raised after camera teleportation
  39846. */
  39847. onAfterCameraTeleport: Observable<Vector3>;
  39848. /**
  39849. * Observable raised when current selected mesh gets unselected
  39850. */
  39851. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39852. private _raySelectionPredicate;
  39853. /**
  39854. * To be optionaly changed by user to define custom ray selection
  39855. */
  39856. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39857. /**
  39858. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39859. */
  39860. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39861. /**
  39862. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39863. */
  39864. teleportationEnabled: boolean;
  39865. private _defaultHeight;
  39866. private _teleportationInitialized;
  39867. private _interactionsEnabled;
  39868. private _interactionsRequested;
  39869. private _displayGaze;
  39870. private _displayLaserPointer;
  39871. /**
  39872. * The mesh used to display where the user is going to teleport.
  39873. */
  39874. /**
  39875. * Sets the mesh to be used to display where the user is going to teleport.
  39876. */
  39877. teleportationTarget: Mesh;
  39878. /**
  39879. * 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
  39880. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39881. * See http://doc.babylonjs.com/resources/baking_transformations
  39882. */
  39883. gazeTrackerMesh: Mesh;
  39884. /**
  39885. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39886. */
  39887. updateGazeTrackerScale: boolean;
  39888. /**
  39889. * If the gaze trackers color should be updated when selecting meshes
  39890. */
  39891. updateGazeTrackerColor: boolean;
  39892. /**
  39893. * The gaze tracking mesh corresponding to the left controller
  39894. */
  39895. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39896. /**
  39897. * The gaze tracking mesh corresponding to the right controller
  39898. */
  39899. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39900. /**
  39901. * If the ray of the gaze should be displayed.
  39902. */
  39903. /**
  39904. * Sets if the ray of the gaze should be displayed.
  39905. */
  39906. displayGaze: boolean;
  39907. /**
  39908. * If the ray of the LaserPointer should be displayed.
  39909. */
  39910. /**
  39911. * Sets if the ray of the LaserPointer should be displayed.
  39912. */
  39913. displayLaserPointer: boolean;
  39914. /**
  39915. * The deviceOrientationCamera used as the camera when not in VR.
  39916. */
  39917. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39918. /**
  39919. * Based on the current WebVR support, returns the current VR camera used.
  39920. */
  39921. readonly currentVRCamera: Nullable<Camera>;
  39922. /**
  39923. * The webVRCamera which is used when in VR.
  39924. */
  39925. readonly webVRCamera: WebVRFreeCamera;
  39926. /**
  39927. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39928. */
  39929. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39930. private readonly _teleportationRequestInitiated;
  39931. /**
  39932. * Defines wether or not Pointer lock should be requested when switching to
  39933. * full screen.
  39934. */
  39935. requestPointerLockOnFullScreen: boolean;
  39936. /**
  39937. * Instantiates a VRExperienceHelper.
  39938. * Helps to quickly add VR support to an existing scene.
  39939. * @param scene The scene the VRExperienceHelper belongs to.
  39940. * @param webVROptions Options to modify the vr experience helper's behavior.
  39941. */
  39942. constructor(scene: Scene,
  39943. /** Options to modify the vr experience helper's behavior. */
  39944. webVROptions?: VRExperienceHelperOptions);
  39945. private _onDefaultMeshLoaded;
  39946. private _onResize;
  39947. private _onFullscreenChange;
  39948. /**
  39949. * Gets a value indicating if we are currently in VR mode.
  39950. */
  39951. readonly isInVRMode: boolean;
  39952. private onVrDisplayPresentChange;
  39953. private onVRDisplayChanged;
  39954. private moveButtonToBottomRight;
  39955. private displayVRButton;
  39956. private updateButtonVisibility;
  39957. private _cachedAngularSensibility;
  39958. /**
  39959. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39960. * Otherwise, will use the fullscreen API.
  39961. */
  39962. enterVR(): void;
  39963. /**
  39964. * Attempt to exit VR, or fullscreen.
  39965. */
  39966. exitVR(): void;
  39967. /**
  39968. * The position of the vr experience helper.
  39969. */
  39970. /**
  39971. * Sets the position of the vr experience helper.
  39972. */
  39973. position: Vector3;
  39974. /**
  39975. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39976. */
  39977. enableInteractions(): void;
  39978. private readonly _noControllerIsActive;
  39979. private beforeRender;
  39980. private _isTeleportationFloor;
  39981. /**
  39982. * Adds a floor mesh to be used for teleportation.
  39983. * @param floorMesh the mesh to be used for teleportation.
  39984. */
  39985. addFloorMesh(floorMesh: Mesh): void;
  39986. /**
  39987. * Removes a floor mesh from being used for teleportation.
  39988. * @param floorMesh the mesh to be removed.
  39989. */
  39990. removeFloorMesh(floorMesh: Mesh): void;
  39991. /**
  39992. * Enables interactions and teleportation using the VR controllers and gaze.
  39993. * @param vrTeleportationOptions options to modify teleportation behavior.
  39994. */
  39995. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39996. private _onNewGamepadConnected;
  39997. private _tryEnableInteractionOnController;
  39998. private _onNewGamepadDisconnected;
  39999. private _enableInteractionOnController;
  40000. private _checkTeleportWithRay;
  40001. private _checkRotate;
  40002. private _checkTeleportBackwards;
  40003. private _enableTeleportationOnController;
  40004. private _createTeleportationCircles;
  40005. private _displayTeleportationTarget;
  40006. private _hideTeleportationTarget;
  40007. private _rotateCamera;
  40008. private _moveTeleportationSelectorTo;
  40009. private _workingVector;
  40010. private _workingQuaternion;
  40011. private _workingMatrix;
  40012. /**
  40013. * Teleports the users feet to the desired location
  40014. * @param location The location where the user's feet should be placed
  40015. */
  40016. teleportCamera(location: Vector3): void;
  40017. private _convertNormalToDirectionOfRay;
  40018. private _castRayAndSelectObject;
  40019. private _notifySelectedMeshUnselected;
  40020. /**
  40021. * Sets the color of the laser ray from the vr controllers.
  40022. * @param color new color for the ray.
  40023. */
  40024. changeLaserColor(color: Color3): void;
  40025. /**
  40026. * Sets the color of the ray from the vr headsets gaze.
  40027. * @param color new color for the ray.
  40028. */
  40029. changeGazeColor(color: Color3): void;
  40030. /**
  40031. * Exits VR and disposes of the vr experience helper
  40032. */
  40033. dispose(): void;
  40034. /**
  40035. * Gets the name of the VRExperienceHelper class
  40036. * @returns "VRExperienceHelper"
  40037. */
  40038. getClassName(): string;
  40039. }
  40040. }
  40041. declare module BABYLON {
  40042. /**
  40043. * Manages an XRSession
  40044. * @see https://doc.babylonjs.com/how_to/webxr
  40045. */
  40046. export class WebXRSessionManager implements IDisposable {
  40047. private scene;
  40048. /**
  40049. * Fires every time a new xrFrame arrives which can be used to update the camera
  40050. */
  40051. onXRFrameObservable: Observable<any>;
  40052. /**
  40053. * Fires when the xr session is ended either by the device or manually done
  40054. */
  40055. onXRSessionEnded: Observable<any>;
  40056. /** @hidden */
  40057. _xrSession: XRSession;
  40058. /** @hidden */
  40059. _frameOfReference: XRFrameOfReference;
  40060. /** @hidden */
  40061. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40062. /** @hidden */
  40063. _currentXRFrame: Nullable<XRFrame>;
  40064. private _xrNavigator;
  40065. private _xrDevice;
  40066. private _tmpMatrix;
  40067. /**
  40068. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40069. * @param scene The scene which the session should be created for
  40070. */
  40071. constructor(scene: Scene);
  40072. /**
  40073. * Initializes the manager
  40074. * After initialization enterXR can be called to start an XR session
  40075. * @returns Promise which resolves after it is initialized
  40076. */
  40077. initializeAsync(): Promise<void>;
  40078. /**
  40079. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40080. * @param sessionCreationOptions xr options to create the session with
  40081. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40082. * @returns Promise which resolves after it enters XR
  40083. */
  40084. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40085. /**
  40086. * Stops the xrSession and restores the renderloop
  40087. * @returns Promise which resolves after it exits XR
  40088. */
  40089. exitXRAsync(): Promise<void>;
  40090. /**
  40091. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40092. * @param ray ray to cast into the environment
  40093. * @returns Promise which resolves with a collision point in the environment if it exists
  40094. */
  40095. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40096. /**
  40097. * Checks if a session would be supported for the creation options specified
  40098. * @param options creation options to check if they are supported
  40099. * @returns true if supported
  40100. */
  40101. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40102. /**
  40103. * @hidden
  40104. * Converts the render layer of xrSession to a render target
  40105. * @param session session to create render target for
  40106. * @param scene scene the new render target should be created for
  40107. */
  40108. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40109. /**
  40110. * Disposes of the session manager
  40111. */
  40112. dispose(): void;
  40113. }
  40114. }
  40115. declare module BABYLON {
  40116. /**
  40117. * WebXR Camera which holds the views for the xrSession
  40118. * @see https://doc.babylonjs.com/how_to/webxr
  40119. */
  40120. export class WebXRCamera extends FreeCamera {
  40121. private static _TmpMatrix;
  40122. /**
  40123. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40124. * @param name the name of the camera
  40125. * @param scene the scene to add the camera to
  40126. */
  40127. constructor(name: string, scene: Scene);
  40128. private _updateNumberOfRigCameras;
  40129. /** @hidden */
  40130. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40131. /**
  40132. * Updates the cameras position from the current pose information of the XR session
  40133. * @param xrSessionManager the session containing pose information
  40134. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40135. */
  40136. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40137. }
  40138. }
  40139. declare module BABYLON {
  40140. /**
  40141. * States of the webXR experience
  40142. */
  40143. export enum WebXRState {
  40144. /**
  40145. * Transitioning to being in XR mode
  40146. */
  40147. ENTERING_XR = 0,
  40148. /**
  40149. * Transitioning to non XR mode
  40150. */
  40151. EXITING_XR = 1,
  40152. /**
  40153. * In XR mode and presenting
  40154. */
  40155. IN_XR = 2,
  40156. /**
  40157. * Not entered XR mode
  40158. */
  40159. NOT_IN_XR = 3
  40160. }
  40161. /**
  40162. * Helper class used to enable XR
  40163. * @see https://doc.babylonjs.com/how_to/webxr
  40164. */
  40165. export class WebXRExperienceHelper implements IDisposable {
  40166. private scene;
  40167. /**
  40168. * 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
  40169. */
  40170. container: AbstractMesh;
  40171. /**
  40172. * Camera used to render xr content
  40173. */
  40174. camera: WebXRCamera;
  40175. /**
  40176. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40177. */
  40178. state: WebXRState;
  40179. private _setState;
  40180. private static _TmpVector;
  40181. /**
  40182. * Fires when the state of the experience helper has changed
  40183. */
  40184. onStateChangedObservable: Observable<WebXRState>;
  40185. /** @hidden */
  40186. _sessionManager: WebXRSessionManager;
  40187. private _nonVRCamera;
  40188. private _originalSceneAutoClear;
  40189. private _supported;
  40190. /**
  40191. * Creates the experience helper
  40192. * @param scene the scene to attach the experience helper to
  40193. * @returns a promise for the experience helper
  40194. */
  40195. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40196. /**
  40197. * Creates a WebXRExperienceHelper
  40198. * @param scene The scene the helper should be created in
  40199. */
  40200. private constructor();
  40201. /**
  40202. * Exits XR mode and returns the scene to its original state
  40203. * @returns promise that resolves after xr mode has exited
  40204. */
  40205. exitXRAsync(): Promise<void>;
  40206. /**
  40207. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40208. * @param sessionCreationOptions options for the XR session
  40209. * @param frameOfReference frame of reference of the XR session
  40210. * @returns promise that resolves after xr mode has entered
  40211. */
  40212. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40213. /**
  40214. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40215. * @param ray ray to cast into the environment
  40216. * @returns Promise which resolves with a collision point in the environment if it exists
  40217. */
  40218. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40219. /**
  40220. * Updates the global position of the camera by moving the camera's container
  40221. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40222. * @param position The desired global position of the camera
  40223. */
  40224. setPositionOfCameraUsingContainer(position: Vector3): void;
  40225. /**
  40226. * Rotates the xr camera by rotating the camera's container around the camera's position
  40227. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40228. * @param rotation the desired quaternion rotation to apply to the camera
  40229. */
  40230. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40231. /**
  40232. * Checks if the creation options are supported by the xr session
  40233. * @param options creation options
  40234. * @returns true if supported
  40235. */
  40236. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40237. /**
  40238. * Disposes of the experience helper
  40239. */
  40240. dispose(): void;
  40241. }
  40242. }
  40243. declare module BABYLON {
  40244. /**
  40245. * Button which can be used to enter a different mode of XR
  40246. */
  40247. export class WebXREnterExitUIButton {
  40248. /** button element */
  40249. element: HTMLElement;
  40250. /** XR initialization options for the button */
  40251. initializationOptions: XRSessionCreationOptions;
  40252. /**
  40253. * Creates a WebXREnterExitUIButton
  40254. * @param element button element
  40255. * @param initializationOptions XR initialization options for the button
  40256. */
  40257. constructor(
  40258. /** button element */
  40259. element: HTMLElement,
  40260. /** XR initialization options for the button */
  40261. initializationOptions: XRSessionCreationOptions);
  40262. /**
  40263. * Overwritable function which can be used to update the button's visuals when the state changes
  40264. * @param activeButton the current active button in the UI
  40265. */
  40266. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40267. }
  40268. /**
  40269. * Options to create the webXR UI
  40270. */
  40271. export class WebXREnterExitUIOptions {
  40272. /**
  40273. * Context to enter xr with
  40274. */
  40275. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40276. /**
  40277. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40278. */
  40279. customButtons?: Array<WebXREnterExitUIButton>;
  40280. }
  40281. /**
  40282. * UI to allow the user to enter/exit XR mode
  40283. */
  40284. export class WebXREnterExitUI implements IDisposable {
  40285. private scene;
  40286. private _overlay;
  40287. private _buttons;
  40288. private _activeButton;
  40289. /**
  40290. * Fired every time the active button is changed.
  40291. *
  40292. * When xr is entered via a button that launches xr that button will be the callback parameter
  40293. *
  40294. * When exiting xr the callback parameter will be null)
  40295. */
  40296. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40297. /**
  40298. * Creates UI to allow the user to enter/exit XR mode
  40299. * @param scene the scene to add the ui to
  40300. * @param helper the xr experience helper to enter/exit xr with
  40301. * @param options options to configure the UI
  40302. * @returns the created ui
  40303. */
  40304. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40305. private constructor();
  40306. private _updateButtons;
  40307. /**
  40308. * Disposes of the object
  40309. */
  40310. dispose(): void;
  40311. }
  40312. }
  40313. declare module BABYLON {
  40314. /**
  40315. * Represents an XR input
  40316. */
  40317. export class WebXRController {
  40318. /**
  40319. * 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
  40320. */
  40321. grip?: AbstractMesh;
  40322. /**
  40323. * Pointer which can be used to select objects or attach a visible laser to
  40324. */
  40325. pointer: AbstractMesh;
  40326. /**
  40327. * Creates the controller
  40328. * @see https://doc.babylonjs.com/how_to/webxr
  40329. * @param scene the scene which the controller should be associated to
  40330. */
  40331. constructor(scene: Scene);
  40332. /**
  40333. * Disposes of the object
  40334. */
  40335. dispose(): void;
  40336. }
  40337. /**
  40338. * XR input used to track XR inputs such as controllers/rays
  40339. */
  40340. export class WebXRInput implements IDisposable {
  40341. private helper;
  40342. /**
  40343. * XR controllers being tracked
  40344. */
  40345. controllers: Array<WebXRController>;
  40346. private _tmpMatrix;
  40347. private _frameObserver;
  40348. /**
  40349. * Initializes the WebXRInput
  40350. * @param helper experience helper which the input should be created for
  40351. */
  40352. constructor(helper: WebXRExperienceHelper);
  40353. /**
  40354. * Disposes of the object
  40355. */
  40356. dispose(): void;
  40357. }
  40358. }
  40359. declare module BABYLON {
  40360. /**
  40361. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40362. */
  40363. export class WebXRManagedOutputCanvas implements IDisposable {
  40364. private _canvas;
  40365. /**
  40366. * xrpresent context of the canvas which can be used to display/mirror xr content
  40367. */
  40368. canvasContext: Nullable<WebGLRenderingContext>;
  40369. /**
  40370. * Initializes the canvas to be added/removed upon entering/exiting xr
  40371. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40372. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40373. */
  40374. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40375. /**
  40376. * Disposes of the object
  40377. */
  40378. dispose(): void;
  40379. private _setManagedOutputCanvas;
  40380. private _addCanvas;
  40381. private _removeCanvas;
  40382. }
  40383. }
  40384. declare module BABYLON {
  40385. /**
  40386. * Contains an array of blocks representing the octree
  40387. */
  40388. export interface IOctreeContainer<T> {
  40389. /**
  40390. * Blocks within the octree
  40391. */
  40392. blocks: Array<OctreeBlock<T>>;
  40393. }
  40394. /**
  40395. * Class used to store a cell in an octree
  40396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40397. */
  40398. export class OctreeBlock<T> {
  40399. /**
  40400. * Gets the content of the current block
  40401. */
  40402. entries: T[];
  40403. /**
  40404. * Gets the list of block children
  40405. */
  40406. blocks: Array<OctreeBlock<T>>;
  40407. private _depth;
  40408. private _maxDepth;
  40409. private _capacity;
  40410. private _minPoint;
  40411. private _maxPoint;
  40412. private _boundingVectors;
  40413. private _creationFunc;
  40414. /**
  40415. * Creates a new block
  40416. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40417. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40418. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40419. * @param depth defines the current depth of this block in the octree
  40420. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40421. * @param creationFunc defines a callback to call when an element is added to the block
  40422. */
  40423. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40424. /**
  40425. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40426. */
  40427. readonly capacity: number;
  40428. /**
  40429. * Gets the minimum vector (in world space) of the block's bounding box
  40430. */
  40431. readonly minPoint: Vector3;
  40432. /**
  40433. * Gets the maximum vector (in world space) of the block's bounding box
  40434. */
  40435. readonly maxPoint: Vector3;
  40436. /**
  40437. * Add a new element to this block
  40438. * @param entry defines the element to add
  40439. */
  40440. addEntry(entry: T): void;
  40441. /**
  40442. * Remove an element from this block
  40443. * @param entry defines the element to remove
  40444. */
  40445. removeEntry(entry: T): void;
  40446. /**
  40447. * Add an array of elements to this block
  40448. * @param entries defines the array of elements to add
  40449. */
  40450. addEntries(entries: T[]): void;
  40451. /**
  40452. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40453. * @param frustumPlanes defines the frustum planes to test
  40454. * @param selection defines the array to store current content if selection is positive
  40455. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40456. */
  40457. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40458. /**
  40459. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40460. * @param sphereCenter defines the bounding sphere center
  40461. * @param sphereRadius defines the bounding sphere radius
  40462. * @param selection defines the array to store current content if selection is positive
  40463. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40464. */
  40465. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40466. /**
  40467. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40468. * @param ray defines the ray to test with
  40469. * @param selection defines the array to store current content if selection is positive
  40470. */
  40471. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40472. /**
  40473. * Subdivide the content into child blocks (this block will then be empty)
  40474. */
  40475. createInnerBlocks(): void;
  40476. /**
  40477. * @hidden
  40478. */
  40479. 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;
  40480. }
  40481. }
  40482. declare module BABYLON {
  40483. /**
  40484. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40485. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40486. */
  40487. export class Octree<T> {
  40488. /** 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.) */
  40489. maxDepth: number;
  40490. /**
  40491. * Blocks within the octree containing objects
  40492. */
  40493. blocks: Array<OctreeBlock<T>>;
  40494. /**
  40495. * Content stored in the octree
  40496. */
  40497. dynamicContent: T[];
  40498. private _maxBlockCapacity;
  40499. private _selectionContent;
  40500. private _creationFunc;
  40501. /**
  40502. * Creates a octree
  40503. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40504. * @param creationFunc function to be used to instatiate the octree
  40505. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40506. * @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.)
  40507. */
  40508. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40509. /** 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.) */
  40510. maxDepth?: number);
  40511. /**
  40512. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40513. * @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);
  40514. * @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);
  40515. * @param entries meshes to be added to the octree blocks
  40516. */
  40517. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40518. /**
  40519. * Adds a mesh to the octree
  40520. * @param entry Mesh to add to the octree
  40521. */
  40522. addMesh(entry: T): void;
  40523. /**
  40524. * Remove an element from the octree
  40525. * @param entry defines the element to remove
  40526. */
  40527. removeMesh(entry: T): void;
  40528. /**
  40529. * Selects an array of meshes within the frustum
  40530. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40531. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40532. * @returns array of meshes within the frustum
  40533. */
  40534. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40535. /**
  40536. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40537. * @param sphereCenter defines the bounding sphere center
  40538. * @param sphereRadius defines the bounding sphere radius
  40539. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40540. * @returns an array of objects that intersect the sphere
  40541. */
  40542. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40543. /**
  40544. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40545. * @param ray defines the ray to test with
  40546. * @returns array of intersected objects
  40547. */
  40548. intersectsRay(ray: Ray): SmartArray<T>;
  40549. /**
  40550. * Adds a mesh into the octree block if it intersects the block
  40551. */
  40552. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40553. /**
  40554. * Adds a submesh into the octree block if it intersects the block
  40555. */
  40556. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40557. }
  40558. }
  40559. declare module BABYLON {
  40560. interface Scene {
  40561. /**
  40562. * @hidden
  40563. * Backing Filed
  40564. */
  40565. _selectionOctree: Octree<AbstractMesh>;
  40566. /**
  40567. * Gets the octree used to boost mesh selection (picking)
  40568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40569. */
  40570. selectionOctree: Octree<AbstractMesh>;
  40571. /**
  40572. * Creates or updates the octree used to boost selection (picking)
  40573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40574. * @param maxCapacity defines the maximum capacity per leaf
  40575. * @param maxDepth defines the maximum depth of the octree
  40576. * @returns an octree of AbstractMesh
  40577. */
  40578. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40579. }
  40580. interface AbstractMesh {
  40581. /**
  40582. * @hidden
  40583. * Backing Field
  40584. */
  40585. _submeshesOctree: Octree<SubMesh>;
  40586. /**
  40587. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40588. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40589. * @param maxCapacity defines the maximum size of each block (64 by default)
  40590. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40591. * @returns the new octree
  40592. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40594. */
  40595. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40596. }
  40597. /**
  40598. * Defines the octree scene component responsible to manage any octrees
  40599. * in a given scene.
  40600. */
  40601. export class OctreeSceneComponent {
  40602. /**
  40603. * The component name help to identify the component in the list of scene components.
  40604. */
  40605. readonly name: string;
  40606. /**
  40607. * The scene the component belongs to.
  40608. */
  40609. scene: Scene;
  40610. /**
  40611. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40612. */
  40613. readonly checksIsEnabled: boolean;
  40614. /**
  40615. * Creates a new instance of the component for the given scene
  40616. * @param scene Defines the scene to register the component in
  40617. */
  40618. constructor(scene: Scene);
  40619. /**
  40620. * Registers the component in a given scene
  40621. */
  40622. register(): void;
  40623. /**
  40624. * Return the list of active meshes
  40625. * @returns the list of active meshes
  40626. */
  40627. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40628. /**
  40629. * Return the list of active sub meshes
  40630. * @param mesh The mesh to get the candidates sub meshes from
  40631. * @returns the list of active sub meshes
  40632. */
  40633. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40634. private _tempRay;
  40635. /**
  40636. * Return the list of sub meshes intersecting with a given local ray
  40637. * @param mesh defines the mesh to find the submesh for
  40638. * @param localRay defines the ray in local space
  40639. * @returns the list of intersecting sub meshes
  40640. */
  40641. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40642. /**
  40643. * Return the list of sub meshes colliding with a collider
  40644. * @param mesh defines the mesh to find the submesh for
  40645. * @param collider defines the collider to evaluate the collision against
  40646. * @returns the list of colliding sub meshes
  40647. */
  40648. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40649. /**
  40650. * Rebuilds the elements related to this component in case of
  40651. * context lost for instance.
  40652. */
  40653. rebuild(): void;
  40654. /**
  40655. * Disposes the component and the associated ressources.
  40656. */
  40657. dispose(): void;
  40658. }
  40659. }
  40660. declare module BABYLON {
  40661. /**
  40662. * Renders a layer on top of an existing scene
  40663. */
  40664. export class UtilityLayerRenderer implements IDisposable {
  40665. /** the original scene that will be rendered on top of */
  40666. originalScene: Scene;
  40667. private _pointerCaptures;
  40668. private _lastPointerEvents;
  40669. private static _DefaultUtilityLayer;
  40670. private static _DefaultKeepDepthUtilityLayer;
  40671. private _sharedGizmoLight;
  40672. /**
  40673. * @hidden
  40674. * Light which used by gizmos to get light shading
  40675. */
  40676. _getSharedGizmoLight(): HemisphericLight;
  40677. /**
  40678. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40679. */
  40680. pickUtilitySceneFirst: boolean;
  40681. /**
  40682. * 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)
  40683. */
  40684. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40685. /**
  40686. * 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)
  40687. */
  40688. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40689. /**
  40690. * The scene that is rendered on top of the original scene
  40691. */
  40692. utilityLayerScene: Scene;
  40693. /**
  40694. * If the utility layer should automatically be rendered on top of existing scene
  40695. */
  40696. shouldRender: boolean;
  40697. /**
  40698. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40699. */
  40700. onlyCheckPointerDownEvents: boolean;
  40701. /**
  40702. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40703. */
  40704. processAllEvents: boolean;
  40705. /**
  40706. * Observable raised when the pointer move from the utility layer scene to the main scene
  40707. */
  40708. onPointerOutObservable: Observable<number>;
  40709. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40710. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40711. private _afterRenderObserver;
  40712. private _sceneDisposeObserver;
  40713. private _originalPointerObserver;
  40714. /**
  40715. * Instantiates a UtilityLayerRenderer
  40716. * @param originalScene the original scene that will be rendered on top of
  40717. * @param handleEvents boolean indicating if the utility layer should handle events
  40718. */
  40719. constructor(
  40720. /** the original scene that will be rendered on top of */
  40721. originalScene: Scene, handleEvents?: boolean);
  40722. private _notifyObservers;
  40723. /**
  40724. * Renders the utility layers scene on top of the original scene
  40725. */
  40726. render(): void;
  40727. /**
  40728. * Disposes of the renderer
  40729. */
  40730. dispose(): void;
  40731. private _updateCamera;
  40732. }
  40733. }
  40734. declare module BABYLON {
  40735. /**
  40736. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40737. */
  40738. export class Gizmo implements IDisposable {
  40739. /** The utility layer the gizmo will be added to */
  40740. gizmoLayer: UtilityLayerRenderer;
  40741. /**
  40742. * The root mesh of the gizmo
  40743. */
  40744. _rootMesh: Mesh;
  40745. private _attachedMesh;
  40746. /**
  40747. * Ratio for the scale of the gizmo (Default: 1)
  40748. */
  40749. scaleRatio: number;
  40750. /**
  40751. * If a custom mesh has been set (Default: false)
  40752. */
  40753. protected _customMeshSet: boolean;
  40754. /**
  40755. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40756. * * When set, interactions will be enabled
  40757. */
  40758. attachedMesh: Nullable<AbstractMesh>;
  40759. /**
  40760. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40761. * @param mesh The mesh to replace the default mesh of the gizmo
  40762. */
  40763. setCustomMesh(mesh: Mesh): void;
  40764. /**
  40765. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40766. */
  40767. updateGizmoRotationToMatchAttachedMesh: boolean;
  40768. /**
  40769. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40770. */
  40771. updateGizmoPositionToMatchAttachedMesh: boolean;
  40772. /**
  40773. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40774. */
  40775. protected _updateScale: boolean;
  40776. protected _interactionsEnabled: boolean;
  40777. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40778. private _beforeRenderObserver;
  40779. private _tempVector;
  40780. /**
  40781. * Creates a gizmo
  40782. * @param gizmoLayer The utility layer the gizmo will be added to
  40783. */
  40784. constructor(
  40785. /** The utility layer the gizmo will be added to */
  40786. gizmoLayer?: UtilityLayerRenderer);
  40787. /**
  40788. * Updates the gizmo to match the attached mesh's position/rotation
  40789. */
  40790. protected _update(): void;
  40791. /**
  40792. * Disposes of the gizmo
  40793. */
  40794. dispose(): void;
  40795. }
  40796. }
  40797. declare module BABYLON {
  40798. /**
  40799. * Single axis drag gizmo
  40800. */
  40801. export class AxisDragGizmo extends Gizmo {
  40802. /**
  40803. * Drag behavior responsible for the gizmos dragging interactions
  40804. */
  40805. dragBehavior: PointerDragBehavior;
  40806. private _pointerObserver;
  40807. /**
  40808. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40809. */
  40810. snapDistance: number;
  40811. /**
  40812. * Event that fires each time the gizmo snaps to a new location.
  40813. * * snapDistance is the the change in distance
  40814. */
  40815. onSnapObservable: Observable<{
  40816. snapDistance: number;
  40817. }>;
  40818. /** @hidden */
  40819. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40820. /** @hidden */
  40821. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40822. /**
  40823. * Creates an AxisDragGizmo
  40824. * @param gizmoLayer The utility layer the gizmo will be added to
  40825. * @param dragAxis The axis which the gizmo will be able to drag on
  40826. * @param color The color of the gizmo
  40827. */
  40828. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40829. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40830. /**
  40831. * Disposes of the gizmo
  40832. */
  40833. dispose(): void;
  40834. }
  40835. }
  40836. declare module BABYLON.Debug {
  40837. /**
  40838. * The Axes viewer will show 3 axes in a specific point in space
  40839. */
  40840. export class AxesViewer {
  40841. private _xAxis;
  40842. private _yAxis;
  40843. private _zAxis;
  40844. private _scaleLinesFactor;
  40845. private _instanced;
  40846. /**
  40847. * Gets the hosting scene
  40848. */
  40849. scene: Scene;
  40850. /**
  40851. * Gets or sets a number used to scale line length
  40852. */
  40853. scaleLines: number;
  40854. /** Gets the node hierarchy used to render x-axis */
  40855. readonly xAxis: TransformNode;
  40856. /** Gets the node hierarchy used to render y-axis */
  40857. readonly yAxis: TransformNode;
  40858. /** Gets the node hierarchy used to render z-axis */
  40859. readonly zAxis: TransformNode;
  40860. /**
  40861. * Creates a new AxesViewer
  40862. * @param scene defines the hosting scene
  40863. * @param scaleLines defines a number used to scale line length (1 by default)
  40864. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40865. * @param xAxis defines the node hierarchy used to render the x-axis
  40866. * @param yAxis defines the node hierarchy used to render the y-axis
  40867. * @param zAxis defines the node hierarchy used to render the z-axis
  40868. */
  40869. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40870. /**
  40871. * Force the viewer to update
  40872. * @param position defines the position of the viewer
  40873. * @param xaxis defines the x axis of the viewer
  40874. * @param yaxis defines the y axis of the viewer
  40875. * @param zaxis defines the z axis of the viewer
  40876. */
  40877. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40878. /**
  40879. * Creates an instance of this axes viewer.
  40880. * @returns a new axes viewer with instanced meshes
  40881. */
  40882. createInstance(): AxesViewer;
  40883. /** Releases resources */
  40884. dispose(): void;
  40885. private static _SetRenderingGroupId;
  40886. }
  40887. }
  40888. declare module BABYLON.Debug {
  40889. /**
  40890. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40891. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40892. */
  40893. export class BoneAxesViewer extends AxesViewer {
  40894. /**
  40895. * Gets or sets the target mesh where to display the axes viewer
  40896. */
  40897. mesh: Nullable<Mesh>;
  40898. /**
  40899. * Gets or sets the target bone where to display the axes viewer
  40900. */
  40901. bone: Nullable<Bone>;
  40902. /** Gets current position */
  40903. pos: Vector3;
  40904. /** Gets direction of X axis */
  40905. xaxis: Vector3;
  40906. /** Gets direction of Y axis */
  40907. yaxis: Vector3;
  40908. /** Gets direction of Z axis */
  40909. zaxis: Vector3;
  40910. /**
  40911. * Creates a new BoneAxesViewer
  40912. * @param scene defines the hosting scene
  40913. * @param bone defines the target bone
  40914. * @param mesh defines the target mesh
  40915. * @param scaleLines defines a scaling factor for line length (1 by default)
  40916. */
  40917. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40918. /**
  40919. * Force the viewer to update
  40920. */
  40921. update(): void;
  40922. /** Releases resources */
  40923. dispose(): void;
  40924. }
  40925. }
  40926. declare module BABYLON {
  40927. /**
  40928. * Interface used to define scene explorer extensibility option
  40929. */
  40930. export interface IExplorerExtensibilityOption {
  40931. /**
  40932. * Define the option label
  40933. */
  40934. label: string;
  40935. /**
  40936. * Defines the action to execute on click
  40937. */
  40938. action: (entity: any) => void;
  40939. }
  40940. /**
  40941. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40942. */
  40943. export interface IExplorerExtensibilityGroup {
  40944. /**
  40945. * Defines a predicate to test if a given type mut be extended
  40946. */
  40947. predicate: (entity: any) => boolean;
  40948. /**
  40949. * Gets the list of options added to a type
  40950. */
  40951. entries: IExplorerExtensibilityOption[];
  40952. }
  40953. /**
  40954. * Interface used to define the options to use to create the Inspector
  40955. */
  40956. export interface IInspectorOptions {
  40957. /**
  40958. * Display in overlay mode (default: false)
  40959. */
  40960. overlay?: boolean;
  40961. /**
  40962. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40963. */
  40964. globalRoot?: HTMLElement;
  40965. /**
  40966. * Display the Scene explorer
  40967. */
  40968. showExplorer?: boolean;
  40969. /**
  40970. * Display the property inspector
  40971. */
  40972. showInspector?: boolean;
  40973. /**
  40974. * Display in embed mode (both panes on the right)
  40975. */
  40976. embedMode?: boolean;
  40977. /**
  40978. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40979. */
  40980. handleResize?: boolean;
  40981. /**
  40982. * Allow the panes to popup (default: true)
  40983. */
  40984. enablePopup?: boolean;
  40985. /**
  40986. * Allow the panes to be closed by users (default: true)
  40987. */
  40988. enableClose?: boolean;
  40989. /**
  40990. * Optional list of extensibility entries
  40991. */
  40992. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40993. /**
  40994. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40995. */
  40996. inspectorURL?: string;
  40997. }
  40998. interface Scene {
  40999. /**
  41000. * @hidden
  41001. * Backing field
  41002. */
  41003. _debugLayer: DebugLayer;
  41004. /**
  41005. * Gets the debug layer (aka Inspector) associated with the scene
  41006. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41007. */
  41008. debugLayer: DebugLayer;
  41009. }
  41010. /**
  41011. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41012. * what is happening in your scene
  41013. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41014. */
  41015. export class DebugLayer {
  41016. /**
  41017. * Define the url to get the inspector script from.
  41018. * By default it uses the babylonjs CDN.
  41019. * @ignoreNaming
  41020. */
  41021. static InspectorURL: string;
  41022. private _scene;
  41023. private BJSINSPECTOR;
  41024. /**
  41025. * Observable triggered when a property is changed through the inspector.
  41026. */
  41027. onPropertyChangedObservable: Observable<{
  41028. object: any;
  41029. property: string;
  41030. value: any;
  41031. initialValue: any;
  41032. }>;
  41033. /**
  41034. * Instantiates a new debug layer.
  41035. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41036. * what is happening in your scene
  41037. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41038. * @param scene Defines the scene to inspect
  41039. */
  41040. constructor(scene: Scene);
  41041. /** Creates the inspector window. */
  41042. private _createInspector;
  41043. /**
  41044. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41045. * @param entity defines the entity to select
  41046. * @param lineContainerTitle defines the specific block to highlight
  41047. */
  41048. select(entity: any, lineContainerTitle?: string): void;
  41049. /** Get the inspector from bundle or global */
  41050. private _getGlobalInspector;
  41051. /**
  41052. * Get if the inspector is visible or not.
  41053. * @returns true if visible otherwise, false
  41054. */
  41055. isVisible(): boolean;
  41056. /**
  41057. * Hide the inspector and close its window.
  41058. */
  41059. hide(): void;
  41060. /**
  41061. * Launch the debugLayer.
  41062. * @param config Define the configuration of the inspector
  41063. * @return a promise fulfilled when the debug layer is visible
  41064. */
  41065. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41066. }
  41067. }
  41068. declare module BABYLON {
  41069. /**
  41070. * Class containing static functions to help procedurally build meshes
  41071. */
  41072. export class BoxBuilder {
  41073. /**
  41074. * Creates a box mesh
  41075. * * The parameter `size` sets the size (float) of each box side (default 1)
  41076. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41077. * * 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)
  41078. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41080. * * 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
  41081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41082. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41083. * @param name defines the name of the mesh
  41084. * @param options defines the options used to create the mesh
  41085. * @param scene defines the hosting scene
  41086. * @returns the box mesh
  41087. */
  41088. static CreateBox(name: string, options: {
  41089. size?: number;
  41090. width?: number;
  41091. height?: number;
  41092. depth?: number;
  41093. faceUV?: Vector4[];
  41094. faceColors?: Color4[];
  41095. sideOrientation?: number;
  41096. frontUVs?: Vector4;
  41097. backUVs?: Vector4;
  41098. wrap?: boolean;
  41099. topBaseAt?: number;
  41100. bottomBaseAt?: number;
  41101. updatable?: boolean;
  41102. }, scene?: Nullable<Scene>): Mesh;
  41103. }
  41104. }
  41105. declare module BABYLON {
  41106. /**
  41107. * Class containing static functions to help procedurally build meshes
  41108. */
  41109. export class SphereBuilder {
  41110. /**
  41111. * Creates a sphere mesh
  41112. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41113. * * 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`)
  41114. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41115. * * 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
  41116. * * 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)
  41117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41118. * * 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
  41119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41120. * @param name defines the name of the mesh
  41121. * @param options defines the options used to create the mesh
  41122. * @param scene defines the hosting scene
  41123. * @returns the sphere mesh
  41124. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41125. */
  41126. static CreateSphere(name: string, options: {
  41127. segments?: number;
  41128. diameter?: number;
  41129. diameterX?: number;
  41130. diameterY?: number;
  41131. diameterZ?: number;
  41132. arc?: number;
  41133. slice?: number;
  41134. sideOrientation?: number;
  41135. frontUVs?: Vector4;
  41136. backUVs?: Vector4;
  41137. updatable?: boolean;
  41138. }, scene: any): Mesh;
  41139. }
  41140. }
  41141. declare module BABYLON.Debug {
  41142. /**
  41143. * Used to show the physics impostor around the specific mesh
  41144. */
  41145. export class PhysicsViewer {
  41146. /** @hidden */
  41147. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41148. /** @hidden */
  41149. protected _meshes: Array<Nullable<AbstractMesh>>;
  41150. /** @hidden */
  41151. protected _scene: Nullable<Scene>;
  41152. /** @hidden */
  41153. protected _numMeshes: number;
  41154. /** @hidden */
  41155. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41156. private _renderFunction;
  41157. private _utilityLayer;
  41158. private _debugBoxMesh;
  41159. private _debugSphereMesh;
  41160. private _debugCylinderMesh;
  41161. private _debugMaterial;
  41162. private _debugMeshMeshes;
  41163. /**
  41164. * Creates a new PhysicsViewer
  41165. * @param scene defines the hosting scene
  41166. */
  41167. constructor(scene: Scene);
  41168. /** @hidden */
  41169. protected _updateDebugMeshes(): void;
  41170. /**
  41171. * Renders a specified physic impostor
  41172. * @param impostor defines the impostor to render
  41173. * @param targetMesh defines the mesh represented by the impostor
  41174. * @returns the new debug mesh used to render the impostor
  41175. */
  41176. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41177. /**
  41178. * Hides a specified physic impostor
  41179. * @param impostor defines the impostor to hide
  41180. */
  41181. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41182. private _getDebugMaterial;
  41183. private _getDebugBoxMesh;
  41184. private _getDebugSphereMesh;
  41185. private _getDebugCylinderMesh;
  41186. private _getDebugMeshMesh;
  41187. private _getDebugMesh;
  41188. /** Releases all resources */
  41189. dispose(): void;
  41190. }
  41191. }
  41192. declare module BABYLON {
  41193. /**
  41194. * Class containing static functions to help procedurally build meshes
  41195. */
  41196. export class LinesBuilder {
  41197. /**
  41198. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41199. * * 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
  41200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41201. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41202. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41203. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41205. * * 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
  41206. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41209. * @param name defines the name of the new line system
  41210. * @param options defines the options used to create the line system
  41211. * @param scene defines the hosting scene
  41212. * @returns a new line system mesh
  41213. */
  41214. static CreateLineSystem(name: string, options: {
  41215. lines: Vector3[][];
  41216. updatable?: boolean;
  41217. instance?: Nullable<LinesMesh>;
  41218. colors?: Nullable<Color4[][]>;
  41219. useVertexAlpha?: boolean;
  41220. }, scene: Nullable<Scene>): LinesMesh;
  41221. /**
  41222. * Creates a line mesh
  41223. * 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
  41224. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41225. * * The parameter `points` is an array successive Vector3
  41226. * * 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
  41227. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41228. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41229. * * When updating an instance, remember that only point positions can change, not the number of points
  41230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41232. * @param name defines the name of the new line system
  41233. * @param options defines the options used to create the line system
  41234. * @param scene defines the hosting scene
  41235. * @returns a new line mesh
  41236. */
  41237. static CreateLines(name: string, options: {
  41238. points: Vector3[];
  41239. updatable?: boolean;
  41240. instance?: Nullable<LinesMesh>;
  41241. colors?: Color4[];
  41242. useVertexAlpha?: boolean;
  41243. }, scene?: Nullable<Scene>): LinesMesh;
  41244. /**
  41245. * Creates a dashed line mesh
  41246. * * 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
  41247. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41248. * * The parameter `points` is an array successive Vector3
  41249. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41250. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41251. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41252. * * 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
  41253. * * When updating an instance, remember that only point positions can change, not the number of points
  41254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41255. * @param name defines the name of the mesh
  41256. * @param options defines the options used to create the mesh
  41257. * @param scene defines the hosting scene
  41258. * @returns the dashed line mesh
  41259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41260. */
  41261. static CreateDashedLines(name: string, options: {
  41262. points: Vector3[];
  41263. dashSize?: number;
  41264. gapSize?: number;
  41265. dashNb?: number;
  41266. updatable?: boolean;
  41267. instance?: LinesMesh;
  41268. }, scene?: Nullable<Scene>): LinesMesh;
  41269. }
  41270. }
  41271. declare module BABYLON {
  41272. /**
  41273. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41274. * in order to better appreciate the issue one might have.
  41275. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41276. */
  41277. export class RayHelper {
  41278. /**
  41279. * Defines the ray we are currently tryin to visualize.
  41280. */
  41281. ray: Nullable<Ray>;
  41282. private _renderPoints;
  41283. private _renderLine;
  41284. private _renderFunction;
  41285. private _scene;
  41286. private _updateToMeshFunction;
  41287. private _attachedToMesh;
  41288. private _meshSpaceDirection;
  41289. private _meshSpaceOrigin;
  41290. /**
  41291. * Helper function to create a colored helper in a scene in one line.
  41292. * @param ray Defines the ray we are currently tryin to visualize
  41293. * @param scene Defines the scene the ray is used in
  41294. * @param color Defines the color we want to see the ray in
  41295. * @returns The newly created ray helper.
  41296. */
  41297. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41298. /**
  41299. * Instantiate a new ray helper.
  41300. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41301. * in order to better appreciate the issue one might have.
  41302. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41303. * @param ray Defines the ray we are currently tryin to visualize
  41304. */
  41305. constructor(ray: Ray);
  41306. /**
  41307. * Shows the ray we are willing to debug.
  41308. * @param scene Defines the scene the ray needs to be rendered in
  41309. * @param color Defines the color the ray needs to be rendered in
  41310. */
  41311. show(scene: Scene, color?: Color3): void;
  41312. /**
  41313. * Hides the ray we are debugging.
  41314. */
  41315. hide(): void;
  41316. private _render;
  41317. /**
  41318. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41319. * @param mesh Defines the mesh we want the helper attached to
  41320. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41321. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41322. * @param length Defines the length of the ray
  41323. */
  41324. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41325. /**
  41326. * Detach the ray helper from the mesh it has previously been attached to.
  41327. */
  41328. detachFromMesh(): void;
  41329. private _updateToMesh;
  41330. /**
  41331. * Dispose the helper and release its associated resources.
  41332. */
  41333. dispose(): void;
  41334. }
  41335. }
  41336. declare module BABYLON.Debug {
  41337. /**
  41338. * Class used to render a debug view of a given skeleton
  41339. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41340. */
  41341. export class SkeletonViewer {
  41342. /** defines the skeleton to render */
  41343. skeleton: Skeleton;
  41344. /** defines the mesh attached to the skeleton */
  41345. mesh: AbstractMesh;
  41346. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41347. autoUpdateBonesMatrices: boolean;
  41348. /** defines the rendering group id to use with the viewer */
  41349. renderingGroupId: number;
  41350. /** Gets or sets the color used to render the skeleton */
  41351. color: Color3;
  41352. private _scene;
  41353. private _debugLines;
  41354. private _debugMesh;
  41355. private _isEnabled;
  41356. private _renderFunction;
  41357. private _utilityLayer;
  41358. /**
  41359. * Returns the mesh used to render the bones
  41360. */
  41361. readonly debugMesh: Nullable<LinesMesh>;
  41362. /**
  41363. * Creates a new SkeletonViewer
  41364. * @param skeleton defines the skeleton to render
  41365. * @param mesh defines the mesh attached to the skeleton
  41366. * @param scene defines the hosting scene
  41367. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41368. * @param renderingGroupId defines the rendering group id to use with the viewer
  41369. */
  41370. constructor(
  41371. /** defines the skeleton to render */
  41372. skeleton: Skeleton,
  41373. /** defines the mesh attached to the skeleton */
  41374. mesh: AbstractMesh, scene: Scene,
  41375. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41376. autoUpdateBonesMatrices?: boolean,
  41377. /** defines the rendering group id to use with the viewer */
  41378. renderingGroupId?: number);
  41379. /** Gets or sets a boolean indicating if the viewer is enabled */
  41380. isEnabled: boolean;
  41381. private _getBonePosition;
  41382. private _getLinesForBonesWithLength;
  41383. private _getLinesForBonesNoLength;
  41384. /** Update the viewer to sync with current skeleton state */
  41385. update(): void;
  41386. /** Release associated resources */
  41387. dispose(): void;
  41388. }
  41389. }
  41390. declare module BABYLON {
  41391. /**
  41392. * Options to create the null engine
  41393. */
  41394. export class NullEngineOptions {
  41395. /**
  41396. * Render width (Default: 512)
  41397. */
  41398. renderWidth: number;
  41399. /**
  41400. * Render height (Default: 256)
  41401. */
  41402. renderHeight: number;
  41403. /**
  41404. * Texture size (Default: 512)
  41405. */
  41406. textureSize: number;
  41407. /**
  41408. * If delta time between frames should be constant
  41409. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41410. */
  41411. deterministicLockstep: boolean;
  41412. /**
  41413. * Maximum about of steps between frames (Default: 4)
  41414. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41415. */
  41416. lockstepMaxSteps: number;
  41417. }
  41418. /**
  41419. * The null engine class provides support for headless version of babylon.js.
  41420. * This can be used in server side scenario or for testing purposes
  41421. */
  41422. export class NullEngine extends Engine {
  41423. private _options;
  41424. /**
  41425. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41426. */
  41427. isDeterministicLockStep(): boolean;
  41428. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41429. getLockstepMaxSteps(): number;
  41430. /**
  41431. * Sets hardware scaling, used to save performance if needed
  41432. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41433. */
  41434. getHardwareScalingLevel(): number;
  41435. constructor(options?: NullEngineOptions);
  41436. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41437. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41438. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41439. getRenderWidth(useScreen?: boolean): number;
  41440. getRenderHeight(useScreen?: boolean): number;
  41441. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41442. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41443. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41444. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41445. bindSamplers(effect: Effect): void;
  41446. enableEffect(effect: Effect): void;
  41447. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41448. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41449. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41450. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41451. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41452. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41453. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41454. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41455. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41456. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41457. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41458. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41459. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41460. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41461. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41462. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41463. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41464. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41465. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41466. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41467. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41468. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41469. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41470. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41471. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41472. bindBuffers(vertexBuffers: {
  41473. [key: string]: VertexBuffer;
  41474. }, indexBuffer: DataBuffer, effect: Effect): void;
  41475. wipeCaches(bruteForce?: boolean): void;
  41476. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41477. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41478. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41479. /** @hidden */
  41480. _createTexture(): WebGLTexture;
  41481. /** @hidden */
  41482. _releaseTexture(texture: InternalTexture): void;
  41483. 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;
  41484. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41485. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41486. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41487. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41488. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41489. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41490. areAllEffectsReady(): boolean;
  41491. /**
  41492. * @hidden
  41493. * Get the current error code of the webGL context
  41494. * @returns the error code
  41495. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41496. */
  41497. getError(): number;
  41498. /** @hidden */
  41499. _getUnpackAlignement(): number;
  41500. /** @hidden */
  41501. _unpackFlipY(value: boolean): void;
  41502. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41503. /**
  41504. * Updates a dynamic vertex buffer.
  41505. * @param vertexBuffer the vertex buffer to update
  41506. * @param data the data used to update the vertex buffer
  41507. * @param byteOffset the byte offset of the data (optional)
  41508. * @param byteLength the byte length of the data (optional)
  41509. */
  41510. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41511. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41512. /** @hidden */
  41513. _bindTexture(channel: number, texture: InternalTexture): void;
  41514. /** @hidden */
  41515. _releaseBuffer(buffer: DataBuffer): boolean;
  41516. releaseEffects(): void;
  41517. displayLoadingUI(): void;
  41518. hideLoadingUI(): void;
  41519. /** @hidden */
  41520. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41521. /** @hidden */
  41522. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41523. /** @hidden */
  41524. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41525. /** @hidden */
  41526. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41527. }
  41528. }
  41529. declare module BABYLON {
  41530. /** @hidden */
  41531. export class _OcclusionDataStorage {
  41532. /** @hidden */
  41533. occlusionInternalRetryCounter: number;
  41534. /** @hidden */
  41535. isOcclusionQueryInProgress: boolean;
  41536. /** @hidden */
  41537. isOccluded: boolean;
  41538. /** @hidden */
  41539. occlusionRetryCount: number;
  41540. /** @hidden */
  41541. occlusionType: number;
  41542. /** @hidden */
  41543. occlusionQueryAlgorithmType: number;
  41544. }
  41545. interface Engine {
  41546. /**
  41547. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41548. * @return the new query
  41549. */
  41550. createQuery(): WebGLQuery;
  41551. /**
  41552. * Delete and release a webGL query
  41553. * @param query defines the query to delete
  41554. * @return the current engine
  41555. */
  41556. deleteQuery(query: WebGLQuery): Engine;
  41557. /**
  41558. * Check if a given query has resolved and got its value
  41559. * @param query defines the query to check
  41560. * @returns true if the query got its value
  41561. */
  41562. isQueryResultAvailable(query: WebGLQuery): boolean;
  41563. /**
  41564. * Gets the value of a given query
  41565. * @param query defines the query to check
  41566. * @returns the value of the query
  41567. */
  41568. getQueryResult(query: WebGLQuery): number;
  41569. /**
  41570. * Initiates an occlusion query
  41571. * @param algorithmType defines the algorithm to use
  41572. * @param query defines the query to use
  41573. * @returns the current engine
  41574. * @see http://doc.babylonjs.com/features/occlusionquery
  41575. */
  41576. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41577. /**
  41578. * Ends an occlusion query
  41579. * @see http://doc.babylonjs.com/features/occlusionquery
  41580. * @param algorithmType defines the algorithm to use
  41581. * @returns the current engine
  41582. */
  41583. endOcclusionQuery(algorithmType: number): Engine;
  41584. /**
  41585. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41586. * Please note that only one query can be issued at a time
  41587. * @returns a time token used to track the time span
  41588. */
  41589. startTimeQuery(): Nullable<_TimeToken>;
  41590. /**
  41591. * Ends a time query
  41592. * @param token defines the token used to measure the time span
  41593. * @returns the time spent (in ns)
  41594. */
  41595. endTimeQuery(token: _TimeToken): int;
  41596. /** @hidden */
  41597. _currentNonTimestampToken: Nullable<_TimeToken>;
  41598. /** @hidden */
  41599. _createTimeQuery(): WebGLQuery;
  41600. /** @hidden */
  41601. _deleteTimeQuery(query: WebGLQuery): void;
  41602. /** @hidden */
  41603. _getGlAlgorithmType(algorithmType: number): number;
  41604. /** @hidden */
  41605. _getTimeQueryResult(query: WebGLQuery): any;
  41606. /** @hidden */
  41607. _getTimeQueryAvailability(query: WebGLQuery): any;
  41608. }
  41609. interface AbstractMesh {
  41610. /**
  41611. * Backing filed
  41612. * @hidden
  41613. */
  41614. __occlusionDataStorage: _OcclusionDataStorage;
  41615. /**
  41616. * Access property
  41617. * @hidden
  41618. */
  41619. _occlusionDataStorage: _OcclusionDataStorage;
  41620. /**
  41621. * 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.
  41622. * The default value is -1 which means don't break the query and wait till the result
  41623. * @see http://doc.babylonjs.com/features/occlusionquery
  41624. */
  41625. occlusionRetryCount: number;
  41626. /**
  41627. * 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:
  41628. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41629. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41630. * * 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.
  41631. * @see http://doc.babylonjs.com/features/occlusionquery
  41632. */
  41633. occlusionType: number;
  41634. /**
  41635. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41636. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41637. * * 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.
  41638. * @see http://doc.babylonjs.com/features/occlusionquery
  41639. */
  41640. occlusionQueryAlgorithmType: number;
  41641. /**
  41642. * 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
  41643. * @see http://doc.babylonjs.com/features/occlusionquery
  41644. */
  41645. isOccluded: boolean;
  41646. /**
  41647. * Flag to check the progress status of the query
  41648. * @see http://doc.babylonjs.com/features/occlusionquery
  41649. */
  41650. isOcclusionQueryInProgress: boolean;
  41651. }
  41652. }
  41653. declare module BABYLON {
  41654. /** @hidden */
  41655. export var _forceTransformFeedbackToBundle: boolean;
  41656. interface Engine {
  41657. /**
  41658. * Creates a webGL transform feedback object
  41659. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41660. * @returns the webGL transform feedback object
  41661. */
  41662. createTransformFeedback(): WebGLTransformFeedback;
  41663. /**
  41664. * Delete a webGL transform feedback object
  41665. * @param value defines the webGL transform feedback object to delete
  41666. */
  41667. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41668. /**
  41669. * Bind a webGL transform feedback object to the webgl context
  41670. * @param value defines the webGL transform feedback object to bind
  41671. */
  41672. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41673. /**
  41674. * Begins a transform feedback operation
  41675. * @param usePoints defines if points or triangles must be used
  41676. */
  41677. beginTransformFeedback(usePoints: boolean): void;
  41678. /**
  41679. * Ends a transform feedback operation
  41680. */
  41681. endTransformFeedback(): void;
  41682. /**
  41683. * Specify the varyings to use with transform feedback
  41684. * @param program defines the associated webGL program
  41685. * @param value defines the list of strings representing the varying names
  41686. */
  41687. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41688. /**
  41689. * Bind a webGL buffer for a transform feedback operation
  41690. * @param value defines the webGL buffer to bind
  41691. */
  41692. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41693. }
  41694. }
  41695. declare module BABYLON {
  41696. /**
  41697. * Creation options of the multi render target texture.
  41698. */
  41699. export interface IMultiRenderTargetOptions {
  41700. /**
  41701. * Define if the texture needs to create mip maps after render.
  41702. */
  41703. generateMipMaps?: boolean;
  41704. /**
  41705. * Define the types of all the draw buffers we want to create
  41706. */
  41707. types?: number[];
  41708. /**
  41709. * Define the sampling modes of all the draw buffers we want to create
  41710. */
  41711. samplingModes?: number[];
  41712. /**
  41713. * Define if a depth buffer is required
  41714. */
  41715. generateDepthBuffer?: boolean;
  41716. /**
  41717. * Define if a stencil buffer is required
  41718. */
  41719. generateStencilBuffer?: boolean;
  41720. /**
  41721. * Define if a depth texture is required instead of a depth buffer
  41722. */
  41723. generateDepthTexture?: boolean;
  41724. /**
  41725. * Define the number of desired draw buffers
  41726. */
  41727. textureCount?: number;
  41728. /**
  41729. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41730. */
  41731. doNotChangeAspectRatio?: boolean;
  41732. /**
  41733. * Define the default type of the buffers we are creating
  41734. */
  41735. defaultType?: number;
  41736. }
  41737. /**
  41738. * A multi render target, like a render target provides the ability to render to a texture.
  41739. * Unlike the render target, it can render to several draw buffers in one draw.
  41740. * This is specially interesting in deferred rendering or for any effects requiring more than
  41741. * just one color from a single pass.
  41742. */
  41743. export class MultiRenderTarget extends RenderTargetTexture {
  41744. private _internalTextures;
  41745. private _textures;
  41746. private _multiRenderTargetOptions;
  41747. /**
  41748. * Get if draw buffers are currently supported by the used hardware and browser.
  41749. */
  41750. readonly isSupported: boolean;
  41751. /**
  41752. * Get the list of textures generated by the multi render target.
  41753. */
  41754. readonly textures: Texture[];
  41755. /**
  41756. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41757. */
  41758. readonly depthTexture: Texture;
  41759. /**
  41760. * Set the wrapping mode on U of all the textures we are rendering to.
  41761. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41762. */
  41763. wrapU: number;
  41764. /**
  41765. * Set the wrapping mode on V of all the textures we are rendering to.
  41766. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41767. */
  41768. wrapV: number;
  41769. /**
  41770. * Instantiate a new multi render target texture.
  41771. * A multi render target, like a render target provides the ability to render to a texture.
  41772. * Unlike the render target, it can render to several draw buffers in one draw.
  41773. * This is specially interesting in deferred rendering or for any effects requiring more than
  41774. * just one color from a single pass.
  41775. * @param name Define the name of the texture
  41776. * @param size Define the size of the buffers to render to
  41777. * @param count Define the number of target we are rendering into
  41778. * @param scene Define the scene the texture belongs to
  41779. * @param options Define the options used to create the multi render target
  41780. */
  41781. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41782. /** @hidden */
  41783. _rebuild(): void;
  41784. private _createInternalTextures;
  41785. private _createTextures;
  41786. /**
  41787. * Define the number of samples used if MSAA is enabled.
  41788. */
  41789. samples: number;
  41790. /**
  41791. * Resize all the textures in the multi render target.
  41792. * Be carrefull as it will recreate all the data in the new texture.
  41793. * @param size Define the new size
  41794. */
  41795. resize(size: any): void;
  41796. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41797. /**
  41798. * Dispose the render targets and their associated resources
  41799. */
  41800. dispose(): void;
  41801. /**
  41802. * Release all the underlying texture used as draw buffers.
  41803. */
  41804. releaseInternalTextures(): void;
  41805. }
  41806. }
  41807. declare module BABYLON {
  41808. interface Engine {
  41809. /**
  41810. * Unbind a list of render target textures from the webGL context
  41811. * This is used only when drawBuffer extension or webGL2 are active
  41812. * @param textures defines the render target textures to unbind
  41813. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41814. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41815. */
  41816. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41817. /**
  41818. * Create a multi render target texture
  41819. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41820. * @param size defines the size of the texture
  41821. * @param options defines the creation options
  41822. * @returns the cube texture as an InternalTexture
  41823. */
  41824. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41825. /**
  41826. * Update the sample count for a given multiple render target texture
  41827. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41828. * @param textures defines the textures to update
  41829. * @param samples defines the sample count to set
  41830. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41831. */
  41832. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41833. }
  41834. }
  41835. declare module BABYLON {
  41836. /**
  41837. * Gather the list of clipboard event types as constants.
  41838. */
  41839. export class ClipboardEventTypes {
  41840. /**
  41841. * The clipboard event is fired when a copy command is active (pressed).
  41842. */
  41843. static readonly COPY: number;
  41844. /**
  41845. * The clipboard event is fired when a cut command is active (pressed).
  41846. */
  41847. static readonly CUT: number;
  41848. /**
  41849. * The clipboard event is fired when a paste command is active (pressed).
  41850. */
  41851. static readonly PASTE: number;
  41852. }
  41853. /**
  41854. * This class is used to store clipboard related info for the onClipboardObservable event.
  41855. */
  41856. export class ClipboardInfo {
  41857. /**
  41858. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41859. */
  41860. type: number;
  41861. /**
  41862. * Defines the related dom event
  41863. */
  41864. event: ClipboardEvent;
  41865. /**
  41866. *Creates an instance of ClipboardInfo.
  41867. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41868. * @param event Defines the related dom event
  41869. */
  41870. constructor(
  41871. /**
  41872. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41873. */
  41874. type: number,
  41875. /**
  41876. * Defines the related dom event
  41877. */
  41878. event: ClipboardEvent);
  41879. /**
  41880. * Get the clipboard event's type from the keycode.
  41881. * @param keyCode Defines the keyCode for the current keyboard event.
  41882. * @return {number}
  41883. */
  41884. static GetTypeFromCharacter(keyCode: number): number;
  41885. }
  41886. }
  41887. declare module BABYLON {
  41888. /**
  41889. * Class used to represent data loading progression
  41890. */
  41891. export class SceneLoaderProgressEvent {
  41892. /** defines if data length to load can be evaluated */
  41893. readonly lengthComputable: boolean;
  41894. /** defines the loaded data length */
  41895. readonly loaded: number;
  41896. /** defines the data length to load */
  41897. readonly total: number;
  41898. /**
  41899. * Create a new progress event
  41900. * @param lengthComputable defines if data length to load can be evaluated
  41901. * @param loaded defines the loaded data length
  41902. * @param total defines the data length to load
  41903. */
  41904. constructor(
  41905. /** defines if data length to load can be evaluated */
  41906. lengthComputable: boolean,
  41907. /** defines the loaded data length */
  41908. loaded: number,
  41909. /** defines the data length to load */
  41910. total: number);
  41911. /**
  41912. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41913. * @param event defines the source event
  41914. * @returns a new SceneLoaderProgressEvent
  41915. */
  41916. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41917. }
  41918. /**
  41919. * Interface used by SceneLoader plugins to define supported file extensions
  41920. */
  41921. export interface ISceneLoaderPluginExtensions {
  41922. /**
  41923. * Defines the list of supported extensions
  41924. */
  41925. [extension: string]: {
  41926. isBinary: boolean;
  41927. };
  41928. }
  41929. /**
  41930. * Interface used by SceneLoader plugin factory
  41931. */
  41932. export interface ISceneLoaderPluginFactory {
  41933. /**
  41934. * Defines the name of the factory
  41935. */
  41936. name: string;
  41937. /**
  41938. * Function called to create a new plugin
  41939. * @return the new plugin
  41940. */
  41941. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41942. /**
  41943. * Boolean indicating if the plugin can direct load specific data
  41944. */
  41945. canDirectLoad?: (data: string) => boolean;
  41946. }
  41947. /**
  41948. * Interface used to define a SceneLoader plugin
  41949. */
  41950. export interface ISceneLoaderPlugin {
  41951. /**
  41952. * The friendly name of this plugin.
  41953. */
  41954. name: string;
  41955. /**
  41956. * The file extensions supported by this plugin.
  41957. */
  41958. extensions: string | ISceneLoaderPluginExtensions;
  41959. /**
  41960. * Import meshes into a scene.
  41961. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41962. * @param scene The scene to import into
  41963. * @param data The data to import
  41964. * @param rootUrl The root url for scene and resources
  41965. * @param meshes The meshes array to import into
  41966. * @param particleSystems The particle systems array to import into
  41967. * @param skeletons The skeletons array to import into
  41968. * @param onError The callback when import fails
  41969. * @returns True if successful or false otherwise
  41970. */
  41971. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41972. /**
  41973. * Load into a scene.
  41974. * @param scene The scene to load into
  41975. * @param data The data to import
  41976. * @param rootUrl The root url for scene and resources
  41977. * @param onError The callback when import fails
  41978. * @returns true if successful or false otherwise
  41979. */
  41980. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41981. /**
  41982. * The callback that returns true if the data can be directly loaded.
  41983. */
  41984. canDirectLoad?: (data: string) => boolean;
  41985. /**
  41986. * The callback that allows custom handling of the root url based on the response url.
  41987. */
  41988. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41989. /**
  41990. * Load into an asset container.
  41991. * @param scene The scene to load into
  41992. * @param data The data to import
  41993. * @param rootUrl The root url for scene and resources
  41994. * @param onError The callback when import fails
  41995. * @returns The loaded asset container
  41996. */
  41997. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41998. }
  41999. /**
  42000. * Interface used to define an async SceneLoader plugin
  42001. */
  42002. export interface ISceneLoaderPluginAsync {
  42003. /**
  42004. * The friendly name of this plugin.
  42005. */
  42006. name: string;
  42007. /**
  42008. * The file extensions supported by this plugin.
  42009. */
  42010. extensions: string | ISceneLoaderPluginExtensions;
  42011. /**
  42012. * Import meshes into a scene.
  42013. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42014. * @param scene The scene to import into
  42015. * @param data The data to import
  42016. * @param rootUrl The root url for scene and resources
  42017. * @param onProgress The callback when the load progresses
  42018. * @param fileName Defines the name of the file to load
  42019. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42020. */
  42021. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42022. meshes: AbstractMesh[];
  42023. particleSystems: IParticleSystem[];
  42024. skeletons: Skeleton[];
  42025. animationGroups: AnimationGroup[];
  42026. }>;
  42027. /**
  42028. * Load into a scene.
  42029. * @param scene The scene to load into
  42030. * @param data The data to import
  42031. * @param rootUrl The root url for scene and resources
  42032. * @param onProgress The callback when the load progresses
  42033. * @param fileName Defines the name of the file to load
  42034. * @returns Nothing
  42035. */
  42036. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42037. /**
  42038. * The callback that returns true if the data can be directly loaded.
  42039. */
  42040. canDirectLoad?: (data: string) => boolean;
  42041. /**
  42042. * The callback that allows custom handling of the root url based on the response url.
  42043. */
  42044. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42045. /**
  42046. * Load into an asset container.
  42047. * @param scene The scene to load into
  42048. * @param data The data to import
  42049. * @param rootUrl The root url for scene and resources
  42050. * @param onProgress The callback when the load progresses
  42051. * @param fileName Defines the name of the file to load
  42052. * @returns The loaded asset container
  42053. */
  42054. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42055. }
  42056. /**
  42057. * Class used to load scene from various file formats using registered plugins
  42058. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42059. */
  42060. export class SceneLoader {
  42061. /**
  42062. * No logging while loading
  42063. */
  42064. static readonly NO_LOGGING: number;
  42065. /**
  42066. * Minimal logging while loading
  42067. */
  42068. static readonly MINIMAL_LOGGING: number;
  42069. /**
  42070. * Summary logging while loading
  42071. */
  42072. static readonly SUMMARY_LOGGING: number;
  42073. /**
  42074. * Detailled logging while loading
  42075. */
  42076. static readonly DETAILED_LOGGING: number;
  42077. /**
  42078. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42079. */
  42080. static ForceFullSceneLoadingForIncremental: boolean;
  42081. /**
  42082. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42083. */
  42084. static ShowLoadingScreen: boolean;
  42085. /**
  42086. * Defines the current logging level (while loading the scene)
  42087. * @ignorenaming
  42088. */
  42089. static loggingLevel: number;
  42090. /**
  42091. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42092. */
  42093. static CleanBoneMatrixWeights: boolean;
  42094. /**
  42095. * Event raised when a plugin is used to load a scene
  42096. */
  42097. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42098. private static _registeredPlugins;
  42099. private static _getDefaultPlugin;
  42100. private static _getPluginForExtension;
  42101. private static _getPluginForDirectLoad;
  42102. private static _getPluginForFilename;
  42103. private static _getDirectLoad;
  42104. private static _loadData;
  42105. private static _getFileInfo;
  42106. /**
  42107. * Gets a plugin that can load the given extension
  42108. * @param extension defines the extension to load
  42109. * @returns a plugin or null if none works
  42110. */
  42111. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42112. /**
  42113. * Gets a boolean indicating that the given extension can be loaded
  42114. * @param extension defines the extension to load
  42115. * @returns true if the extension is supported
  42116. */
  42117. static IsPluginForExtensionAvailable(extension: string): boolean;
  42118. /**
  42119. * Adds a new plugin to the list of registered plugins
  42120. * @param plugin defines the plugin to add
  42121. */
  42122. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42123. /**
  42124. * Import meshes into a scene
  42125. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42126. * @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)
  42127. * @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)
  42128. * @param scene the instance of BABYLON.Scene to append to
  42129. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42130. * @param onProgress a callback with a progress event for each file being loaded
  42131. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42132. * @param pluginExtension the extension used to determine the plugin
  42133. * @returns The loaded plugin
  42134. */
  42135. 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>;
  42136. /**
  42137. * Import meshes into a scene
  42138. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42139. * @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)
  42140. * @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)
  42141. * @param scene the instance of BABYLON.Scene to append to
  42142. * @param onProgress a callback with a progress event for each file being loaded
  42143. * @param pluginExtension the extension used to determine the plugin
  42144. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42145. */
  42146. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42147. meshes: AbstractMesh[];
  42148. particleSystems: IParticleSystem[];
  42149. skeletons: Skeleton[];
  42150. animationGroups: AnimationGroup[];
  42151. }>;
  42152. /**
  42153. * Load a scene
  42154. * @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)
  42155. * @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)
  42156. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42157. * @param onSuccess a callback with the scene when import succeeds
  42158. * @param onProgress a callback with a progress event for each file being loaded
  42159. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42160. * @param pluginExtension the extension used to determine the plugin
  42161. * @returns The loaded plugin
  42162. */
  42163. 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>;
  42164. /**
  42165. * Load a scene
  42166. * @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)
  42167. * @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)
  42168. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42169. * @param onProgress a callback with a progress event for each file being loaded
  42170. * @param pluginExtension the extension used to determine the plugin
  42171. * @returns The loaded scene
  42172. */
  42173. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42174. /**
  42175. * Append a scene
  42176. * @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)
  42177. * @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)
  42178. * @param scene is the instance of BABYLON.Scene to append to
  42179. * @param onSuccess a callback with the scene when import succeeds
  42180. * @param onProgress a callback with a progress event for each file being loaded
  42181. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42182. * @param pluginExtension the extension used to determine the plugin
  42183. * @returns The loaded plugin
  42184. */
  42185. 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>;
  42186. /**
  42187. * Append a scene
  42188. * @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)
  42189. * @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)
  42190. * @param scene is the instance of BABYLON.Scene to append to
  42191. * @param onProgress a callback with a progress event for each file being loaded
  42192. * @param pluginExtension the extension used to determine the plugin
  42193. * @returns The given scene
  42194. */
  42195. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42196. /**
  42197. * Load a scene into an asset container
  42198. * @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)
  42199. * @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)
  42200. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42201. * @param onSuccess a callback with the scene when import succeeds
  42202. * @param onProgress a callback with a progress event for each file being loaded
  42203. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42204. * @param pluginExtension the extension used to determine the plugin
  42205. * @returns The loaded plugin
  42206. */
  42207. 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>;
  42208. /**
  42209. * Load a scene into an asset container
  42210. * @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)
  42211. * @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)
  42212. * @param scene is the instance of Scene to append to
  42213. * @param onProgress a callback with a progress event for each file being loaded
  42214. * @param pluginExtension the extension used to determine the plugin
  42215. * @returns The loaded asset container
  42216. */
  42217. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42218. }
  42219. }
  42220. declare module BABYLON {
  42221. /**
  42222. * Google Daydream controller
  42223. */
  42224. export class DaydreamController extends WebVRController {
  42225. /**
  42226. * Base Url for the controller model.
  42227. */
  42228. static MODEL_BASE_URL: string;
  42229. /**
  42230. * File name for the controller model.
  42231. */
  42232. static MODEL_FILENAME: string;
  42233. /**
  42234. * Gamepad Id prefix used to identify Daydream Controller.
  42235. */
  42236. static readonly GAMEPAD_ID_PREFIX: string;
  42237. /**
  42238. * Creates a new DaydreamController from a gamepad
  42239. * @param vrGamepad the gamepad that the controller should be created from
  42240. */
  42241. constructor(vrGamepad: any);
  42242. /**
  42243. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42244. * @param scene scene in which to add meshes
  42245. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42246. */
  42247. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42248. /**
  42249. * Called once for each button that changed state since the last frame
  42250. * @param buttonIdx Which button index changed
  42251. * @param state New state of the button
  42252. * @param changes Which properties on the state changed since last frame
  42253. */
  42254. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42255. }
  42256. }
  42257. declare module BABYLON {
  42258. /**
  42259. * Gear VR Controller
  42260. */
  42261. export class GearVRController extends WebVRController {
  42262. /**
  42263. * Base Url for the controller model.
  42264. */
  42265. static MODEL_BASE_URL: string;
  42266. /**
  42267. * File name for the controller model.
  42268. */
  42269. static MODEL_FILENAME: string;
  42270. /**
  42271. * Gamepad Id prefix used to identify this controller.
  42272. */
  42273. static readonly GAMEPAD_ID_PREFIX: string;
  42274. private readonly _buttonIndexToObservableNameMap;
  42275. /**
  42276. * Creates a new GearVRController from a gamepad
  42277. * @param vrGamepad the gamepad that the controller should be created from
  42278. */
  42279. constructor(vrGamepad: any);
  42280. /**
  42281. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42282. * @param scene scene in which to add meshes
  42283. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42284. */
  42285. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42286. /**
  42287. * Called once for each button that changed state since the last frame
  42288. * @param buttonIdx Which button index changed
  42289. * @param state New state of the button
  42290. * @param changes Which properties on the state changed since last frame
  42291. */
  42292. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42293. }
  42294. }
  42295. declare module BABYLON {
  42296. /**
  42297. * Generic Controller
  42298. */
  42299. export class GenericController extends WebVRController {
  42300. /**
  42301. * Base Url for the controller model.
  42302. */
  42303. static readonly MODEL_BASE_URL: string;
  42304. /**
  42305. * File name for the controller model.
  42306. */
  42307. static readonly MODEL_FILENAME: string;
  42308. /**
  42309. * Creates a new GenericController from a gamepad
  42310. * @param vrGamepad the gamepad that the controller should be created from
  42311. */
  42312. constructor(vrGamepad: any);
  42313. /**
  42314. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42315. * @param scene scene in which to add meshes
  42316. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42317. */
  42318. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42319. /**
  42320. * Called once for each button that changed state since the last frame
  42321. * @param buttonIdx Which button index changed
  42322. * @param state New state of the button
  42323. * @param changes Which properties on the state changed since last frame
  42324. */
  42325. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * Oculus Touch Controller
  42331. */
  42332. export class OculusTouchController extends WebVRController {
  42333. /**
  42334. * Base Url for the controller model.
  42335. */
  42336. static MODEL_BASE_URL: string;
  42337. /**
  42338. * File name for the left controller model.
  42339. */
  42340. static MODEL_LEFT_FILENAME: string;
  42341. /**
  42342. * File name for the right controller model.
  42343. */
  42344. static MODEL_RIGHT_FILENAME: string;
  42345. /**
  42346. * Fired when the secondary trigger on this controller is modified
  42347. */
  42348. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42349. /**
  42350. * Fired when the thumb rest on this controller is modified
  42351. */
  42352. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42353. /**
  42354. * Creates a new OculusTouchController from a gamepad
  42355. * @param vrGamepad the gamepad that the controller should be created from
  42356. */
  42357. constructor(vrGamepad: any);
  42358. /**
  42359. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42360. * @param scene scene in which to add meshes
  42361. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42362. */
  42363. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42364. /**
  42365. * Fired when the A button on this controller is modified
  42366. */
  42367. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42368. /**
  42369. * Fired when the B button on this controller is modified
  42370. */
  42371. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42372. /**
  42373. * Fired when the X button on this controller is modified
  42374. */
  42375. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42376. /**
  42377. * Fired when the Y button on this controller is modified
  42378. */
  42379. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42380. /**
  42381. * Called once for each button that changed state since the last frame
  42382. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42383. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42384. * 2) secondary trigger (same)
  42385. * 3) A (right) X (left), touch, pressed = value
  42386. * 4) B / Y
  42387. * 5) thumb rest
  42388. * @param buttonIdx Which button index changed
  42389. * @param state New state of the button
  42390. * @param changes Which properties on the state changed since last frame
  42391. */
  42392. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42393. }
  42394. }
  42395. declare module BABYLON {
  42396. /**
  42397. * Vive Controller
  42398. */
  42399. export class ViveController extends WebVRController {
  42400. /**
  42401. * Base Url for the controller model.
  42402. */
  42403. static MODEL_BASE_URL: string;
  42404. /**
  42405. * File name for the controller model.
  42406. */
  42407. static MODEL_FILENAME: string;
  42408. /**
  42409. * Creates a new ViveController from a gamepad
  42410. * @param vrGamepad the gamepad that the controller should be created from
  42411. */
  42412. constructor(vrGamepad: any);
  42413. /**
  42414. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42415. * @param scene scene in which to add meshes
  42416. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42417. */
  42418. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42419. /**
  42420. * Fired when the left button on this controller is modified
  42421. */
  42422. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42423. /**
  42424. * Fired when the right button on this controller is modified
  42425. */
  42426. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42427. /**
  42428. * Fired when the menu button on this controller is modified
  42429. */
  42430. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42431. /**
  42432. * Called once for each button that changed state since the last frame
  42433. * Vive mapping:
  42434. * 0: touchpad
  42435. * 1: trigger
  42436. * 2: left AND right buttons
  42437. * 3: menu button
  42438. * @param buttonIdx Which button index changed
  42439. * @param state New state of the button
  42440. * @param changes Which properties on the state changed since last frame
  42441. */
  42442. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42443. }
  42444. }
  42445. declare module BABYLON {
  42446. /**
  42447. * Defines the WindowsMotionController object that the state of the windows motion controller
  42448. */
  42449. export class WindowsMotionController extends WebVRController {
  42450. /**
  42451. * The base url used to load the left and right controller models
  42452. */
  42453. static MODEL_BASE_URL: string;
  42454. /**
  42455. * The name of the left controller model file
  42456. */
  42457. static MODEL_LEFT_FILENAME: string;
  42458. /**
  42459. * The name of the right controller model file
  42460. */
  42461. static MODEL_RIGHT_FILENAME: string;
  42462. /**
  42463. * The controller name prefix for this controller type
  42464. */
  42465. static readonly GAMEPAD_ID_PREFIX: string;
  42466. /**
  42467. * The controller id pattern for this controller type
  42468. */
  42469. private static readonly GAMEPAD_ID_PATTERN;
  42470. private _loadedMeshInfo;
  42471. private readonly _mapping;
  42472. /**
  42473. * Fired when the trackpad on this controller is clicked
  42474. */
  42475. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42476. /**
  42477. * Fired when the trackpad on this controller is modified
  42478. */
  42479. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42480. /**
  42481. * The current x and y values of this controller's trackpad
  42482. */
  42483. trackpad: StickValues;
  42484. /**
  42485. * Creates a new WindowsMotionController from a gamepad
  42486. * @param vrGamepad the gamepad that the controller should be created from
  42487. */
  42488. constructor(vrGamepad: any);
  42489. /**
  42490. * Fired when the trigger on this controller is modified
  42491. */
  42492. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42493. /**
  42494. * Fired when the menu button on this controller is modified
  42495. */
  42496. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42497. /**
  42498. * Fired when the grip button on this controller is modified
  42499. */
  42500. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42501. /**
  42502. * Fired when the thumbstick button on this controller is modified
  42503. */
  42504. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42505. /**
  42506. * Fired when the touchpad button on this controller is modified
  42507. */
  42508. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42509. /**
  42510. * Fired when the touchpad values on this controller are modified
  42511. */
  42512. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42513. private _updateTrackpad;
  42514. /**
  42515. * Called once per frame by the engine.
  42516. */
  42517. update(): void;
  42518. /**
  42519. * Called once for each button that changed state since the last frame
  42520. * @param buttonIdx Which button index changed
  42521. * @param state New state of the button
  42522. * @param changes Which properties on the state changed since last frame
  42523. */
  42524. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42525. /**
  42526. * Moves the buttons on the controller mesh based on their current state
  42527. * @param buttonName the name of the button to move
  42528. * @param buttonValue the value of the button which determines the buttons new position
  42529. */
  42530. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42531. /**
  42532. * Moves the axis on the controller mesh based on its current state
  42533. * @param axis the index of the axis
  42534. * @param axisValue the value of the axis which determines the meshes new position
  42535. * @hidden
  42536. */
  42537. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42538. /**
  42539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42540. * @param scene scene in which to add meshes
  42541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42542. */
  42543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42544. /**
  42545. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42546. * can be transformed by button presses and axes values, based on this._mapping.
  42547. *
  42548. * @param scene scene in which the meshes exist
  42549. * @param meshes list of meshes that make up the controller model to process
  42550. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42551. */
  42552. private processModel;
  42553. private createMeshInfo;
  42554. /**
  42555. * Gets the ray of the controller in the direction the controller is pointing
  42556. * @param length the length the resulting ray should be
  42557. * @returns a ray in the direction the controller is pointing
  42558. */
  42559. getForwardRay(length?: number): Ray;
  42560. /**
  42561. * Disposes of the controller
  42562. */
  42563. dispose(): void;
  42564. }
  42565. }
  42566. declare module BABYLON {
  42567. /**
  42568. * Single axis scale gizmo
  42569. */
  42570. export class AxisScaleGizmo extends Gizmo {
  42571. private _coloredMaterial;
  42572. /**
  42573. * Drag behavior responsible for the gizmos dragging interactions
  42574. */
  42575. dragBehavior: PointerDragBehavior;
  42576. private _pointerObserver;
  42577. /**
  42578. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42579. */
  42580. snapDistance: number;
  42581. /**
  42582. * Event that fires each time the gizmo snaps to a new location.
  42583. * * snapDistance is the the change in distance
  42584. */
  42585. onSnapObservable: Observable<{
  42586. snapDistance: number;
  42587. }>;
  42588. /**
  42589. * If the scaling operation should be done on all axis (default: false)
  42590. */
  42591. uniformScaling: boolean;
  42592. /**
  42593. * Creates an AxisScaleGizmo
  42594. * @param gizmoLayer The utility layer the gizmo will be added to
  42595. * @param dragAxis The axis which the gizmo will be able to scale on
  42596. * @param color The color of the gizmo
  42597. */
  42598. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42599. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42600. /**
  42601. * Disposes of the gizmo
  42602. */
  42603. dispose(): void;
  42604. /**
  42605. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42606. * @param mesh The mesh to replace the default mesh of the gizmo
  42607. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42608. */
  42609. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42610. }
  42611. }
  42612. declare module BABYLON {
  42613. /**
  42614. * Bounding box gizmo
  42615. */
  42616. export class BoundingBoxGizmo extends Gizmo {
  42617. private _lineBoundingBox;
  42618. private _rotateSpheresParent;
  42619. private _scaleBoxesParent;
  42620. private _boundingDimensions;
  42621. private _renderObserver;
  42622. private _pointerObserver;
  42623. private _scaleDragSpeed;
  42624. private _tmpQuaternion;
  42625. private _tmpVector;
  42626. private _tmpRotationMatrix;
  42627. /**
  42628. * 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)
  42629. */
  42630. ignoreChildren: boolean;
  42631. /**
  42632. * 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)
  42633. */
  42634. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42635. /**
  42636. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42637. */
  42638. rotationSphereSize: number;
  42639. /**
  42640. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42641. */
  42642. scaleBoxSize: number;
  42643. /**
  42644. * 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)
  42645. */
  42646. fixedDragMeshScreenSize: boolean;
  42647. /**
  42648. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42649. */
  42650. fixedDragMeshScreenSizeDistanceFactor: number;
  42651. /**
  42652. * Fired when a rotation sphere or scale box is dragged
  42653. */
  42654. onDragStartObservable: Observable<{}>;
  42655. /**
  42656. * Fired when a scale box is dragged
  42657. */
  42658. onScaleBoxDragObservable: Observable<{}>;
  42659. /**
  42660. * Fired when a scale box drag is ended
  42661. */
  42662. onScaleBoxDragEndObservable: Observable<{}>;
  42663. /**
  42664. * Fired when a rotation sphere is dragged
  42665. */
  42666. onRotationSphereDragObservable: Observable<{}>;
  42667. /**
  42668. * Fired when a rotation sphere drag is ended
  42669. */
  42670. onRotationSphereDragEndObservable: Observable<{}>;
  42671. /**
  42672. * 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)
  42673. */
  42674. scalePivot: Nullable<Vector3>;
  42675. /**
  42676. * Mesh used as a pivot to rotate the attached mesh
  42677. */
  42678. private _anchorMesh;
  42679. private _existingMeshScale;
  42680. private _dragMesh;
  42681. private pointerDragBehavior;
  42682. private coloredMaterial;
  42683. private hoverColoredMaterial;
  42684. /**
  42685. * Sets the color of the bounding box gizmo
  42686. * @param color the color to set
  42687. */
  42688. setColor(color: Color3): void;
  42689. /**
  42690. * Creates an BoundingBoxGizmo
  42691. * @param gizmoLayer The utility layer the gizmo will be added to
  42692. * @param color The color of the gizmo
  42693. */
  42694. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42696. private _selectNode;
  42697. /**
  42698. * Updates the bounding box information for the Gizmo
  42699. */
  42700. updateBoundingBox(): void;
  42701. private _updateRotationSpheres;
  42702. private _updateScaleBoxes;
  42703. /**
  42704. * Enables rotation on the specified axis and disables rotation on the others
  42705. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42706. */
  42707. setEnabledRotationAxis(axis: string): void;
  42708. /**
  42709. * Enables/disables scaling
  42710. * @param enable if scaling should be enabled
  42711. */
  42712. setEnabledScaling(enable: boolean): void;
  42713. private _updateDummy;
  42714. /**
  42715. * Enables a pointer drag behavior on the bounding box of the gizmo
  42716. */
  42717. enableDragBehavior(): void;
  42718. /**
  42719. * Disposes of the gizmo
  42720. */
  42721. dispose(): void;
  42722. /**
  42723. * 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)
  42724. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42725. * @returns the bounding box mesh with the passed in mesh as a child
  42726. */
  42727. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42728. /**
  42729. * CustomMeshes are not supported by this gizmo
  42730. * @param mesh The mesh to replace the default mesh of the gizmo
  42731. */
  42732. setCustomMesh(mesh: Mesh): void;
  42733. }
  42734. }
  42735. declare module BABYLON {
  42736. /**
  42737. * Single plane rotation gizmo
  42738. */
  42739. export class PlaneRotationGizmo extends Gizmo {
  42740. /**
  42741. * Drag behavior responsible for the gizmos dragging interactions
  42742. */
  42743. dragBehavior: PointerDragBehavior;
  42744. private _pointerObserver;
  42745. /**
  42746. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42747. */
  42748. snapDistance: number;
  42749. /**
  42750. * Event that fires each time the gizmo snaps to a new location.
  42751. * * snapDistance is the the change in distance
  42752. */
  42753. onSnapObservable: Observable<{
  42754. snapDistance: number;
  42755. }>;
  42756. /**
  42757. * Creates a PlaneRotationGizmo
  42758. * @param gizmoLayer The utility layer the gizmo will be added to
  42759. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42760. * @param color The color of the gizmo
  42761. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42762. */
  42763. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42764. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42765. /**
  42766. * Disposes of the gizmo
  42767. */
  42768. dispose(): void;
  42769. }
  42770. }
  42771. declare module BABYLON {
  42772. /**
  42773. * Gizmo that enables rotating a mesh along 3 axis
  42774. */
  42775. export class RotationGizmo extends Gizmo {
  42776. /**
  42777. * Internal gizmo used for interactions on the x axis
  42778. */
  42779. xGizmo: PlaneRotationGizmo;
  42780. /**
  42781. * Internal gizmo used for interactions on the y axis
  42782. */
  42783. yGizmo: PlaneRotationGizmo;
  42784. /**
  42785. * Internal gizmo used for interactions on the z axis
  42786. */
  42787. zGizmo: PlaneRotationGizmo;
  42788. /** Fires an event when any of it's sub gizmos are dragged */
  42789. onDragStartObservable: Observable<{}>;
  42790. /** Fires an event when any of it's sub gizmos are released from dragging */
  42791. onDragEndObservable: Observable<{}>;
  42792. attachedMesh: Nullable<AbstractMesh>;
  42793. /**
  42794. * Creates a RotationGizmo
  42795. * @param gizmoLayer The utility layer the gizmo will be added to
  42796. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42797. */
  42798. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42799. updateGizmoRotationToMatchAttachedMesh: boolean;
  42800. /**
  42801. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42802. */
  42803. snapDistance: number;
  42804. /**
  42805. * Ratio for the scale of the gizmo (Default: 1)
  42806. */
  42807. scaleRatio: number;
  42808. /**
  42809. * Disposes of the gizmo
  42810. */
  42811. dispose(): void;
  42812. /**
  42813. * CustomMeshes are not supported by this gizmo
  42814. * @param mesh The mesh to replace the default mesh of the gizmo
  42815. */
  42816. setCustomMesh(mesh: Mesh): void;
  42817. }
  42818. }
  42819. declare module BABYLON {
  42820. /**
  42821. * Gizmo that enables dragging a mesh along 3 axis
  42822. */
  42823. export class PositionGizmo extends Gizmo {
  42824. /**
  42825. * Internal gizmo used for interactions on the x axis
  42826. */
  42827. xGizmo: AxisDragGizmo;
  42828. /**
  42829. * Internal gizmo used for interactions on the y axis
  42830. */
  42831. yGizmo: AxisDragGizmo;
  42832. /**
  42833. * Internal gizmo used for interactions on the z axis
  42834. */
  42835. zGizmo: AxisDragGizmo;
  42836. /** Fires an event when any of it's sub gizmos are dragged */
  42837. onDragStartObservable: Observable<{}>;
  42838. /** Fires an event when any of it's sub gizmos are released from dragging */
  42839. onDragEndObservable: Observable<{}>;
  42840. attachedMesh: Nullable<AbstractMesh>;
  42841. /**
  42842. * Creates a PositionGizmo
  42843. * @param gizmoLayer The utility layer the gizmo will be added to
  42844. */
  42845. constructor(gizmoLayer?: UtilityLayerRenderer);
  42846. updateGizmoRotationToMatchAttachedMesh: boolean;
  42847. /**
  42848. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42849. */
  42850. snapDistance: number;
  42851. /**
  42852. * Ratio for the scale of the gizmo (Default: 1)
  42853. */
  42854. scaleRatio: number;
  42855. /**
  42856. * Disposes of the gizmo
  42857. */
  42858. dispose(): void;
  42859. /**
  42860. * CustomMeshes are not supported by this gizmo
  42861. * @param mesh The mesh to replace the default mesh of the gizmo
  42862. */
  42863. setCustomMesh(mesh: Mesh): void;
  42864. }
  42865. }
  42866. declare module BABYLON {
  42867. /**
  42868. * Class containing static functions to help procedurally build meshes
  42869. */
  42870. export class PolyhedronBuilder {
  42871. /**
  42872. * Creates a polyhedron mesh
  42873. * * 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
  42874. * * The parameter `size` (positive float, default 1) sets the polygon size
  42875. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42876. * * 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`
  42877. * * 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
  42878. * * 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)`)
  42879. * * 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
  42880. * * 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
  42881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42882. * * 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
  42883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42884. * @param name defines the name of the mesh
  42885. * @param options defines the options used to create the mesh
  42886. * @param scene defines the hosting scene
  42887. * @returns the polyhedron mesh
  42888. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42889. */
  42890. static CreatePolyhedron(name: string, options: {
  42891. type?: number;
  42892. size?: number;
  42893. sizeX?: number;
  42894. sizeY?: number;
  42895. sizeZ?: number;
  42896. custom?: any;
  42897. faceUV?: Vector4[];
  42898. faceColors?: Color4[];
  42899. flat?: boolean;
  42900. updatable?: boolean;
  42901. sideOrientation?: number;
  42902. frontUVs?: Vector4;
  42903. backUVs?: Vector4;
  42904. }, scene?: Nullable<Scene>): Mesh;
  42905. }
  42906. }
  42907. declare module BABYLON {
  42908. /**
  42909. * Gizmo that enables scaling a mesh along 3 axis
  42910. */
  42911. export class ScaleGizmo extends Gizmo {
  42912. /**
  42913. * Internal gizmo used for interactions on the x axis
  42914. */
  42915. xGizmo: AxisScaleGizmo;
  42916. /**
  42917. * Internal gizmo used for interactions on the y axis
  42918. */
  42919. yGizmo: AxisScaleGizmo;
  42920. /**
  42921. * Internal gizmo used for interactions on the z axis
  42922. */
  42923. zGizmo: AxisScaleGizmo;
  42924. /**
  42925. * Internal gizmo used to scale all axis equally
  42926. */
  42927. uniformScaleGizmo: AxisScaleGizmo;
  42928. /** Fires an event when any of it's sub gizmos are dragged */
  42929. onDragStartObservable: Observable<{}>;
  42930. /** Fires an event when any of it's sub gizmos are released from dragging */
  42931. onDragEndObservable: Observable<{}>;
  42932. attachedMesh: Nullable<AbstractMesh>;
  42933. /**
  42934. * Creates a ScaleGizmo
  42935. * @param gizmoLayer The utility layer the gizmo will be added to
  42936. */
  42937. constructor(gizmoLayer?: UtilityLayerRenderer);
  42938. updateGizmoRotationToMatchAttachedMesh: boolean;
  42939. /**
  42940. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42941. */
  42942. snapDistance: number;
  42943. /**
  42944. * Ratio for the scale of the gizmo (Default: 1)
  42945. */
  42946. scaleRatio: number;
  42947. /**
  42948. * Disposes of the gizmo
  42949. */
  42950. dispose(): void;
  42951. }
  42952. }
  42953. declare module BABYLON {
  42954. /**
  42955. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42956. */
  42957. export class GizmoManager implements IDisposable {
  42958. private scene;
  42959. /**
  42960. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42961. */
  42962. gizmos: {
  42963. positionGizmo: Nullable<PositionGizmo>;
  42964. rotationGizmo: Nullable<RotationGizmo>;
  42965. scaleGizmo: Nullable<ScaleGizmo>;
  42966. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42967. };
  42968. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42969. clearGizmoOnEmptyPointerEvent: boolean;
  42970. /** Fires an event when the manager is attached to a mesh */
  42971. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42972. private _gizmosEnabled;
  42973. private _pointerObserver;
  42974. private _attachedMesh;
  42975. private _boundingBoxColor;
  42976. private _defaultUtilityLayer;
  42977. private _defaultKeepDepthUtilityLayer;
  42978. /**
  42979. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42980. */
  42981. boundingBoxDragBehavior: SixDofDragBehavior;
  42982. /**
  42983. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42984. */
  42985. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42986. /**
  42987. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42988. */
  42989. usePointerToAttachGizmos: boolean;
  42990. /**
  42991. * Instatiates a gizmo manager
  42992. * @param scene the scene to overlay the gizmos on top of
  42993. */
  42994. constructor(scene: Scene);
  42995. /**
  42996. * Attaches a set of gizmos to the specified mesh
  42997. * @param mesh The mesh the gizmo's should be attached to
  42998. */
  42999. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43000. /**
  43001. * If the position gizmo is enabled
  43002. */
  43003. positionGizmoEnabled: boolean;
  43004. /**
  43005. * If the rotation gizmo is enabled
  43006. */
  43007. rotationGizmoEnabled: boolean;
  43008. /**
  43009. * If the scale gizmo is enabled
  43010. */
  43011. scaleGizmoEnabled: boolean;
  43012. /**
  43013. * If the boundingBox gizmo is enabled
  43014. */
  43015. boundingBoxGizmoEnabled: boolean;
  43016. /**
  43017. * Disposes of the gizmo manager
  43018. */
  43019. dispose(): void;
  43020. }
  43021. }
  43022. declare module BABYLON {
  43023. /**
  43024. * A directional light is defined by a direction (what a surprise!).
  43025. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43026. * 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.
  43027. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43028. */
  43029. export class DirectionalLight extends ShadowLight {
  43030. private _shadowFrustumSize;
  43031. /**
  43032. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43033. */
  43034. /**
  43035. * Specifies a fix frustum size for the shadow generation.
  43036. */
  43037. shadowFrustumSize: number;
  43038. private _shadowOrthoScale;
  43039. /**
  43040. * Gets the shadow projection scale against the optimal computed one.
  43041. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43042. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43043. */
  43044. /**
  43045. * Sets the shadow projection scale against the optimal computed one.
  43046. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43047. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43048. */
  43049. shadowOrthoScale: number;
  43050. /**
  43051. * Automatically compute the projection matrix to best fit (including all the casters)
  43052. * on each frame.
  43053. */
  43054. autoUpdateExtends: boolean;
  43055. private _orthoLeft;
  43056. private _orthoRight;
  43057. private _orthoTop;
  43058. private _orthoBottom;
  43059. /**
  43060. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43061. * The directional light is emitted from everywhere in the given direction.
  43062. * It can cast shadows.
  43063. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43064. * @param name The friendly name of the light
  43065. * @param direction The direction of the light
  43066. * @param scene The scene the light belongs to
  43067. */
  43068. constructor(name: string, direction: Vector3, scene: Scene);
  43069. /**
  43070. * Returns the string "DirectionalLight".
  43071. * @return The class name
  43072. */
  43073. getClassName(): string;
  43074. /**
  43075. * Returns the integer 1.
  43076. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43077. */
  43078. getTypeID(): number;
  43079. /**
  43080. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43081. * Returns the DirectionalLight Shadow projection matrix.
  43082. */
  43083. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43084. /**
  43085. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43086. * Returns the DirectionalLight Shadow projection matrix.
  43087. */
  43088. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43089. /**
  43090. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43091. * Returns the DirectionalLight Shadow projection matrix.
  43092. */
  43093. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43094. protected _buildUniformLayout(): void;
  43095. /**
  43096. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43097. * @param effect The effect to update
  43098. * @param lightIndex The index of the light in the effect to update
  43099. * @returns The directional light
  43100. */
  43101. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43102. /**
  43103. * Gets the minZ used for shadow according to both the scene and the light.
  43104. *
  43105. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43106. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43107. * @param activeCamera The camera we are returning the min for
  43108. * @returns the depth min z
  43109. */
  43110. getDepthMinZ(activeCamera: Camera): number;
  43111. /**
  43112. * Gets the maxZ used for shadow according to both the scene and the light.
  43113. *
  43114. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43115. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43116. * @param activeCamera The camera we are returning the max for
  43117. * @returns the depth max z
  43118. */
  43119. getDepthMaxZ(activeCamera: Camera): number;
  43120. /**
  43121. * Prepares the list of defines specific to the light type.
  43122. * @param defines the list of defines
  43123. * @param lightIndex defines the index of the light for the effect
  43124. */
  43125. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43126. }
  43127. }
  43128. declare module BABYLON {
  43129. /**
  43130. * Class containing static functions to help procedurally build meshes
  43131. */
  43132. export class HemisphereBuilder {
  43133. /**
  43134. * Creates a hemisphere mesh
  43135. * @param name defines the name of the mesh
  43136. * @param options defines the options used to create the mesh
  43137. * @param scene defines the hosting scene
  43138. * @returns the hemisphere mesh
  43139. */
  43140. static CreateHemisphere(name: string, options: {
  43141. segments?: number;
  43142. diameter?: number;
  43143. sideOrientation?: number;
  43144. }, scene: any): Mesh;
  43145. }
  43146. }
  43147. declare module BABYLON {
  43148. /**
  43149. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43150. * These values define a cone of light starting from the position, emitting toward the direction.
  43151. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43152. * and the exponent defines the speed of the decay of the light with distance (reach).
  43153. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43154. */
  43155. export class SpotLight extends ShadowLight {
  43156. private _angle;
  43157. private _innerAngle;
  43158. private _cosHalfAngle;
  43159. private _lightAngleScale;
  43160. private _lightAngleOffset;
  43161. /**
  43162. * Gets the cone angle of the spot light in Radians.
  43163. */
  43164. /**
  43165. * Sets the cone angle of the spot light in Radians.
  43166. */
  43167. angle: number;
  43168. /**
  43169. * Only used in gltf falloff mode, this defines the angle where
  43170. * the directional falloff will start before cutting at angle which could be seen
  43171. * as outer angle.
  43172. */
  43173. /**
  43174. * Only used in gltf falloff mode, this defines the angle where
  43175. * the directional falloff will start before cutting at angle which could be seen
  43176. * as outer angle.
  43177. */
  43178. innerAngle: number;
  43179. private _shadowAngleScale;
  43180. /**
  43181. * Allows scaling the angle of the light for shadow generation only.
  43182. */
  43183. /**
  43184. * Allows scaling the angle of the light for shadow generation only.
  43185. */
  43186. shadowAngleScale: number;
  43187. /**
  43188. * The light decay speed with the distance from the emission spot.
  43189. */
  43190. exponent: number;
  43191. private _projectionTextureMatrix;
  43192. /**
  43193. * Allows reading the projecton texture
  43194. */
  43195. readonly projectionTextureMatrix: Matrix;
  43196. protected _projectionTextureLightNear: number;
  43197. /**
  43198. * Gets the near clip of the Spotlight for texture projection.
  43199. */
  43200. /**
  43201. * Sets the near clip of the Spotlight for texture projection.
  43202. */
  43203. projectionTextureLightNear: number;
  43204. protected _projectionTextureLightFar: number;
  43205. /**
  43206. * Gets the far clip of the Spotlight for texture projection.
  43207. */
  43208. /**
  43209. * Sets the far clip of the Spotlight for texture projection.
  43210. */
  43211. projectionTextureLightFar: number;
  43212. protected _projectionTextureUpDirection: Vector3;
  43213. /**
  43214. * Gets the Up vector of the Spotlight for texture projection.
  43215. */
  43216. /**
  43217. * Sets the Up vector of the Spotlight for texture projection.
  43218. */
  43219. projectionTextureUpDirection: Vector3;
  43220. private _projectionTexture;
  43221. /**
  43222. * Gets the projection texture of the light.
  43223. */
  43224. /**
  43225. * Sets the projection texture of the light.
  43226. */
  43227. projectionTexture: Nullable<BaseTexture>;
  43228. private _projectionTextureViewLightDirty;
  43229. private _projectionTextureProjectionLightDirty;
  43230. private _projectionTextureDirty;
  43231. private _projectionTextureViewTargetVector;
  43232. private _projectionTextureViewLightMatrix;
  43233. private _projectionTextureProjectionLightMatrix;
  43234. private _projectionTextureScalingMatrix;
  43235. /**
  43236. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43237. * It can cast shadows.
  43238. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43239. * @param name The light friendly name
  43240. * @param position The position of the spot light in the scene
  43241. * @param direction The direction of the light in the scene
  43242. * @param angle The cone angle of the light in Radians
  43243. * @param exponent The light decay speed with the distance from the emission spot
  43244. * @param scene The scene the lights belongs to
  43245. */
  43246. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43247. /**
  43248. * Returns the string "SpotLight".
  43249. * @returns the class name
  43250. */
  43251. getClassName(): string;
  43252. /**
  43253. * Returns the integer 2.
  43254. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43255. */
  43256. getTypeID(): number;
  43257. /**
  43258. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43259. */
  43260. protected _setDirection(value: Vector3): void;
  43261. /**
  43262. * Overrides the position setter to recompute the projection texture view light Matrix.
  43263. */
  43264. protected _setPosition(value: Vector3): void;
  43265. /**
  43266. * 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.
  43267. * Returns the SpotLight.
  43268. */
  43269. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43270. protected _computeProjectionTextureViewLightMatrix(): void;
  43271. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43272. /**
  43273. * Main function for light texture projection matrix computing.
  43274. */
  43275. protected _computeProjectionTextureMatrix(): void;
  43276. protected _buildUniformLayout(): void;
  43277. private _computeAngleValues;
  43278. /**
  43279. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43280. * @param effect The effect to update
  43281. * @param lightIndex The index of the light in the effect to update
  43282. * @returns The spot light
  43283. */
  43284. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43285. /**
  43286. * Disposes the light and the associated resources.
  43287. */
  43288. dispose(): void;
  43289. /**
  43290. * Prepares the list of defines specific to the light type.
  43291. * @param defines the list of defines
  43292. * @param lightIndex defines the index of the light for the effect
  43293. */
  43294. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43295. }
  43296. }
  43297. declare module BABYLON {
  43298. /**
  43299. * Gizmo that enables viewing a light
  43300. */
  43301. export class LightGizmo extends Gizmo {
  43302. private _lightMesh;
  43303. private _material;
  43304. private cachedPosition;
  43305. private cachedForward;
  43306. /**
  43307. * Creates a LightGizmo
  43308. * @param gizmoLayer The utility layer the gizmo will be added to
  43309. */
  43310. constructor(gizmoLayer?: UtilityLayerRenderer);
  43311. private _light;
  43312. /**
  43313. * The light that the gizmo is attached to
  43314. */
  43315. light: Nullable<Light>;
  43316. /**
  43317. * @hidden
  43318. * Updates the gizmo to match the attached mesh's position/rotation
  43319. */
  43320. protected _update(): void;
  43321. private static _Scale;
  43322. /**
  43323. * Creates the lines for a light mesh
  43324. */
  43325. private static _createLightLines;
  43326. /**
  43327. * Disposes of the light gizmo
  43328. */
  43329. dispose(): void;
  43330. private static _CreateHemisphericLightMesh;
  43331. private static _CreatePointLightMesh;
  43332. private static _CreateSpotLightMesh;
  43333. private static _CreateDirectionalLightMesh;
  43334. }
  43335. }
  43336. declare module BABYLON {
  43337. /** @hidden */
  43338. export var backgroundFragmentDeclaration: {
  43339. name: string;
  43340. shader: string;
  43341. };
  43342. }
  43343. declare module BABYLON {
  43344. /** @hidden */
  43345. export var backgroundUboDeclaration: {
  43346. name: string;
  43347. shader: string;
  43348. };
  43349. }
  43350. declare module BABYLON {
  43351. /** @hidden */
  43352. export var backgroundPixelShader: {
  43353. name: string;
  43354. shader: string;
  43355. };
  43356. }
  43357. declare module BABYLON {
  43358. /** @hidden */
  43359. export var backgroundVertexDeclaration: {
  43360. name: string;
  43361. shader: string;
  43362. };
  43363. }
  43364. declare module BABYLON {
  43365. /** @hidden */
  43366. export var backgroundVertexShader: {
  43367. name: string;
  43368. shader: string;
  43369. };
  43370. }
  43371. declare module BABYLON {
  43372. /**
  43373. * Background material used to create an efficient environement around your scene.
  43374. */
  43375. export class BackgroundMaterial extends PushMaterial {
  43376. /**
  43377. * Standard reflectance value at parallel view angle.
  43378. */
  43379. static StandardReflectance0: number;
  43380. /**
  43381. * Standard reflectance value at grazing angle.
  43382. */
  43383. static StandardReflectance90: number;
  43384. protected _primaryColor: Color3;
  43385. /**
  43386. * Key light Color (multiply against the environement texture)
  43387. */
  43388. primaryColor: Color3;
  43389. protected __perceptualColor: Nullable<Color3>;
  43390. /**
  43391. * Experimental Internal Use Only.
  43392. *
  43393. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43394. * This acts as a helper to set the primary color to a more "human friendly" value.
  43395. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43396. * output color as close as possible from the chosen value.
  43397. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43398. * part of lighting setup.)
  43399. */
  43400. _perceptualColor: Nullable<Color3>;
  43401. protected _primaryColorShadowLevel: float;
  43402. /**
  43403. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43404. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43405. */
  43406. primaryColorShadowLevel: float;
  43407. protected _primaryColorHighlightLevel: float;
  43408. /**
  43409. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43410. * The primary color is used at the level chosen to define what the white area would look.
  43411. */
  43412. primaryColorHighlightLevel: float;
  43413. protected _reflectionTexture: Nullable<BaseTexture>;
  43414. /**
  43415. * Reflection Texture used in the material.
  43416. * Should be author in a specific way for the best result (refer to the documentation).
  43417. */
  43418. reflectionTexture: Nullable<BaseTexture>;
  43419. protected _reflectionBlur: float;
  43420. /**
  43421. * Reflection Texture level of blur.
  43422. *
  43423. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43424. * texture twice.
  43425. */
  43426. reflectionBlur: float;
  43427. protected _diffuseTexture: Nullable<BaseTexture>;
  43428. /**
  43429. * Diffuse Texture used in the material.
  43430. * Should be author in a specific way for the best result (refer to the documentation).
  43431. */
  43432. diffuseTexture: Nullable<BaseTexture>;
  43433. protected _shadowLights: Nullable<IShadowLight[]>;
  43434. /**
  43435. * Specify the list of lights casting shadow on the material.
  43436. * All scene shadow lights will be included if null.
  43437. */
  43438. shadowLights: Nullable<IShadowLight[]>;
  43439. protected _shadowLevel: float;
  43440. /**
  43441. * Helps adjusting the shadow to a softer level if required.
  43442. * 0 means black shadows and 1 means no shadows.
  43443. */
  43444. shadowLevel: float;
  43445. protected _sceneCenter: Vector3;
  43446. /**
  43447. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43448. * It is usually zero but might be interesting to modify according to your setup.
  43449. */
  43450. sceneCenter: Vector3;
  43451. protected _opacityFresnel: boolean;
  43452. /**
  43453. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43454. * This helps ensuring a nice transition when the camera goes under the ground.
  43455. */
  43456. opacityFresnel: boolean;
  43457. protected _reflectionFresnel: boolean;
  43458. /**
  43459. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43460. * This helps adding a mirror texture on the ground.
  43461. */
  43462. reflectionFresnel: boolean;
  43463. protected _reflectionFalloffDistance: number;
  43464. /**
  43465. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43466. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43467. */
  43468. reflectionFalloffDistance: number;
  43469. protected _reflectionAmount: number;
  43470. /**
  43471. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43472. */
  43473. reflectionAmount: number;
  43474. protected _reflectionReflectance0: number;
  43475. /**
  43476. * This specifies the weight of the reflection at grazing angle.
  43477. */
  43478. reflectionReflectance0: number;
  43479. protected _reflectionReflectance90: number;
  43480. /**
  43481. * This specifies the weight of the reflection at a perpendicular point of view.
  43482. */
  43483. reflectionReflectance90: number;
  43484. /**
  43485. * Sets the reflection reflectance fresnel values according to the default standard
  43486. * empirically know to work well :-)
  43487. */
  43488. reflectionStandardFresnelWeight: number;
  43489. protected _useRGBColor: boolean;
  43490. /**
  43491. * Helps to directly use the maps channels instead of their level.
  43492. */
  43493. useRGBColor: boolean;
  43494. protected _enableNoise: boolean;
  43495. /**
  43496. * This helps reducing the banding effect that could occur on the background.
  43497. */
  43498. enableNoise: boolean;
  43499. /**
  43500. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43501. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43502. * Recommended to be keep at 1.0 except for special cases.
  43503. */
  43504. fovMultiplier: number;
  43505. private _fovMultiplier;
  43506. /**
  43507. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43508. */
  43509. useEquirectangularFOV: boolean;
  43510. private _maxSimultaneousLights;
  43511. /**
  43512. * Number of Simultaneous lights allowed on the material.
  43513. */
  43514. maxSimultaneousLights: int;
  43515. /**
  43516. * Default configuration related to image processing available in the Background Material.
  43517. */
  43518. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43519. /**
  43520. * Keep track of the image processing observer to allow dispose and replace.
  43521. */
  43522. private _imageProcessingObserver;
  43523. /**
  43524. * Attaches a new image processing configuration to the PBR Material.
  43525. * @param configuration (if null the scene configuration will be use)
  43526. */
  43527. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43528. /**
  43529. * Gets the image processing configuration used either in this material.
  43530. */
  43531. /**
  43532. * Sets the Default image processing configuration used either in the this material.
  43533. *
  43534. * If sets to null, the scene one is in use.
  43535. */
  43536. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43537. /**
  43538. * Gets wether the color curves effect is enabled.
  43539. */
  43540. /**
  43541. * Sets wether the color curves effect is enabled.
  43542. */
  43543. cameraColorCurvesEnabled: boolean;
  43544. /**
  43545. * Gets wether the color grading effect is enabled.
  43546. */
  43547. /**
  43548. * Gets wether the color grading effect is enabled.
  43549. */
  43550. cameraColorGradingEnabled: boolean;
  43551. /**
  43552. * Gets wether tonemapping is enabled or not.
  43553. */
  43554. /**
  43555. * Sets wether tonemapping is enabled or not
  43556. */
  43557. cameraToneMappingEnabled: boolean;
  43558. /**
  43559. * The camera exposure used on this material.
  43560. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43561. * This corresponds to a photographic exposure.
  43562. */
  43563. /**
  43564. * The camera exposure used on this material.
  43565. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43566. * This corresponds to a photographic exposure.
  43567. */
  43568. cameraExposure: float;
  43569. /**
  43570. * Gets The camera contrast used on this material.
  43571. */
  43572. /**
  43573. * Sets The camera contrast used on this material.
  43574. */
  43575. cameraContrast: float;
  43576. /**
  43577. * Gets the Color Grading 2D Lookup Texture.
  43578. */
  43579. /**
  43580. * Sets the Color Grading 2D Lookup Texture.
  43581. */
  43582. cameraColorGradingTexture: Nullable<BaseTexture>;
  43583. /**
  43584. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43585. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43586. * 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;
  43587. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43588. */
  43589. /**
  43590. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43591. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43592. * 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;
  43593. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43594. */
  43595. cameraColorCurves: Nullable<ColorCurves>;
  43596. /**
  43597. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43598. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43599. */
  43600. switchToBGR: boolean;
  43601. private _renderTargets;
  43602. private _reflectionControls;
  43603. private _white;
  43604. private _primaryShadowColor;
  43605. private _primaryHighlightColor;
  43606. /**
  43607. * Instantiates a Background Material in the given scene
  43608. * @param name The friendly name of the material
  43609. * @param scene The scene to add the material to
  43610. */
  43611. constructor(name: string, scene: Scene);
  43612. /**
  43613. * Gets a boolean indicating that current material needs to register RTT
  43614. */
  43615. readonly hasRenderTargetTextures: boolean;
  43616. /**
  43617. * The entire material has been created in order to prevent overdraw.
  43618. * @returns false
  43619. */
  43620. needAlphaTesting(): boolean;
  43621. /**
  43622. * The entire material has been created in order to prevent overdraw.
  43623. * @returns true if blending is enable
  43624. */
  43625. needAlphaBlending(): boolean;
  43626. /**
  43627. * Checks wether the material is ready to be rendered for a given mesh.
  43628. * @param mesh The mesh to render
  43629. * @param subMesh The submesh to check against
  43630. * @param useInstances Specify wether or not the material is used with instances
  43631. * @returns true if all the dependencies are ready (Textures, Effects...)
  43632. */
  43633. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43634. /**
  43635. * Compute the primary color according to the chosen perceptual color.
  43636. */
  43637. private _computePrimaryColorFromPerceptualColor;
  43638. /**
  43639. * Compute the highlights and shadow colors according to their chosen levels.
  43640. */
  43641. private _computePrimaryColors;
  43642. /**
  43643. * Build the uniform buffer used in the material.
  43644. */
  43645. buildUniformLayout(): void;
  43646. /**
  43647. * Unbind the material.
  43648. */
  43649. unbind(): void;
  43650. /**
  43651. * Bind only the world matrix to the material.
  43652. * @param world The world matrix to bind.
  43653. */
  43654. bindOnlyWorldMatrix(world: Matrix): void;
  43655. /**
  43656. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43657. * @param world The world matrix to bind.
  43658. * @param subMesh The submesh to bind for.
  43659. */
  43660. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43661. /**
  43662. * Dispose the material.
  43663. * @param forceDisposeEffect Force disposal of the associated effect.
  43664. * @param forceDisposeTextures Force disposal of the associated textures.
  43665. */
  43666. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43667. /**
  43668. * Clones the material.
  43669. * @param name The cloned name.
  43670. * @returns The cloned material.
  43671. */
  43672. clone(name: string): BackgroundMaterial;
  43673. /**
  43674. * Serializes the current material to its JSON representation.
  43675. * @returns The JSON representation.
  43676. */
  43677. serialize(): any;
  43678. /**
  43679. * Gets the class name of the material
  43680. * @returns "BackgroundMaterial"
  43681. */
  43682. getClassName(): string;
  43683. /**
  43684. * Parse a JSON input to create back a background material.
  43685. * @param source The JSON data to parse
  43686. * @param scene The scene to create the parsed material in
  43687. * @param rootUrl The root url of the assets the material depends upon
  43688. * @returns the instantiated BackgroundMaterial.
  43689. */
  43690. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43691. }
  43692. }
  43693. declare module BABYLON {
  43694. /**
  43695. * Represents the different options available during the creation of
  43696. * a Environment helper.
  43697. *
  43698. * This can control the default ground, skybox and image processing setup of your scene.
  43699. */
  43700. export interface IEnvironmentHelperOptions {
  43701. /**
  43702. * Specifies wether or not to create a ground.
  43703. * True by default.
  43704. */
  43705. createGround: boolean;
  43706. /**
  43707. * Specifies the ground size.
  43708. * 15 by default.
  43709. */
  43710. groundSize: number;
  43711. /**
  43712. * The texture used on the ground for the main color.
  43713. * Comes from the BabylonJS CDN by default.
  43714. *
  43715. * Remarks: Can be either a texture or a url.
  43716. */
  43717. groundTexture: string | BaseTexture;
  43718. /**
  43719. * The color mixed in the ground texture by default.
  43720. * BabylonJS clearColor by default.
  43721. */
  43722. groundColor: Color3;
  43723. /**
  43724. * Specifies the ground opacity.
  43725. * 1 by default.
  43726. */
  43727. groundOpacity: number;
  43728. /**
  43729. * Enables the ground to receive shadows.
  43730. * True by default.
  43731. */
  43732. enableGroundShadow: boolean;
  43733. /**
  43734. * Helps preventing the shadow to be fully black on the ground.
  43735. * 0.5 by default.
  43736. */
  43737. groundShadowLevel: number;
  43738. /**
  43739. * Creates a mirror texture attach to the ground.
  43740. * false by default.
  43741. */
  43742. enableGroundMirror: boolean;
  43743. /**
  43744. * Specifies the ground mirror size ratio.
  43745. * 0.3 by default as the default kernel is 64.
  43746. */
  43747. groundMirrorSizeRatio: number;
  43748. /**
  43749. * Specifies the ground mirror blur kernel size.
  43750. * 64 by default.
  43751. */
  43752. groundMirrorBlurKernel: number;
  43753. /**
  43754. * Specifies the ground mirror visibility amount.
  43755. * 1 by default
  43756. */
  43757. groundMirrorAmount: number;
  43758. /**
  43759. * Specifies the ground mirror reflectance weight.
  43760. * This uses the standard weight of the background material to setup the fresnel effect
  43761. * of the mirror.
  43762. * 1 by default.
  43763. */
  43764. groundMirrorFresnelWeight: number;
  43765. /**
  43766. * Specifies the ground mirror Falloff distance.
  43767. * This can helps reducing the size of the reflection.
  43768. * 0 by Default.
  43769. */
  43770. groundMirrorFallOffDistance: number;
  43771. /**
  43772. * Specifies the ground mirror texture type.
  43773. * Unsigned Int by Default.
  43774. */
  43775. groundMirrorTextureType: number;
  43776. /**
  43777. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43778. * the shown objects.
  43779. */
  43780. groundYBias: number;
  43781. /**
  43782. * Specifies wether or not to create a skybox.
  43783. * True by default.
  43784. */
  43785. createSkybox: boolean;
  43786. /**
  43787. * Specifies the skybox size.
  43788. * 20 by default.
  43789. */
  43790. skyboxSize: number;
  43791. /**
  43792. * The texture used on the skybox for the main color.
  43793. * Comes from the BabylonJS CDN by default.
  43794. *
  43795. * Remarks: Can be either a texture or a url.
  43796. */
  43797. skyboxTexture: string | BaseTexture;
  43798. /**
  43799. * The color mixed in the skybox texture by default.
  43800. * BabylonJS clearColor by default.
  43801. */
  43802. skyboxColor: Color3;
  43803. /**
  43804. * The background rotation around the Y axis of the scene.
  43805. * This helps aligning the key lights of your scene with the background.
  43806. * 0 by default.
  43807. */
  43808. backgroundYRotation: number;
  43809. /**
  43810. * Compute automatically the size of the elements to best fit with the scene.
  43811. */
  43812. sizeAuto: boolean;
  43813. /**
  43814. * Default position of the rootMesh if autoSize is not true.
  43815. */
  43816. rootPosition: Vector3;
  43817. /**
  43818. * Sets up the image processing in the scene.
  43819. * true by default.
  43820. */
  43821. setupImageProcessing: boolean;
  43822. /**
  43823. * The texture used as your environment texture in the scene.
  43824. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43825. *
  43826. * Remarks: Can be either a texture or a url.
  43827. */
  43828. environmentTexture: string | BaseTexture;
  43829. /**
  43830. * The value of the exposure to apply to the scene.
  43831. * 0.6 by default if setupImageProcessing is true.
  43832. */
  43833. cameraExposure: number;
  43834. /**
  43835. * The value of the contrast to apply to the scene.
  43836. * 1.6 by default if setupImageProcessing is true.
  43837. */
  43838. cameraContrast: number;
  43839. /**
  43840. * Specifies wether or not tonemapping should be enabled in the scene.
  43841. * true by default if setupImageProcessing is true.
  43842. */
  43843. toneMappingEnabled: boolean;
  43844. }
  43845. /**
  43846. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43847. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43848. * It also helps with the default setup of your imageProcessing configuration.
  43849. */
  43850. export class EnvironmentHelper {
  43851. /**
  43852. * Default ground texture URL.
  43853. */
  43854. private static _groundTextureCDNUrl;
  43855. /**
  43856. * Default skybox texture URL.
  43857. */
  43858. private static _skyboxTextureCDNUrl;
  43859. /**
  43860. * Default environment texture URL.
  43861. */
  43862. private static _environmentTextureCDNUrl;
  43863. /**
  43864. * Creates the default options for the helper.
  43865. */
  43866. private static _getDefaultOptions;
  43867. private _rootMesh;
  43868. /**
  43869. * Gets the root mesh created by the helper.
  43870. */
  43871. readonly rootMesh: Mesh;
  43872. private _skybox;
  43873. /**
  43874. * Gets the skybox created by the helper.
  43875. */
  43876. readonly skybox: Nullable<Mesh>;
  43877. private _skyboxTexture;
  43878. /**
  43879. * Gets the skybox texture created by the helper.
  43880. */
  43881. readonly skyboxTexture: Nullable<BaseTexture>;
  43882. private _skyboxMaterial;
  43883. /**
  43884. * Gets the skybox material created by the helper.
  43885. */
  43886. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43887. private _ground;
  43888. /**
  43889. * Gets the ground mesh created by the helper.
  43890. */
  43891. readonly ground: Nullable<Mesh>;
  43892. private _groundTexture;
  43893. /**
  43894. * Gets the ground texture created by the helper.
  43895. */
  43896. readonly groundTexture: Nullable<BaseTexture>;
  43897. private _groundMirror;
  43898. /**
  43899. * Gets the ground mirror created by the helper.
  43900. */
  43901. readonly groundMirror: Nullable<MirrorTexture>;
  43902. /**
  43903. * Gets the ground mirror render list to helps pushing the meshes
  43904. * you wish in the ground reflection.
  43905. */
  43906. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43907. private _groundMaterial;
  43908. /**
  43909. * Gets the ground material created by the helper.
  43910. */
  43911. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43912. /**
  43913. * Stores the creation options.
  43914. */
  43915. private readonly _scene;
  43916. private _options;
  43917. /**
  43918. * This observable will be notified with any error during the creation of the environment,
  43919. * mainly texture creation errors.
  43920. */
  43921. onErrorObservable: Observable<{
  43922. message?: string;
  43923. exception?: any;
  43924. }>;
  43925. /**
  43926. * constructor
  43927. * @param options Defines the options we want to customize the helper
  43928. * @param scene The scene to add the material to
  43929. */
  43930. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43931. /**
  43932. * Updates the background according to the new options
  43933. * @param options
  43934. */
  43935. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43936. /**
  43937. * Sets the primary color of all the available elements.
  43938. * @param color the main color to affect to the ground and the background
  43939. */
  43940. setMainColor(color: Color3): void;
  43941. /**
  43942. * Setup the image processing according to the specified options.
  43943. */
  43944. private _setupImageProcessing;
  43945. /**
  43946. * Setup the environment texture according to the specified options.
  43947. */
  43948. private _setupEnvironmentTexture;
  43949. /**
  43950. * Setup the background according to the specified options.
  43951. */
  43952. private _setupBackground;
  43953. /**
  43954. * Get the scene sizes according to the setup.
  43955. */
  43956. private _getSceneSize;
  43957. /**
  43958. * Setup the ground according to the specified options.
  43959. */
  43960. private _setupGround;
  43961. /**
  43962. * Setup the ground material according to the specified options.
  43963. */
  43964. private _setupGroundMaterial;
  43965. /**
  43966. * Setup the ground diffuse texture according to the specified options.
  43967. */
  43968. private _setupGroundDiffuseTexture;
  43969. /**
  43970. * Setup the ground mirror texture according to the specified options.
  43971. */
  43972. private _setupGroundMirrorTexture;
  43973. /**
  43974. * Setup the ground to receive the mirror texture.
  43975. */
  43976. private _setupMirrorInGroundMaterial;
  43977. /**
  43978. * Setup the skybox according to the specified options.
  43979. */
  43980. private _setupSkybox;
  43981. /**
  43982. * Setup the skybox material according to the specified options.
  43983. */
  43984. private _setupSkyboxMaterial;
  43985. /**
  43986. * Setup the skybox reflection texture according to the specified options.
  43987. */
  43988. private _setupSkyboxReflectionTexture;
  43989. private _errorHandler;
  43990. /**
  43991. * Dispose all the elements created by the Helper.
  43992. */
  43993. dispose(): void;
  43994. }
  43995. }
  43996. declare module BABYLON {
  43997. /**
  43998. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43999. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44000. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44001. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44002. */
  44003. export class PhotoDome extends TransformNode {
  44004. private _useDirectMapping;
  44005. /**
  44006. * The texture being displayed on the sphere
  44007. */
  44008. protected _photoTexture: Texture;
  44009. /**
  44010. * Gets or sets the texture being displayed on the sphere
  44011. */
  44012. photoTexture: Texture;
  44013. /**
  44014. * Observable raised when an error occured while loading the 360 image
  44015. */
  44016. onLoadErrorObservable: Observable<string>;
  44017. /**
  44018. * The skybox material
  44019. */
  44020. protected _material: BackgroundMaterial;
  44021. /**
  44022. * The surface used for the skybox
  44023. */
  44024. protected _mesh: Mesh;
  44025. /**
  44026. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44027. * Also see the options.resolution property.
  44028. */
  44029. fovMultiplier: number;
  44030. /**
  44031. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44032. * @param name Element's name, child elements will append suffixes for their own names.
  44033. * @param urlsOfPhoto defines the url of the photo to display
  44034. * @param options defines an object containing optional or exposed sub element properties
  44035. * @param onError defines a callback called when an error occured while loading the texture
  44036. */
  44037. constructor(name: string, urlOfPhoto: string, options: {
  44038. resolution?: number;
  44039. size?: number;
  44040. useDirectMapping?: boolean;
  44041. faceForward?: boolean;
  44042. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44043. /**
  44044. * Releases resources associated with this node.
  44045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44047. */
  44048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44049. }
  44050. }
  44051. declare module BABYLON {
  44052. /** @hidden */
  44053. export var rgbdDecodePixelShader: {
  44054. name: string;
  44055. shader: string;
  44056. };
  44057. }
  44058. declare module BABYLON {
  44059. /**
  44060. * Class used to host texture specific utilities
  44061. */
  44062. export class BRDFTextureTools {
  44063. /**
  44064. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44065. * @param texture the texture to expand.
  44066. */
  44067. private static _ExpandDefaultBRDFTexture;
  44068. /**
  44069. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44070. * @param scene defines the hosting scene
  44071. * @returns the environment BRDF texture
  44072. */
  44073. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44074. private static _environmentBRDFBase64Texture;
  44075. }
  44076. }
  44077. declare module BABYLON {
  44078. /**
  44079. * @hidden
  44080. */
  44081. export interface IMaterialClearCoatDefines {
  44082. CLEARCOAT: boolean;
  44083. CLEARCOAT_DEFAULTIOR: boolean;
  44084. CLEARCOAT_TEXTURE: boolean;
  44085. CLEARCOAT_TEXTUREDIRECTUV: number;
  44086. CLEARCOAT_BUMP: boolean;
  44087. CLEARCOAT_BUMPDIRECTUV: number;
  44088. CLEARCOAT_TINT: boolean;
  44089. CLEARCOAT_TINT_TEXTURE: boolean;
  44090. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44091. /** @hidden */
  44092. _areTexturesDirty: boolean;
  44093. }
  44094. /**
  44095. * Define the code related to the clear coat parameters of the pbr material.
  44096. */
  44097. export class PBRClearCoatConfiguration {
  44098. /**
  44099. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44100. * The default fits with a polyurethane material.
  44101. */
  44102. private static readonly _DefaultIndiceOfRefraction;
  44103. private _isEnabled;
  44104. /**
  44105. * Defines if the clear coat is enabled in the material.
  44106. */
  44107. isEnabled: boolean;
  44108. /**
  44109. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44110. */
  44111. intensity: number;
  44112. /**
  44113. * Defines the clear coat layer roughness.
  44114. */
  44115. roughness: number;
  44116. private _indiceOfRefraction;
  44117. /**
  44118. * Defines the indice of refraction of the clear coat.
  44119. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44120. * The default fits with a polyurethane material.
  44121. * Changing the default value is more performance intensive.
  44122. */
  44123. indiceOfRefraction: number;
  44124. private _texture;
  44125. /**
  44126. * Stores the clear coat values in a texture.
  44127. */
  44128. texture: Nullable<BaseTexture>;
  44129. private _bumpTexture;
  44130. /**
  44131. * Define the clear coat specific bump texture.
  44132. */
  44133. bumpTexture: Nullable<BaseTexture>;
  44134. private _isTintEnabled;
  44135. /**
  44136. * Defines if the clear coat tint is enabled in the material.
  44137. */
  44138. isTintEnabled: boolean;
  44139. /**
  44140. * Defines the clear coat tint of the material.
  44141. * This is only use if tint is enabled
  44142. */
  44143. tintColor: Color3;
  44144. /**
  44145. * Defines the distance at which the tint color should be found in the
  44146. * clear coat media.
  44147. * This is only use if tint is enabled
  44148. */
  44149. tintColorAtDistance: number;
  44150. /**
  44151. * Defines the clear coat layer thickness.
  44152. * This is only use if tint is enabled
  44153. */
  44154. tintThickness: number;
  44155. private _tintTexture;
  44156. /**
  44157. * Stores the clear tint values in a texture.
  44158. * rgb is tint
  44159. * a is a thickness factor
  44160. */
  44161. tintTexture: Nullable<BaseTexture>;
  44162. /** @hidden */
  44163. private _internalMarkAllSubMeshesAsTexturesDirty;
  44164. /** @hidden */
  44165. _markAllSubMeshesAsTexturesDirty(): void;
  44166. /**
  44167. * Instantiate a new istance of clear coat configuration.
  44168. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44169. */
  44170. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44171. /**
  44172. * Gets wehter the submesh is ready to be used or not.
  44173. * @param defines the list of "defines" to update.
  44174. * @param scene defines the scene the material belongs to.
  44175. * @param engine defines the engine the material belongs to.
  44176. * @param disableBumpMap defines wether the material disables bump or not.
  44177. * @returns - boolean indicating that the submesh is ready or not.
  44178. */
  44179. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44180. /**
  44181. * Checks to see if a texture is used in the material.
  44182. * @param defines the list of "defines" to update.
  44183. * @param scene defines the scene to the material belongs to.
  44184. */
  44185. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44186. /**
  44187. * Binds the material data.
  44188. * @param uniformBuffer defines the Uniform buffer to fill in.
  44189. * @param scene defines the scene the material belongs to.
  44190. * @param engine defines the engine the material belongs to.
  44191. * @param disableBumpMap defines wether the material disables bump or not.
  44192. * @param isFrozen defines wether the material is frozen or not.
  44193. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44194. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44195. */
  44196. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44197. /**
  44198. * Checks to see if a texture is used in the material.
  44199. * @param texture - Base texture to use.
  44200. * @returns - Boolean specifying if a texture is used in the material.
  44201. */
  44202. hasTexture(texture: BaseTexture): boolean;
  44203. /**
  44204. * Returns an array of the actively used textures.
  44205. * @param activeTextures Array of BaseTextures
  44206. */
  44207. getActiveTextures(activeTextures: BaseTexture[]): void;
  44208. /**
  44209. * Returns the animatable textures.
  44210. * @param animatables Array of animatable textures.
  44211. */
  44212. getAnimatables(animatables: IAnimatable[]): void;
  44213. /**
  44214. * Disposes the resources of the material.
  44215. * @param forceDisposeTextures - Forces the disposal of all textures.
  44216. */
  44217. dispose(forceDisposeTextures?: boolean): void;
  44218. /**
  44219. * Get the current class name of the texture useful for serialization or dynamic coding.
  44220. * @returns "PBRClearCoatConfiguration"
  44221. */
  44222. getClassName(): string;
  44223. /**
  44224. * Add fallbacks to the effect fallbacks list.
  44225. * @param defines defines the Base texture to use.
  44226. * @param fallbacks defines the current fallback list.
  44227. * @param currentRank defines the current fallback rank.
  44228. * @returns the new fallback rank.
  44229. */
  44230. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44231. /**
  44232. * Add the required uniforms to the current list.
  44233. * @param uniforms defines the current uniform list.
  44234. */
  44235. static AddUniforms(uniforms: string[]): void;
  44236. /**
  44237. * Add the required samplers to the current list.
  44238. * @param samplers defines the current sampler list.
  44239. */
  44240. static AddSamplers(samplers: string[]): void;
  44241. /**
  44242. * Add the required uniforms to the current buffer.
  44243. * @param uniformBuffer defines the current uniform buffer.
  44244. */
  44245. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44246. /**
  44247. * Makes a duplicate of the current configuration into another one.
  44248. * @param clearCoatConfiguration define the config where to copy the info
  44249. */
  44250. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44251. /**
  44252. * Serializes this clear coat configuration.
  44253. * @returns - An object with the serialized config.
  44254. */
  44255. serialize(): any;
  44256. /**
  44257. * Parses a Clear Coat Configuration from a serialized object.
  44258. * @param source - Serialized object.
  44259. */
  44260. parse(source: any): void;
  44261. }
  44262. }
  44263. declare module BABYLON {
  44264. /**
  44265. * @hidden
  44266. */
  44267. export interface IMaterialAnisotropicDefines {
  44268. ANISOTROPIC: boolean;
  44269. ANISOTROPIC_TEXTURE: boolean;
  44270. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44271. MAINUV1: boolean;
  44272. _areTexturesDirty: boolean;
  44273. _needUVs: boolean;
  44274. }
  44275. /**
  44276. * Define the code related to the anisotropic parameters of the pbr material.
  44277. */
  44278. export class PBRAnisotropicConfiguration {
  44279. private _isEnabled;
  44280. /**
  44281. * Defines if the anisotropy is enabled in the material.
  44282. */
  44283. isEnabled: boolean;
  44284. /**
  44285. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44286. */
  44287. intensity: number;
  44288. /**
  44289. * Defines if the effect is along the tangents, bitangents or in between.
  44290. * By default, the effect is "strectching" the highlights along the tangents.
  44291. */
  44292. direction: Vector2;
  44293. private _texture;
  44294. /**
  44295. * Stores the anisotropy values in a texture.
  44296. * rg is direction (like normal from -1 to 1)
  44297. * b is a intensity
  44298. */
  44299. texture: Nullable<BaseTexture>;
  44300. /** @hidden */
  44301. private _internalMarkAllSubMeshesAsTexturesDirty;
  44302. /** @hidden */
  44303. _markAllSubMeshesAsTexturesDirty(): void;
  44304. /**
  44305. * Instantiate a new istance of anisotropy configuration.
  44306. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44307. */
  44308. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44309. /**
  44310. * Specifies that the submesh is ready to be used.
  44311. * @param defines the list of "defines" to update.
  44312. * @param scene defines the scene the material belongs to.
  44313. * @returns - boolean indicating that the submesh is ready or not.
  44314. */
  44315. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44316. /**
  44317. * Checks to see if a texture is used in the material.
  44318. * @param defines the list of "defines" to update.
  44319. * @param mesh the mesh we are preparing the defines for.
  44320. * @param scene defines the scene the material belongs to.
  44321. */
  44322. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44323. /**
  44324. * Binds the material data.
  44325. * @param uniformBuffer defines the Uniform buffer to fill in.
  44326. * @param scene defines the scene the material belongs to.
  44327. * @param isFrozen defines wether the material is frozen or not.
  44328. */
  44329. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44330. /**
  44331. * Checks to see if a texture is used in the material.
  44332. * @param texture - Base texture to use.
  44333. * @returns - Boolean specifying if a texture is used in the material.
  44334. */
  44335. hasTexture(texture: BaseTexture): boolean;
  44336. /**
  44337. * Returns an array of the actively used textures.
  44338. * @param activeTextures Array of BaseTextures
  44339. */
  44340. getActiveTextures(activeTextures: BaseTexture[]): void;
  44341. /**
  44342. * Returns the animatable textures.
  44343. * @param animatables Array of animatable textures.
  44344. */
  44345. getAnimatables(animatables: IAnimatable[]): void;
  44346. /**
  44347. * Disposes the resources of the material.
  44348. * @param forceDisposeTextures - Forces the disposal of all textures.
  44349. */
  44350. dispose(forceDisposeTextures?: boolean): void;
  44351. /**
  44352. * Get the current class name of the texture useful for serialization or dynamic coding.
  44353. * @returns "PBRAnisotropicConfiguration"
  44354. */
  44355. getClassName(): string;
  44356. /**
  44357. * Add fallbacks to the effect fallbacks list.
  44358. * @param defines defines the Base texture to use.
  44359. * @param fallbacks defines the current fallback list.
  44360. * @param currentRank defines the current fallback rank.
  44361. * @returns the new fallback rank.
  44362. */
  44363. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44364. /**
  44365. * Add the required uniforms to the current list.
  44366. * @param uniforms defines the current uniform list.
  44367. */
  44368. static AddUniforms(uniforms: string[]): void;
  44369. /**
  44370. * Add the required uniforms to the current buffer.
  44371. * @param uniformBuffer defines the current uniform buffer.
  44372. */
  44373. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44374. /**
  44375. * Add the required samplers to the current list.
  44376. * @param samplers defines the current sampler list.
  44377. */
  44378. static AddSamplers(samplers: string[]): void;
  44379. /**
  44380. * Makes a duplicate of the current configuration into another one.
  44381. * @param anisotropicConfiguration define the config where to copy the info
  44382. */
  44383. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44384. /**
  44385. * Serializes this anisotropy configuration.
  44386. * @returns - An object with the serialized config.
  44387. */
  44388. serialize(): any;
  44389. /**
  44390. * Parses a anisotropy Configuration from a serialized object.
  44391. * @param source - Serialized object.
  44392. */
  44393. parse(source: any): void;
  44394. }
  44395. }
  44396. declare module BABYLON {
  44397. /**
  44398. * @hidden
  44399. */
  44400. export interface IMaterialBRDFDefines {
  44401. BRDF_V_HEIGHT_CORRELATED: boolean;
  44402. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44403. SPHERICAL_HARMONICS: boolean;
  44404. /** @hidden */
  44405. _areMiscDirty: boolean;
  44406. }
  44407. /**
  44408. * Define the code related to the BRDF parameters of the pbr material.
  44409. */
  44410. export class PBRBRDFConfiguration {
  44411. /**
  44412. * Default value used for the energy conservation.
  44413. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44414. */
  44415. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44416. /**
  44417. * Default value used for the Smith Visibility Height Correlated mode.
  44418. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44419. */
  44420. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44421. /**
  44422. * Default value used for the IBL diffuse part.
  44423. * This can help switching back to the polynomials mode globally which is a tiny bit
  44424. * less GPU intensive at the drawback of a lower quality.
  44425. */
  44426. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44427. private _useEnergyConservation;
  44428. /**
  44429. * Defines if the material uses energy conservation.
  44430. */
  44431. useEnergyConservation: boolean;
  44432. private _useSmithVisibilityHeightCorrelated;
  44433. /**
  44434. * LEGACY Mode set to false
  44435. * Defines if the material uses height smith correlated visibility term.
  44436. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44437. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44438. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44439. * Not relying on height correlated will also disable energy conservation.
  44440. */
  44441. useSmithVisibilityHeightCorrelated: boolean;
  44442. private _useSphericalHarmonics;
  44443. /**
  44444. * LEGACY Mode set to false
  44445. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44446. * diffuse part of the IBL.
  44447. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44448. * to the ground truth.
  44449. */
  44450. useSphericalHarmonics: boolean;
  44451. /** @hidden */
  44452. private _internalMarkAllSubMeshesAsMiscDirty;
  44453. /** @hidden */
  44454. _markAllSubMeshesAsMiscDirty(): void;
  44455. /**
  44456. * Instantiate a new istance of clear coat configuration.
  44457. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44458. */
  44459. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44460. /**
  44461. * Checks to see if a texture is used in the material.
  44462. * @param defines the list of "defines" to update.
  44463. */
  44464. prepareDefines(defines: IMaterialBRDFDefines): void;
  44465. /**
  44466. * Get the current class name of the texture useful for serialization or dynamic coding.
  44467. * @returns "PBRClearCoatConfiguration"
  44468. */
  44469. getClassName(): string;
  44470. /**
  44471. * Makes a duplicate of the current configuration into another one.
  44472. * @param brdfConfiguration define the config where to copy the info
  44473. */
  44474. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44475. /**
  44476. * Serializes this BRDF configuration.
  44477. * @returns - An object with the serialized config.
  44478. */
  44479. serialize(): any;
  44480. /**
  44481. * Parses a BRDF Configuration from a serialized object.
  44482. * @param source - Serialized object.
  44483. */
  44484. parse(source: any): void;
  44485. }
  44486. }
  44487. declare module BABYLON {
  44488. /**
  44489. * @hidden
  44490. */
  44491. export interface IMaterialSheenDefines {
  44492. SHEEN: boolean;
  44493. SHEEN_TEXTURE: boolean;
  44494. SHEEN_TEXTUREDIRECTUV: number;
  44495. SHEEN_LINKWITHALBEDO: boolean;
  44496. /** @hidden */
  44497. _areTexturesDirty: boolean;
  44498. }
  44499. /**
  44500. * Define the code related to the Sheen parameters of the pbr material.
  44501. */
  44502. export class PBRSheenConfiguration {
  44503. private _isEnabled;
  44504. /**
  44505. * Defines if the material uses sheen.
  44506. */
  44507. isEnabled: boolean;
  44508. private _linkSheenWithAlbedo;
  44509. /**
  44510. * Defines if the sheen is linked to the sheen color.
  44511. */
  44512. linkSheenWithAlbedo: boolean;
  44513. /**
  44514. * Defines the sheen intensity.
  44515. */
  44516. intensity: number;
  44517. /**
  44518. * Defines the sheen color.
  44519. */
  44520. color: Color3;
  44521. private _texture;
  44522. /**
  44523. * Stores the sheen tint values in a texture.
  44524. * rgb is tint
  44525. * a is a intensity
  44526. */
  44527. texture: Nullable<BaseTexture>;
  44528. /** @hidden */
  44529. private _internalMarkAllSubMeshesAsTexturesDirty;
  44530. /** @hidden */
  44531. _markAllSubMeshesAsTexturesDirty(): void;
  44532. /**
  44533. * Instantiate a new istance of clear coat configuration.
  44534. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44535. */
  44536. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44537. /**
  44538. * Specifies that the submesh is ready to be used.
  44539. * @param defines the list of "defines" to update.
  44540. * @param scene defines the scene the material belongs to.
  44541. * @returns - boolean indicating that the submesh is ready or not.
  44542. */
  44543. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44544. /**
  44545. * Checks to see if a texture is used in the material.
  44546. * @param defines the list of "defines" to update.
  44547. * @param scene defines the scene the material belongs to.
  44548. */
  44549. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44550. /**
  44551. * Binds the material data.
  44552. * @param uniformBuffer defines the Uniform buffer to fill in.
  44553. * @param scene defines the scene the material belongs to.
  44554. * @param isFrozen defines wether the material is frozen or not.
  44555. */
  44556. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44557. /**
  44558. * Checks to see if a texture is used in the material.
  44559. * @param texture - Base texture to use.
  44560. * @returns - Boolean specifying if a texture is used in the material.
  44561. */
  44562. hasTexture(texture: BaseTexture): boolean;
  44563. /**
  44564. * Returns an array of the actively used textures.
  44565. * @param activeTextures Array of BaseTextures
  44566. */
  44567. getActiveTextures(activeTextures: BaseTexture[]): void;
  44568. /**
  44569. * Returns the animatable textures.
  44570. * @param animatables Array of animatable textures.
  44571. */
  44572. getAnimatables(animatables: IAnimatable[]): void;
  44573. /**
  44574. * Disposes the resources of the material.
  44575. * @param forceDisposeTextures - Forces the disposal of all textures.
  44576. */
  44577. dispose(forceDisposeTextures?: boolean): void;
  44578. /**
  44579. * Get the current class name of the texture useful for serialization or dynamic coding.
  44580. * @returns "PBRSheenConfiguration"
  44581. */
  44582. getClassName(): string;
  44583. /**
  44584. * Add fallbacks to the effect fallbacks list.
  44585. * @param defines defines the Base texture to use.
  44586. * @param fallbacks defines the current fallback list.
  44587. * @param currentRank defines the current fallback rank.
  44588. * @returns the new fallback rank.
  44589. */
  44590. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44591. /**
  44592. * Add the required uniforms to the current list.
  44593. * @param uniforms defines the current uniform list.
  44594. */
  44595. static AddUniforms(uniforms: string[]): void;
  44596. /**
  44597. * Add the required uniforms to the current buffer.
  44598. * @param uniformBuffer defines the current uniform buffer.
  44599. */
  44600. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44601. /**
  44602. * Add the required samplers to the current list.
  44603. * @param samplers defines the current sampler list.
  44604. */
  44605. static AddSamplers(samplers: string[]): void;
  44606. /**
  44607. * Makes a duplicate of the current configuration into another one.
  44608. * @param sheenConfiguration define the config where to copy the info
  44609. */
  44610. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44611. /**
  44612. * Serializes this BRDF configuration.
  44613. * @returns - An object with the serialized config.
  44614. */
  44615. serialize(): any;
  44616. /**
  44617. * Parses a Sheen Configuration from a serialized object.
  44618. * @param source - Serialized object.
  44619. */
  44620. parse(source: any): void;
  44621. }
  44622. }
  44623. declare module BABYLON {
  44624. /**
  44625. * @hidden
  44626. */
  44627. export interface IMaterialSubSurfaceDefines {
  44628. SUBSURFACE: boolean;
  44629. SS_REFRACTION: boolean;
  44630. SS_TRANSLUCENCY: boolean;
  44631. SS_SCATERRING: boolean;
  44632. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44633. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44634. SS_REFRACTIONMAP_3D: boolean;
  44635. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44636. SS_LODINREFRACTIONALPHA: boolean;
  44637. SS_GAMMAREFRACTION: boolean;
  44638. SS_RGBDREFRACTION: boolean;
  44639. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44640. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44641. /** @hidden */
  44642. _areTexturesDirty: boolean;
  44643. }
  44644. /**
  44645. * Define the code related to the sub surface parameters of the pbr material.
  44646. */
  44647. export class PBRSubSurfaceConfiguration {
  44648. private _isRefractionEnabled;
  44649. /**
  44650. * Defines if the refraction is enabled in the material.
  44651. */
  44652. isRefractionEnabled: boolean;
  44653. private _isTranslucencyEnabled;
  44654. /**
  44655. * Defines if the translucency is enabled in the material.
  44656. */
  44657. isTranslucencyEnabled: boolean;
  44658. private _isScatteringEnabled;
  44659. /**
  44660. * Defines the refraction intensity of the material.
  44661. * The refraction when enabled replaces the Diffuse part of the material.
  44662. * The intensity helps transitionning between diffuse and refraction.
  44663. */
  44664. refractionIntensity: number;
  44665. /**
  44666. * Defines the translucency intensity of the material.
  44667. * When translucency has been enabled, this defines how much of the "translucency"
  44668. * is addded to the diffuse part of the material.
  44669. */
  44670. translucencyIntensity: number;
  44671. /**
  44672. * Defines the scattering intensity of the material.
  44673. * When scattering has been enabled, this defines how much of the "scattered light"
  44674. * is addded to the diffuse part of the material.
  44675. */
  44676. scatteringIntensity: number;
  44677. private _thicknessTexture;
  44678. /**
  44679. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44680. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44681. * 0 would mean minimumThickness
  44682. * 1 would mean maximumThickness
  44683. * The other channels might be use as a mask to vary the different effects intensity.
  44684. */
  44685. thicknessTexture: Nullable<BaseTexture>;
  44686. private _refractionTexture;
  44687. /**
  44688. * Defines the texture to use for refraction.
  44689. */
  44690. refractionTexture: Nullable<BaseTexture>;
  44691. private _indexOfRefraction;
  44692. /**
  44693. * Defines the indice of refraction used in the material.
  44694. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44695. */
  44696. indexOfRefraction: number;
  44697. private _invertRefractionY;
  44698. /**
  44699. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44700. */
  44701. invertRefractionY: boolean;
  44702. private _linkRefractionWithTransparency;
  44703. /**
  44704. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44705. * Materials half opaque for instance using refraction could benefit from this control.
  44706. */
  44707. linkRefractionWithTransparency: boolean;
  44708. /**
  44709. * Defines the minimum thickness stored in the thickness map.
  44710. * If no thickness map is defined, this value will be used to simulate thickness.
  44711. */
  44712. minimumThickness: number;
  44713. /**
  44714. * Defines the maximum thickness stored in the thickness map.
  44715. */
  44716. maximumThickness: number;
  44717. /**
  44718. * Defines the volume tint of the material.
  44719. * This is used for both translucency and scattering.
  44720. */
  44721. tintColor: Color3;
  44722. /**
  44723. * Defines the distance at which the tint color should be found in the media.
  44724. * This is used for refraction only.
  44725. */
  44726. tintColorAtDistance: number;
  44727. /**
  44728. * Defines how far each channel transmit through the media.
  44729. * It is defined as a color to simplify it selection.
  44730. */
  44731. diffusionDistance: Color3;
  44732. private _useMaskFromThicknessTexture;
  44733. /**
  44734. * Stores the intensity of the different subsurface effects in the thickness texture.
  44735. * * the green channel is the translucency intensity.
  44736. * * the blue channel is the scattering intensity.
  44737. * * the alpha channel is the refraction intensity.
  44738. */
  44739. useMaskFromThicknessTexture: boolean;
  44740. /** @hidden */
  44741. private _internalMarkAllSubMeshesAsTexturesDirty;
  44742. /** @hidden */
  44743. _markAllSubMeshesAsTexturesDirty(): void;
  44744. /**
  44745. * Instantiate a new istance of sub surface configuration.
  44746. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44747. */
  44748. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44749. /**
  44750. * Gets wehter the submesh is ready to be used or not.
  44751. * @param defines the list of "defines" to update.
  44752. * @param scene defines the scene the material belongs to.
  44753. * @returns - boolean indicating that the submesh is ready or not.
  44754. */
  44755. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44756. /**
  44757. * Checks to see if a texture is used in the material.
  44758. * @param defines the list of "defines" to update.
  44759. * @param scene defines the scene to the material belongs to.
  44760. */
  44761. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44762. /**
  44763. * Binds the material data.
  44764. * @param uniformBuffer defines the Uniform buffer to fill in.
  44765. * @param scene defines the scene the material belongs to.
  44766. * @param engine defines the engine the material belongs to.
  44767. * @param isFrozen defines wether the material is frozen or not.
  44768. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44769. */
  44770. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44771. /**
  44772. * Unbinds the material from the mesh.
  44773. * @param activeEffect defines the effect that should be unbound from.
  44774. * @returns true if unbound, otherwise false
  44775. */
  44776. unbind(activeEffect: Effect): boolean;
  44777. /**
  44778. * Returns the texture used for refraction or null if none is used.
  44779. * @param scene defines the scene the material belongs to.
  44780. * @returns - Refraction texture if present. If no refraction texture and refraction
  44781. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44782. */
  44783. private _getRefractionTexture;
  44784. /**
  44785. * Returns true if alpha blending should be disabled.
  44786. */
  44787. readonly disableAlphaBlending: boolean;
  44788. /**
  44789. * Fills the list of render target textures.
  44790. * @param renderTargets the list of render targets to update
  44791. */
  44792. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44793. /**
  44794. * Checks to see if a texture is used in the material.
  44795. * @param texture - Base texture to use.
  44796. * @returns - Boolean specifying if a texture is used in the material.
  44797. */
  44798. hasTexture(texture: BaseTexture): boolean;
  44799. /**
  44800. * Gets a boolean indicating that current material needs to register RTT
  44801. * @returns true if this uses a render target otherwise false.
  44802. */
  44803. hasRenderTargetTextures(): boolean;
  44804. /**
  44805. * Returns an array of the actively used textures.
  44806. * @param activeTextures Array of BaseTextures
  44807. */
  44808. getActiveTextures(activeTextures: BaseTexture[]): void;
  44809. /**
  44810. * Returns the animatable textures.
  44811. * @param animatables Array of animatable textures.
  44812. */
  44813. getAnimatables(animatables: IAnimatable[]): void;
  44814. /**
  44815. * Disposes the resources of the material.
  44816. * @param forceDisposeTextures - Forces the disposal of all textures.
  44817. */
  44818. dispose(forceDisposeTextures?: boolean): void;
  44819. /**
  44820. * Get the current class name of the texture useful for serialization or dynamic coding.
  44821. * @returns "PBRSubSurfaceConfiguration"
  44822. */
  44823. getClassName(): string;
  44824. /**
  44825. * Add fallbacks to the effect fallbacks list.
  44826. * @param defines defines the Base texture to use.
  44827. * @param fallbacks defines the current fallback list.
  44828. * @param currentRank defines the current fallback rank.
  44829. * @returns the new fallback rank.
  44830. */
  44831. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44832. /**
  44833. * Add the required uniforms to the current list.
  44834. * @param uniforms defines the current uniform list.
  44835. */
  44836. static AddUniforms(uniforms: string[]): void;
  44837. /**
  44838. * Add the required samplers to the current list.
  44839. * @param samplers defines the current sampler list.
  44840. */
  44841. static AddSamplers(samplers: string[]): void;
  44842. /**
  44843. * Add the required uniforms to the current buffer.
  44844. * @param uniformBuffer defines the current uniform buffer.
  44845. */
  44846. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44847. /**
  44848. * Makes a duplicate of the current configuration into another one.
  44849. * @param configuration define the config where to copy the info
  44850. */
  44851. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44852. /**
  44853. * Serializes this Sub Surface configuration.
  44854. * @returns - An object with the serialized config.
  44855. */
  44856. serialize(): any;
  44857. /**
  44858. * Parses a Sub Surface Configuration from a serialized object.
  44859. * @param source - Serialized object.
  44860. */
  44861. parse(source: any): void;
  44862. }
  44863. }
  44864. declare module BABYLON {
  44865. /** @hidden */
  44866. export var pbrFragmentDeclaration: {
  44867. name: string;
  44868. shader: string;
  44869. };
  44870. }
  44871. declare module BABYLON {
  44872. /** @hidden */
  44873. export var pbrUboDeclaration: {
  44874. name: string;
  44875. shader: string;
  44876. };
  44877. }
  44878. declare module BABYLON {
  44879. /** @hidden */
  44880. export var pbrFragmentExtraDeclaration: {
  44881. name: string;
  44882. shader: string;
  44883. };
  44884. }
  44885. declare module BABYLON {
  44886. /** @hidden */
  44887. export var pbrFragmentSamplersDeclaration: {
  44888. name: string;
  44889. shader: string;
  44890. };
  44891. }
  44892. declare module BABYLON {
  44893. /** @hidden */
  44894. export var pbrHelperFunctions: {
  44895. name: string;
  44896. shader: string;
  44897. };
  44898. }
  44899. declare module BABYLON {
  44900. /** @hidden */
  44901. export var harmonicsFunctions: {
  44902. name: string;
  44903. shader: string;
  44904. };
  44905. }
  44906. declare module BABYLON {
  44907. /** @hidden */
  44908. export var pbrDirectLightingSetupFunctions: {
  44909. name: string;
  44910. shader: string;
  44911. };
  44912. }
  44913. declare module BABYLON {
  44914. /** @hidden */
  44915. export var pbrDirectLightingFalloffFunctions: {
  44916. name: string;
  44917. shader: string;
  44918. };
  44919. }
  44920. declare module BABYLON {
  44921. /** @hidden */
  44922. export var pbrBRDFFunctions: {
  44923. name: string;
  44924. shader: string;
  44925. };
  44926. }
  44927. declare module BABYLON {
  44928. /** @hidden */
  44929. export var pbrDirectLightingFunctions: {
  44930. name: string;
  44931. shader: string;
  44932. };
  44933. }
  44934. declare module BABYLON {
  44935. /** @hidden */
  44936. export var pbrIBLFunctions: {
  44937. name: string;
  44938. shader: string;
  44939. };
  44940. }
  44941. declare module BABYLON {
  44942. /** @hidden */
  44943. export var pbrDebug: {
  44944. name: string;
  44945. shader: string;
  44946. };
  44947. }
  44948. declare module BABYLON {
  44949. /** @hidden */
  44950. export var pbrPixelShader: {
  44951. name: string;
  44952. shader: string;
  44953. };
  44954. }
  44955. declare module BABYLON {
  44956. /** @hidden */
  44957. export var pbrVertexDeclaration: {
  44958. name: string;
  44959. shader: string;
  44960. };
  44961. }
  44962. declare module BABYLON {
  44963. /** @hidden */
  44964. export var pbrVertexShader: {
  44965. name: string;
  44966. shader: string;
  44967. };
  44968. }
  44969. declare module BABYLON {
  44970. /**
  44971. * Manages the defines for the PBR Material.
  44972. * @hidden
  44973. */
  44974. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44975. PBR: boolean;
  44976. MAINUV1: boolean;
  44977. MAINUV2: boolean;
  44978. UV1: boolean;
  44979. UV2: boolean;
  44980. ALBEDO: boolean;
  44981. ALBEDODIRECTUV: number;
  44982. VERTEXCOLOR: boolean;
  44983. AMBIENT: boolean;
  44984. AMBIENTDIRECTUV: number;
  44985. AMBIENTINGRAYSCALE: boolean;
  44986. OPACITY: boolean;
  44987. VERTEXALPHA: boolean;
  44988. OPACITYDIRECTUV: number;
  44989. OPACITYRGB: boolean;
  44990. ALPHATEST: boolean;
  44991. DEPTHPREPASS: boolean;
  44992. ALPHABLEND: boolean;
  44993. ALPHAFROMALBEDO: boolean;
  44994. ALPHATESTVALUE: string;
  44995. SPECULAROVERALPHA: boolean;
  44996. RADIANCEOVERALPHA: boolean;
  44997. ALPHAFRESNEL: boolean;
  44998. LINEARALPHAFRESNEL: boolean;
  44999. PREMULTIPLYALPHA: boolean;
  45000. EMISSIVE: boolean;
  45001. EMISSIVEDIRECTUV: number;
  45002. REFLECTIVITY: boolean;
  45003. REFLECTIVITYDIRECTUV: number;
  45004. SPECULARTERM: boolean;
  45005. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45006. MICROSURFACEAUTOMATIC: boolean;
  45007. LODBASEDMICROSFURACE: boolean;
  45008. MICROSURFACEMAP: boolean;
  45009. MICROSURFACEMAPDIRECTUV: number;
  45010. METALLICWORKFLOW: boolean;
  45011. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45012. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45013. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45014. AOSTOREINMETALMAPRED: boolean;
  45015. ENVIRONMENTBRDF: boolean;
  45016. ENVIRONMENTBRDF_RGBD: boolean;
  45017. NORMAL: boolean;
  45018. TANGENT: boolean;
  45019. BUMP: boolean;
  45020. BUMPDIRECTUV: number;
  45021. OBJECTSPACE_NORMALMAP: boolean;
  45022. PARALLAX: boolean;
  45023. PARALLAXOCCLUSION: boolean;
  45024. NORMALXYSCALE: boolean;
  45025. LIGHTMAP: boolean;
  45026. LIGHTMAPDIRECTUV: number;
  45027. USELIGHTMAPASSHADOWMAP: boolean;
  45028. GAMMALIGHTMAP: boolean;
  45029. REFLECTION: boolean;
  45030. REFLECTIONMAP_3D: boolean;
  45031. REFLECTIONMAP_SPHERICAL: boolean;
  45032. REFLECTIONMAP_PLANAR: boolean;
  45033. REFLECTIONMAP_CUBIC: boolean;
  45034. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45035. REFLECTIONMAP_PROJECTION: boolean;
  45036. REFLECTIONMAP_SKYBOX: boolean;
  45037. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45038. REFLECTIONMAP_EXPLICIT: boolean;
  45039. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45040. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45041. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45042. INVERTCUBICMAP: boolean;
  45043. USESPHERICALFROMREFLECTIONMAP: boolean;
  45044. SPHERICAL_HARMONICS: boolean;
  45045. USESPHERICALINVERTEX: boolean;
  45046. REFLECTIONMAP_OPPOSITEZ: boolean;
  45047. LODINREFLECTIONALPHA: boolean;
  45048. GAMMAREFLECTION: boolean;
  45049. RGBDREFLECTION: boolean;
  45050. RADIANCEOCCLUSION: boolean;
  45051. HORIZONOCCLUSION: boolean;
  45052. INSTANCES: boolean;
  45053. NUM_BONE_INFLUENCERS: number;
  45054. BonesPerMesh: number;
  45055. BONETEXTURE: boolean;
  45056. NONUNIFORMSCALING: boolean;
  45057. MORPHTARGETS: boolean;
  45058. MORPHTARGETS_NORMAL: boolean;
  45059. MORPHTARGETS_TANGENT: boolean;
  45060. NUM_MORPH_INFLUENCERS: number;
  45061. IMAGEPROCESSING: boolean;
  45062. VIGNETTE: boolean;
  45063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45064. VIGNETTEBLENDMODEOPAQUE: boolean;
  45065. TONEMAPPING: boolean;
  45066. TONEMAPPING_ACES: boolean;
  45067. CONTRAST: boolean;
  45068. COLORCURVES: boolean;
  45069. COLORGRADING: boolean;
  45070. COLORGRADING3D: boolean;
  45071. SAMPLER3DGREENDEPTH: boolean;
  45072. SAMPLER3DBGRMAP: boolean;
  45073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45074. EXPOSURE: boolean;
  45075. MULTIVIEW: boolean;
  45076. USEPHYSICALLIGHTFALLOFF: boolean;
  45077. USEGLTFLIGHTFALLOFF: boolean;
  45078. TWOSIDEDLIGHTING: boolean;
  45079. SHADOWFLOAT: boolean;
  45080. CLIPPLANE: boolean;
  45081. CLIPPLANE2: boolean;
  45082. CLIPPLANE3: boolean;
  45083. CLIPPLANE4: boolean;
  45084. POINTSIZE: boolean;
  45085. FOG: boolean;
  45086. LOGARITHMICDEPTH: boolean;
  45087. FORCENORMALFORWARD: boolean;
  45088. SPECULARAA: boolean;
  45089. CLEARCOAT: boolean;
  45090. CLEARCOAT_DEFAULTIOR: boolean;
  45091. CLEARCOAT_TEXTURE: boolean;
  45092. CLEARCOAT_TEXTUREDIRECTUV: number;
  45093. CLEARCOAT_BUMP: boolean;
  45094. CLEARCOAT_BUMPDIRECTUV: number;
  45095. CLEARCOAT_TINT: boolean;
  45096. CLEARCOAT_TINT_TEXTURE: boolean;
  45097. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45098. ANISOTROPIC: boolean;
  45099. ANISOTROPIC_TEXTURE: boolean;
  45100. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45101. BRDF_V_HEIGHT_CORRELATED: boolean;
  45102. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45103. SHEEN: boolean;
  45104. SHEEN_TEXTURE: boolean;
  45105. SHEEN_TEXTUREDIRECTUV: number;
  45106. SHEEN_LINKWITHALBEDO: boolean;
  45107. SUBSURFACE: boolean;
  45108. SS_REFRACTION: boolean;
  45109. SS_TRANSLUCENCY: boolean;
  45110. SS_SCATERRING: boolean;
  45111. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45112. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45113. SS_REFRACTIONMAP_3D: boolean;
  45114. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45115. SS_LODINREFRACTIONALPHA: boolean;
  45116. SS_GAMMAREFRACTION: boolean;
  45117. SS_RGBDREFRACTION: boolean;
  45118. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45119. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45120. UNLIT: boolean;
  45121. DEBUGMODE: number;
  45122. /**
  45123. * Initializes the PBR Material defines.
  45124. */
  45125. constructor();
  45126. /**
  45127. * Resets the PBR Material defines.
  45128. */
  45129. reset(): void;
  45130. }
  45131. /**
  45132. * The Physically based material base class of BJS.
  45133. *
  45134. * This offers the main features of a standard PBR material.
  45135. * For more information, please refer to the documentation :
  45136. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45137. */
  45138. export abstract class PBRBaseMaterial extends PushMaterial {
  45139. /**
  45140. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45141. */
  45142. static readonly PBRMATERIAL_OPAQUE: number;
  45143. /**
  45144. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45145. */
  45146. static readonly PBRMATERIAL_ALPHATEST: number;
  45147. /**
  45148. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45149. */
  45150. static readonly PBRMATERIAL_ALPHABLEND: number;
  45151. /**
  45152. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45153. * They are also discarded below the alpha cutoff threshold to improve performances.
  45154. */
  45155. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45156. /**
  45157. * Defines the default value of how much AO map is occluding the analytical lights
  45158. * (point spot...).
  45159. */
  45160. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45161. /**
  45162. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45163. */
  45164. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45165. /**
  45166. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45167. * to enhance interoperability with other engines.
  45168. */
  45169. static readonly LIGHTFALLOFF_GLTF: number;
  45170. /**
  45171. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45172. * to enhance interoperability with other materials.
  45173. */
  45174. static readonly LIGHTFALLOFF_STANDARD: number;
  45175. /**
  45176. * Intensity of the direct lights e.g. the four lights available in your scene.
  45177. * This impacts both the direct diffuse and specular highlights.
  45178. */
  45179. protected _directIntensity: number;
  45180. /**
  45181. * Intensity of the emissive part of the material.
  45182. * This helps controlling the emissive effect without modifying the emissive color.
  45183. */
  45184. protected _emissiveIntensity: number;
  45185. /**
  45186. * Intensity of the environment e.g. how much the environment will light the object
  45187. * either through harmonics for rough material or through the refelction for shiny ones.
  45188. */
  45189. protected _environmentIntensity: number;
  45190. /**
  45191. * This is a special control allowing the reduction of the specular highlights coming from the
  45192. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45193. */
  45194. protected _specularIntensity: number;
  45195. /**
  45196. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45197. */
  45198. private _lightingInfos;
  45199. /**
  45200. * Debug Control allowing disabling the bump map on this material.
  45201. */
  45202. protected _disableBumpMap: boolean;
  45203. /**
  45204. * AKA Diffuse Texture in standard nomenclature.
  45205. */
  45206. protected _albedoTexture: Nullable<BaseTexture>;
  45207. /**
  45208. * AKA Occlusion Texture in other nomenclature.
  45209. */
  45210. protected _ambientTexture: Nullable<BaseTexture>;
  45211. /**
  45212. * AKA Occlusion Texture Intensity in other nomenclature.
  45213. */
  45214. protected _ambientTextureStrength: number;
  45215. /**
  45216. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45217. * 1 means it completely occludes it
  45218. * 0 mean it has no impact
  45219. */
  45220. protected _ambientTextureImpactOnAnalyticalLights: number;
  45221. /**
  45222. * Stores the alpha values in a texture.
  45223. */
  45224. protected _opacityTexture: Nullable<BaseTexture>;
  45225. /**
  45226. * Stores the reflection values in a texture.
  45227. */
  45228. protected _reflectionTexture: Nullable<BaseTexture>;
  45229. /**
  45230. * Stores the emissive values in a texture.
  45231. */
  45232. protected _emissiveTexture: Nullable<BaseTexture>;
  45233. /**
  45234. * AKA Specular texture in other nomenclature.
  45235. */
  45236. protected _reflectivityTexture: Nullable<BaseTexture>;
  45237. /**
  45238. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45239. */
  45240. protected _metallicTexture: Nullable<BaseTexture>;
  45241. /**
  45242. * Specifies the metallic scalar of the metallic/roughness workflow.
  45243. * Can also be used to scale the metalness values of the metallic texture.
  45244. */
  45245. protected _metallic: Nullable<number>;
  45246. /**
  45247. * Specifies the roughness scalar of the metallic/roughness workflow.
  45248. * Can also be used to scale the roughness values of the metallic texture.
  45249. */
  45250. protected _roughness: Nullable<number>;
  45251. /**
  45252. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45253. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45254. */
  45255. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45256. /**
  45257. * Stores surface normal data used to displace a mesh in a texture.
  45258. */
  45259. protected _bumpTexture: Nullable<BaseTexture>;
  45260. /**
  45261. * Stores the pre-calculated light information of a mesh in a texture.
  45262. */
  45263. protected _lightmapTexture: Nullable<BaseTexture>;
  45264. /**
  45265. * The color of a material in ambient lighting.
  45266. */
  45267. protected _ambientColor: Color3;
  45268. /**
  45269. * AKA Diffuse Color in other nomenclature.
  45270. */
  45271. protected _albedoColor: Color3;
  45272. /**
  45273. * AKA Specular Color in other nomenclature.
  45274. */
  45275. protected _reflectivityColor: Color3;
  45276. /**
  45277. * The color applied when light is reflected from a material.
  45278. */
  45279. protected _reflectionColor: Color3;
  45280. /**
  45281. * The color applied when light is emitted from a material.
  45282. */
  45283. protected _emissiveColor: Color3;
  45284. /**
  45285. * AKA Glossiness in other nomenclature.
  45286. */
  45287. protected _microSurface: number;
  45288. /**
  45289. * Specifies that the material will use the light map as a show map.
  45290. */
  45291. protected _useLightmapAsShadowmap: boolean;
  45292. /**
  45293. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45294. * makes the reflect vector face the model (under horizon).
  45295. */
  45296. protected _useHorizonOcclusion: boolean;
  45297. /**
  45298. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45299. * too much the area relying on ambient texture to define their ambient occlusion.
  45300. */
  45301. protected _useRadianceOcclusion: boolean;
  45302. /**
  45303. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45304. */
  45305. protected _useAlphaFromAlbedoTexture: boolean;
  45306. /**
  45307. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45308. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45309. */
  45310. protected _useSpecularOverAlpha: boolean;
  45311. /**
  45312. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45313. */
  45314. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45315. /**
  45316. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45317. */
  45318. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45319. /**
  45320. * Specifies if the metallic texture contains the roughness information in its green channel.
  45321. */
  45322. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45323. /**
  45324. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45325. */
  45326. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45327. /**
  45328. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45329. */
  45330. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45331. /**
  45332. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45333. */
  45334. protected _useAmbientInGrayScale: boolean;
  45335. /**
  45336. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45337. * The material will try to infer what glossiness each pixel should be.
  45338. */
  45339. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45340. /**
  45341. * Defines the falloff type used in this material.
  45342. * It by default is Physical.
  45343. */
  45344. protected _lightFalloff: number;
  45345. /**
  45346. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45347. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45348. */
  45349. protected _useRadianceOverAlpha: boolean;
  45350. /**
  45351. * Allows using an object space normal map (instead of tangent space).
  45352. */
  45353. protected _useObjectSpaceNormalMap: boolean;
  45354. /**
  45355. * Allows using the bump map in parallax mode.
  45356. */
  45357. protected _useParallax: boolean;
  45358. /**
  45359. * Allows using the bump map in parallax occlusion mode.
  45360. */
  45361. protected _useParallaxOcclusion: boolean;
  45362. /**
  45363. * Controls the scale bias of the parallax mode.
  45364. */
  45365. protected _parallaxScaleBias: number;
  45366. /**
  45367. * If sets to true, disables all the lights affecting the material.
  45368. */
  45369. protected _disableLighting: boolean;
  45370. /**
  45371. * Number of Simultaneous lights allowed on the material.
  45372. */
  45373. protected _maxSimultaneousLights: number;
  45374. /**
  45375. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45376. */
  45377. protected _invertNormalMapX: boolean;
  45378. /**
  45379. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45380. */
  45381. protected _invertNormalMapY: boolean;
  45382. /**
  45383. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45384. */
  45385. protected _twoSidedLighting: boolean;
  45386. /**
  45387. * Defines the alpha limits in alpha test mode.
  45388. */
  45389. protected _alphaCutOff: number;
  45390. /**
  45391. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45392. */
  45393. protected _forceAlphaTest: boolean;
  45394. /**
  45395. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45396. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45397. */
  45398. protected _useAlphaFresnel: boolean;
  45399. /**
  45400. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45401. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45402. */
  45403. protected _useLinearAlphaFresnel: boolean;
  45404. /**
  45405. * The transparency mode of the material.
  45406. */
  45407. protected _transparencyMode: Nullable<number>;
  45408. /**
  45409. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45410. * from cos thetav and roughness:
  45411. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45412. */
  45413. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45414. /**
  45415. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45416. */
  45417. protected _forceIrradianceInFragment: boolean;
  45418. /**
  45419. * Force normal to face away from face.
  45420. */
  45421. protected _forceNormalForward: boolean;
  45422. /**
  45423. * Enables specular anti aliasing in the PBR shader.
  45424. * It will both interacts on the Geometry for analytical and IBL lighting.
  45425. * It also prefilter the roughness map based on the bump values.
  45426. */
  45427. protected _enableSpecularAntiAliasing: boolean;
  45428. /**
  45429. * Default configuration related to image processing available in the PBR Material.
  45430. */
  45431. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45432. /**
  45433. * Keep track of the image processing observer to allow dispose and replace.
  45434. */
  45435. private _imageProcessingObserver;
  45436. /**
  45437. * Attaches a new image processing configuration to the PBR Material.
  45438. * @param configuration
  45439. */
  45440. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45441. /**
  45442. * Stores the available render targets.
  45443. */
  45444. private _renderTargets;
  45445. /**
  45446. * Sets the global ambient color for the material used in lighting calculations.
  45447. */
  45448. private _globalAmbientColor;
  45449. /**
  45450. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45451. */
  45452. private _useLogarithmicDepth;
  45453. /**
  45454. * If set to true, no lighting calculations will be applied.
  45455. */
  45456. private _unlit;
  45457. private _debugMode;
  45458. /**
  45459. * @hidden
  45460. * This is reserved for the inspector.
  45461. * Defines the material debug mode.
  45462. * It helps seeing only some components of the material while troubleshooting.
  45463. */
  45464. debugMode: number;
  45465. /**
  45466. * @hidden
  45467. * This is reserved for the inspector.
  45468. * Specify from where on screen the debug mode should start.
  45469. * The value goes from -1 (full screen) to 1 (not visible)
  45470. * It helps with side by side comparison against the final render
  45471. * This defaults to -1
  45472. */
  45473. private debugLimit;
  45474. /**
  45475. * @hidden
  45476. * This is reserved for the inspector.
  45477. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45478. * You can use the factor to better multiply the final value.
  45479. */
  45480. private debugFactor;
  45481. /**
  45482. * Defines the clear coat layer parameters for the material.
  45483. */
  45484. readonly clearCoat: PBRClearCoatConfiguration;
  45485. /**
  45486. * Defines the anisotropic parameters for the material.
  45487. */
  45488. readonly anisotropy: PBRAnisotropicConfiguration;
  45489. /**
  45490. * Defines the BRDF parameters for the material.
  45491. */
  45492. readonly brdf: PBRBRDFConfiguration;
  45493. /**
  45494. * Defines the Sheen parameters for the material.
  45495. */
  45496. readonly sheen: PBRSheenConfiguration;
  45497. /**
  45498. * Defines the SubSurface parameters for the material.
  45499. */
  45500. readonly subSurface: PBRSubSurfaceConfiguration;
  45501. /**
  45502. * Custom callback helping to override the default shader used in the material.
  45503. */
  45504. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45505. /**
  45506. * Instantiates a new PBRMaterial instance.
  45507. *
  45508. * @param name The material name
  45509. * @param scene The scene the material will be use in.
  45510. */
  45511. constructor(name: string, scene: Scene);
  45512. /**
  45513. * Gets a boolean indicating that current material needs to register RTT
  45514. */
  45515. readonly hasRenderTargetTextures: boolean;
  45516. /**
  45517. * Gets the name of the material class.
  45518. */
  45519. getClassName(): string;
  45520. /**
  45521. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45522. */
  45523. /**
  45524. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45525. */
  45526. useLogarithmicDepth: boolean;
  45527. /**
  45528. * Gets the current transparency mode.
  45529. */
  45530. /**
  45531. * Sets the transparency mode of the material.
  45532. *
  45533. * | Value | Type | Description |
  45534. * | ----- | ----------------------------------- | ----------- |
  45535. * | 0 | OPAQUE | |
  45536. * | 1 | ALPHATEST | |
  45537. * | 2 | ALPHABLEND | |
  45538. * | 3 | ALPHATESTANDBLEND | |
  45539. *
  45540. */
  45541. transparencyMode: Nullable<number>;
  45542. /**
  45543. * Returns true if alpha blending should be disabled.
  45544. */
  45545. private readonly _disableAlphaBlending;
  45546. /**
  45547. * Specifies whether or not this material should be rendered in alpha blend mode.
  45548. */
  45549. needAlphaBlending(): boolean;
  45550. /**
  45551. * Specifies if the mesh will require alpha blending.
  45552. * @param mesh - BJS mesh.
  45553. */
  45554. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45555. /**
  45556. * Specifies whether or not this material should be rendered in alpha test mode.
  45557. */
  45558. needAlphaTesting(): boolean;
  45559. /**
  45560. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45561. */
  45562. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45563. /**
  45564. * Gets the texture used for the alpha test.
  45565. */
  45566. getAlphaTestTexture(): Nullable<BaseTexture>;
  45567. /**
  45568. * Specifies that the submesh is ready to be used.
  45569. * @param mesh - BJS mesh.
  45570. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45571. * @param useInstances - Specifies that instances should be used.
  45572. * @returns - boolean indicating that the submesh is ready or not.
  45573. */
  45574. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45575. /**
  45576. * Specifies if the material uses metallic roughness workflow.
  45577. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45578. */
  45579. isMetallicWorkflow(): boolean;
  45580. private _prepareEffect;
  45581. private _prepareDefines;
  45582. /**
  45583. * Force shader compilation
  45584. */
  45585. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45586. clipPlane: boolean;
  45587. }>): void;
  45588. /**
  45589. * Initializes the uniform buffer layout for the shader.
  45590. */
  45591. buildUniformLayout(): void;
  45592. /**
  45593. * Unbinds the material from the mesh
  45594. */
  45595. unbind(): void;
  45596. /**
  45597. * Binds the submesh data.
  45598. * @param world - The world matrix.
  45599. * @param mesh - The BJS mesh.
  45600. * @param subMesh - A submesh of the BJS mesh.
  45601. */
  45602. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45603. /**
  45604. * Returns the animatable textures.
  45605. * @returns - Array of animatable textures.
  45606. */
  45607. getAnimatables(): IAnimatable[];
  45608. /**
  45609. * Returns the texture used for reflections.
  45610. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45611. */
  45612. private _getReflectionTexture;
  45613. /**
  45614. * Returns an array of the actively used textures.
  45615. * @returns - Array of BaseTextures
  45616. */
  45617. getActiveTextures(): BaseTexture[];
  45618. /**
  45619. * Checks to see if a texture is used in the material.
  45620. * @param texture - Base texture to use.
  45621. * @returns - Boolean specifying if a texture is used in the material.
  45622. */
  45623. hasTexture(texture: BaseTexture): boolean;
  45624. /**
  45625. * Disposes the resources of the material.
  45626. * @param forceDisposeEffect - Forces the disposal of effects.
  45627. * @param forceDisposeTextures - Forces the disposal of all textures.
  45628. */
  45629. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45630. }
  45631. }
  45632. declare module BABYLON {
  45633. /**
  45634. * The Physically based material of BJS.
  45635. *
  45636. * This offers the main features of a standard PBR material.
  45637. * For more information, please refer to the documentation :
  45638. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45639. */
  45640. export class PBRMaterial extends PBRBaseMaterial {
  45641. /**
  45642. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45643. */
  45644. static readonly PBRMATERIAL_OPAQUE: number;
  45645. /**
  45646. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45647. */
  45648. static readonly PBRMATERIAL_ALPHATEST: number;
  45649. /**
  45650. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45651. */
  45652. static readonly PBRMATERIAL_ALPHABLEND: number;
  45653. /**
  45654. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45655. * They are also discarded below the alpha cutoff threshold to improve performances.
  45656. */
  45657. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45658. /**
  45659. * Defines the default value of how much AO map is occluding the analytical lights
  45660. * (point spot...).
  45661. */
  45662. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45663. /**
  45664. * Intensity of the direct lights e.g. the four lights available in your scene.
  45665. * This impacts both the direct diffuse and specular highlights.
  45666. */
  45667. directIntensity: number;
  45668. /**
  45669. * Intensity of the emissive part of the material.
  45670. * This helps controlling the emissive effect without modifying the emissive color.
  45671. */
  45672. emissiveIntensity: number;
  45673. /**
  45674. * Intensity of the environment e.g. how much the environment will light the object
  45675. * either through harmonics for rough material or through the refelction for shiny ones.
  45676. */
  45677. environmentIntensity: number;
  45678. /**
  45679. * This is a special control allowing the reduction of the specular highlights coming from the
  45680. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45681. */
  45682. specularIntensity: number;
  45683. /**
  45684. * Debug Control allowing disabling the bump map on this material.
  45685. */
  45686. disableBumpMap: boolean;
  45687. /**
  45688. * AKA Diffuse Texture in standard nomenclature.
  45689. */
  45690. albedoTexture: BaseTexture;
  45691. /**
  45692. * AKA Occlusion Texture in other nomenclature.
  45693. */
  45694. ambientTexture: BaseTexture;
  45695. /**
  45696. * AKA Occlusion Texture Intensity in other nomenclature.
  45697. */
  45698. ambientTextureStrength: number;
  45699. /**
  45700. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45701. * 1 means it completely occludes it
  45702. * 0 mean it has no impact
  45703. */
  45704. ambientTextureImpactOnAnalyticalLights: number;
  45705. /**
  45706. * Stores the alpha values in a texture.
  45707. */
  45708. opacityTexture: BaseTexture;
  45709. /**
  45710. * Stores the reflection values in a texture.
  45711. */
  45712. reflectionTexture: Nullable<BaseTexture>;
  45713. /**
  45714. * Stores the emissive values in a texture.
  45715. */
  45716. emissiveTexture: BaseTexture;
  45717. /**
  45718. * AKA Specular texture in other nomenclature.
  45719. */
  45720. reflectivityTexture: BaseTexture;
  45721. /**
  45722. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45723. */
  45724. metallicTexture: BaseTexture;
  45725. /**
  45726. * Specifies the metallic scalar of the metallic/roughness workflow.
  45727. * Can also be used to scale the metalness values of the metallic texture.
  45728. */
  45729. metallic: Nullable<number>;
  45730. /**
  45731. * Specifies the roughness scalar of the metallic/roughness workflow.
  45732. * Can also be used to scale the roughness values of the metallic texture.
  45733. */
  45734. roughness: Nullable<number>;
  45735. /**
  45736. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45737. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45738. */
  45739. microSurfaceTexture: BaseTexture;
  45740. /**
  45741. * Stores surface normal data used to displace a mesh in a texture.
  45742. */
  45743. bumpTexture: BaseTexture;
  45744. /**
  45745. * Stores the pre-calculated light information of a mesh in a texture.
  45746. */
  45747. lightmapTexture: BaseTexture;
  45748. /**
  45749. * Stores the refracted light information in a texture.
  45750. */
  45751. refractionTexture: Nullable<BaseTexture>;
  45752. /**
  45753. * The color of a material in ambient lighting.
  45754. */
  45755. ambientColor: Color3;
  45756. /**
  45757. * AKA Diffuse Color in other nomenclature.
  45758. */
  45759. albedoColor: Color3;
  45760. /**
  45761. * AKA Specular Color in other nomenclature.
  45762. */
  45763. reflectivityColor: Color3;
  45764. /**
  45765. * The color reflected from the material.
  45766. */
  45767. reflectionColor: Color3;
  45768. /**
  45769. * The color emitted from the material.
  45770. */
  45771. emissiveColor: Color3;
  45772. /**
  45773. * AKA Glossiness in other nomenclature.
  45774. */
  45775. microSurface: number;
  45776. /**
  45777. * source material index of refraction (IOR)' / 'destination material IOR.
  45778. */
  45779. indexOfRefraction: number;
  45780. /**
  45781. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45782. */
  45783. invertRefractionY: boolean;
  45784. /**
  45785. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45786. * Materials half opaque for instance using refraction could benefit from this control.
  45787. */
  45788. linkRefractionWithTransparency: boolean;
  45789. /**
  45790. * If true, the light map contains occlusion information instead of lighting info.
  45791. */
  45792. useLightmapAsShadowmap: boolean;
  45793. /**
  45794. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45795. */
  45796. useAlphaFromAlbedoTexture: boolean;
  45797. /**
  45798. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45799. */
  45800. forceAlphaTest: boolean;
  45801. /**
  45802. * Defines the alpha limits in alpha test mode.
  45803. */
  45804. alphaCutOff: number;
  45805. /**
  45806. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45807. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45808. */
  45809. useSpecularOverAlpha: boolean;
  45810. /**
  45811. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45812. */
  45813. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45814. /**
  45815. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45816. */
  45817. useRoughnessFromMetallicTextureAlpha: boolean;
  45818. /**
  45819. * Specifies if the metallic texture contains the roughness information in its green channel.
  45820. */
  45821. useRoughnessFromMetallicTextureGreen: boolean;
  45822. /**
  45823. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45824. */
  45825. useMetallnessFromMetallicTextureBlue: boolean;
  45826. /**
  45827. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45828. */
  45829. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45830. /**
  45831. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45832. */
  45833. useAmbientInGrayScale: boolean;
  45834. /**
  45835. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45836. * The material will try to infer what glossiness each pixel should be.
  45837. */
  45838. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45839. /**
  45840. * BJS is using an harcoded light falloff based on a manually sets up range.
  45841. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45842. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45843. */
  45844. /**
  45845. * BJS is using an harcoded light falloff based on a manually sets up range.
  45846. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45847. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45848. */
  45849. usePhysicalLightFalloff: boolean;
  45850. /**
  45851. * In order to support the falloff compatibility with gltf, a special mode has been added
  45852. * to reproduce the gltf light falloff.
  45853. */
  45854. /**
  45855. * In order to support the falloff compatibility with gltf, a special mode has been added
  45856. * to reproduce the gltf light falloff.
  45857. */
  45858. useGLTFLightFalloff: boolean;
  45859. /**
  45860. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45861. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45862. */
  45863. useRadianceOverAlpha: boolean;
  45864. /**
  45865. * Allows using an object space normal map (instead of tangent space).
  45866. */
  45867. useObjectSpaceNormalMap: boolean;
  45868. /**
  45869. * Allows using the bump map in parallax mode.
  45870. */
  45871. useParallax: boolean;
  45872. /**
  45873. * Allows using the bump map in parallax occlusion mode.
  45874. */
  45875. useParallaxOcclusion: boolean;
  45876. /**
  45877. * Controls the scale bias of the parallax mode.
  45878. */
  45879. parallaxScaleBias: number;
  45880. /**
  45881. * If sets to true, disables all the lights affecting the material.
  45882. */
  45883. disableLighting: boolean;
  45884. /**
  45885. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45886. */
  45887. forceIrradianceInFragment: boolean;
  45888. /**
  45889. * Number of Simultaneous lights allowed on the material.
  45890. */
  45891. maxSimultaneousLights: number;
  45892. /**
  45893. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45894. */
  45895. invertNormalMapX: boolean;
  45896. /**
  45897. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45898. */
  45899. invertNormalMapY: boolean;
  45900. /**
  45901. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45902. */
  45903. twoSidedLighting: boolean;
  45904. /**
  45905. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45906. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45907. */
  45908. useAlphaFresnel: boolean;
  45909. /**
  45910. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45911. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45912. */
  45913. useLinearAlphaFresnel: boolean;
  45914. /**
  45915. * Let user defines the brdf lookup texture used for IBL.
  45916. * A default 8bit version is embedded but you could point at :
  45917. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45918. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45919. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45920. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45921. */
  45922. environmentBRDFTexture: Nullable<BaseTexture>;
  45923. /**
  45924. * Force normal to face away from face.
  45925. */
  45926. forceNormalForward: boolean;
  45927. /**
  45928. * Enables specular anti aliasing in the PBR shader.
  45929. * It will both interacts on the Geometry for analytical and IBL lighting.
  45930. * It also prefilter the roughness map based on the bump values.
  45931. */
  45932. enableSpecularAntiAliasing: boolean;
  45933. /**
  45934. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45935. * makes the reflect vector face the model (under horizon).
  45936. */
  45937. useHorizonOcclusion: boolean;
  45938. /**
  45939. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45940. * too much the area relying on ambient texture to define their ambient occlusion.
  45941. */
  45942. useRadianceOcclusion: boolean;
  45943. /**
  45944. * If set to true, no lighting calculations will be applied.
  45945. */
  45946. unlit: boolean;
  45947. /**
  45948. * Gets the image processing configuration used either in this material.
  45949. */
  45950. /**
  45951. * Sets the Default image processing configuration used either in the this material.
  45952. *
  45953. * If sets to null, the scene one is in use.
  45954. */
  45955. imageProcessingConfiguration: ImageProcessingConfiguration;
  45956. /**
  45957. * Gets wether the color curves effect is enabled.
  45958. */
  45959. /**
  45960. * Sets wether the color curves effect is enabled.
  45961. */
  45962. cameraColorCurvesEnabled: boolean;
  45963. /**
  45964. * Gets wether the color grading effect is enabled.
  45965. */
  45966. /**
  45967. * Gets wether the color grading effect is enabled.
  45968. */
  45969. cameraColorGradingEnabled: boolean;
  45970. /**
  45971. * Gets wether tonemapping is enabled or not.
  45972. */
  45973. /**
  45974. * Sets wether tonemapping is enabled or not
  45975. */
  45976. cameraToneMappingEnabled: boolean;
  45977. /**
  45978. * The camera exposure used on this material.
  45979. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45980. * This corresponds to a photographic exposure.
  45981. */
  45982. /**
  45983. * The camera exposure used on this material.
  45984. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45985. * This corresponds to a photographic exposure.
  45986. */
  45987. cameraExposure: number;
  45988. /**
  45989. * Gets The camera contrast used on this material.
  45990. */
  45991. /**
  45992. * Sets The camera contrast used on this material.
  45993. */
  45994. cameraContrast: number;
  45995. /**
  45996. * Gets the Color Grading 2D Lookup Texture.
  45997. */
  45998. /**
  45999. * Sets the Color Grading 2D Lookup Texture.
  46000. */
  46001. cameraColorGradingTexture: Nullable<BaseTexture>;
  46002. /**
  46003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46005. * 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;
  46006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46007. */
  46008. /**
  46009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46011. * 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;
  46012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46013. */
  46014. cameraColorCurves: Nullable<ColorCurves>;
  46015. /**
  46016. * Instantiates a new PBRMaterial instance.
  46017. *
  46018. * @param name The material name
  46019. * @param scene The scene the material will be use in.
  46020. */
  46021. constructor(name: string, scene: Scene);
  46022. /**
  46023. * Returns the name of this material class.
  46024. */
  46025. getClassName(): string;
  46026. /**
  46027. * Makes a duplicate of the current material.
  46028. * @param name - name to use for the new material.
  46029. */
  46030. clone(name: string): PBRMaterial;
  46031. /**
  46032. * Serializes this PBR Material.
  46033. * @returns - An object with the serialized material.
  46034. */
  46035. serialize(): any;
  46036. /**
  46037. * Parses a PBR Material from a serialized object.
  46038. * @param source - Serialized object.
  46039. * @param scene - BJS scene instance.
  46040. * @param rootUrl - url for the scene object
  46041. * @returns - PBRMaterial
  46042. */
  46043. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46044. }
  46045. }
  46046. declare module BABYLON {
  46047. /**
  46048. * Direct draw surface info
  46049. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46050. */
  46051. export interface DDSInfo {
  46052. /**
  46053. * Width of the texture
  46054. */
  46055. width: number;
  46056. /**
  46057. * Width of the texture
  46058. */
  46059. height: number;
  46060. /**
  46061. * Number of Mipmaps for the texture
  46062. * @see https://en.wikipedia.org/wiki/Mipmap
  46063. */
  46064. mipmapCount: number;
  46065. /**
  46066. * If the textures format is a known fourCC format
  46067. * @see https://www.fourcc.org/
  46068. */
  46069. isFourCC: boolean;
  46070. /**
  46071. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46072. */
  46073. isRGB: boolean;
  46074. /**
  46075. * If the texture is a lumincance format
  46076. */
  46077. isLuminance: boolean;
  46078. /**
  46079. * If this is a cube texture
  46080. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46081. */
  46082. isCube: boolean;
  46083. /**
  46084. * If the texture is a compressed format eg. FOURCC_DXT1
  46085. */
  46086. isCompressed: boolean;
  46087. /**
  46088. * The dxgiFormat of the texture
  46089. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46090. */
  46091. dxgiFormat: number;
  46092. /**
  46093. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46094. */
  46095. textureType: number;
  46096. /**
  46097. * Sphericle polynomial created for the dds texture
  46098. */
  46099. sphericalPolynomial?: SphericalPolynomial;
  46100. }
  46101. /**
  46102. * Class used to provide DDS decompression tools
  46103. */
  46104. export class DDSTools {
  46105. /**
  46106. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46107. */
  46108. static StoreLODInAlphaChannel: boolean;
  46109. /**
  46110. * Gets DDS information from an array buffer
  46111. * @param arrayBuffer defines the array buffer to read data from
  46112. * @returns the DDS information
  46113. */
  46114. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46115. private static _FloatView;
  46116. private static _Int32View;
  46117. private static _ToHalfFloat;
  46118. private static _FromHalfFloat;
  46119. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46120. private static _GetHalfFloatRGBAArrayBuffer;
  46121. private static _GetFloatRGBAArrayBuffer;
  46122. private static _GetFloatAsUIntRGBAArrayBuffer;
  46123. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46124. private static _GetRGBAArrayBuffer;
  46125. private static _ExtractLongWordOrder;
  46126. private static _GetRGBArrayBuffer;
  46127. private static _GetLuminanceArrayBuffer;
  46128. /**
  46129. * Uploads DDS Levels to a Babylon Texture
  46130. * @hidden
  46131. */
  46132. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46133. }
  46134. interface Engine {
  46135. /**
  46136. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46137. * @param rootUrl defines the url where the file to load is located
  46138. * @param scene defines the current scene
  46139. * @param lodScale defines scale to apply to the mip map selection
  46140. * @param lodOffset defines offset to apply to the mip map selection
  46141. * @param onLoad defines an optional callback raised when the texture is loaded
  46142. * @param onError defines an optional callback raised if there is an issue to load the texture
  46143. * @param format defines the format of the data
  46144. * @param forcedExtension defines the extension to use to pick the right loader
  46145. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46146. * @returns the cube texture as an InternalTexture
  46147. */
  46148. 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;
  46149. }
  46150. }
  46151. declare module BABYLON {
  46152. /**
  46153. * Implementation of the DDS Texture Loader.
  46154. * @hidden
  46155. */
  46156. export class _DDSTextureLoader implements IInternalTextureLoader {
  46157. /**
  46158. * Defines wether the loader supports cascade loading the different faces.
  46159. */
  46160. readonly supportCascades: boolean;
  46161. /**
  46162. * This returns if the loader support the current file information.
  46163. * @param extension defines the file extension of the file being loaded
  46164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46165. * @param fallback defines the fallback internal texture if any
  46166. * @param isBase64 defines whether the texture is encoded as a base64
  46167. * @param isBuffer defines whether the texture data are stored as a buffer
  46168. * @returns true if the loader can load the specified file
  46169. */
  46170. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46171. /**
  46172. * Transform the url before loading if required.
  46173. * @param rootUrl the url of the texture
  46174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46175. * @returns the transformed texture
  46176. */
  46177. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46178. /**
  46179. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46180. * @param rootUrl the url of the texture
  46181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46182. * @returns the fallback texture
  46183. */
  46184. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46185. /**
  46186. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46187. * @param data contains the texture data
  46188. * @param texture defines the BabylonJS internal texture
  46189. * @param createPolynomials will be true if polynomials have been requested
  46190. * @param onLoad defines the callback to trigger once the texture is ready
  46191. * @param onError defines the callback to trigger in case of error
  46192. */
  46193. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46194. /**
  46195. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46196. * @param data contains the texture data
  46197. * @param texture defines the BabylonJS internal texture
  46198. * @param callback defines the method to call once ready to upload
  46199. */
  46200. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46201. }
  46202. }
  46203. declare module BABYLON {
  46204. /** @hidden */
  46205. export var rgbdEncodePixelShader: {
  46206. name: string;
  46207. shader: string;
  46208. };
  46209. }
  46210. declare module BABYLON {
  46211. /**
  46212. * Raw texture data and descriptor sufficient for WebGL texture upload
  46213. */
  46214. export interface EnvironmentTextureInfo {
  46215. /**
  46216. * Version of the environment map
  46217. */
  46218. version: number;
  46219. /**
  46220. * Width of image
  46221. */
  46222. width: number;
  46223. /**
  46224. * Irradiance information stored in the file.
  46225. */
  46226. irradiance: any;
  46227. /**
  46228. * Specular information stored in the file.
  46229. */
  46230. specular: any;
  46231. }
  46232. /**
  46233. * Sets of helpers addressing the serialization and deserialization of environment texture
  46234. * stored in a BabylonJS env file.
  46235. * Those files are usually stored as .env files.
  46236. */
  46237. export class EnvironmentTextureTools {
  46238. /**
  46239. * Magic number identifying the env file.
  46240. */
  46241. private static _MagicBytes;
  46242. /**
  46243. * Gets the environment info from an env file.
  46244. * @param data The array buffer containing the .env bytes.
  46245. * @returns the environment file info (the json header) if successfully parsed.
  46246. */
  46247. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46248. /**
  46249. * Creates an environment texture from a loaded cube texture.
  46250. * @param texture defines the cube texture to convert in env file
  46251. * @return a promise containing the environment data if succesfull.
  46252. */
  46253. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46254. /**
  46255. * Creates a JSON representation of the spherical data.
  46256. * @param texture defines the texture containing the polynomials
  46257. * @return the JSON representation of the spherical info
  46258. */
  46259. private static _CreateEnvTextureIrradiance;
  46260. /**
  46261. * Uploads the texture info contained in the env file to the GPU.
  46262. * @param texture defines the internal texture to upload to
  46263. * @param arrayBuffer defines the buffer cotaining the data to load
  46264. * @param info defines the texture info retrieved through the GetEnvInfo method
  46265. * @returns a promise
  46266. */
  46267. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46268. /**
  46269. * Uploads the levels of image data to the GPU.
  46270. * @param texture defines the internal texture to upload to
  46271. * @param imageData defines the array buffer views of image data [mipmap][face]
  46272. * @returns a promise
  46273. */
  46274. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46275. /**
  46276. * Uploads spherical polynomials information to the texture.
  46277. * @param texture defines the texture we are trying to upload the information to
  46278. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46279. */
  46280. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46281. /** @hidden */
  46282. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46283. }
  46284. }
  46285. declare module BABYLON {
  46286. /**
  46287. * Implementation of the ENV Texture Loader.
  46288. * @hidden
  46289. */
  46290. export class _ENVTextureLoader implements IInternalTextureLoader {
  46291. /**
  46292. * Defines wether the loader supports cascade loading the different faces.
  46293. */
  46294. readonly supportCascades: boolean;
  46295. /**
  46296. * This returns if the loader support the current file information.
  46297. * @param extension defines the file extension of the file being loaded
  46298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46299. * @param fallback defines the fallback internal texture if any
  46300. * @param isBase64 defines whether the texture is encoded as a base64
  46301. * @param isBuffer defines whether the texture data are stored as a buffer
  46302. * @returns true if the loader can load the specified file
  46303. */
  46304. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46305. /**
  46306. * Transform the url before loading if required.
  46307. * @param rootUrl the url of the texture
  46308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46309. * @returns the transformed texture
  46310. */
  46311. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46312. /**
  46313. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46314. * @param rootUrl the url of the texture
  46315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46316. * @returns the fallback texture
  46317. */
  46318. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46319. /**
  46320. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46321. * @param data contains the texture data
  46322. * @param texture defines the BabylonJS internal texture
  46323. * @param createPolynomials will be true if polynomials have been requested
  46324. * @param onLoad defines the callback to trigger once the texture is ready
  46325. * @param onError defines the callback to trigger in case of error
  46326. */
  46327. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46328. /**
  46329. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46330. * @param data contains the texture data
  46331. * @param texture defines the BabylonJS internal texture
  46332. * @param callback defines the method to call once ready to upload
  46333. */
  46334. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46335. }
  46336. }
  46337. declare module BABYLON {
  46338. /**
  46339. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46340. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46341. */
  46342. export class KhronosTextureContainer {
  46343. /** contents of the KTX container file */
  46344. arrayBuffer: any;
  46345. private static HEADER_LEN;
  46346. private static COMPRESSED_2D;
  46347. private static COMPRESSED_3D;
  46348. private static TEX_2D;
  46349. private static TEX_3D;
  46350. /**
  46351. * Gets the openGL type
  46352. */
  46353. glType: number;
  46354. /**
  46355. * Gets the openGL type size
  46356. */
  46357. glTypeSize: number;
  46358. /**
  46359. * Gets the openGL format
  46360. */
  46361. glFormat: number;
  46362. /**
  46363. * Gets the openGL internal format
  46364. */
  46365. glInternalFormat: number;
  46366. /**
  46367. * Gets the base internal format
  46368. */
  46369. glBaseInternalFormat: number;
  46370. /**
  46371. * Gets image width in pixel
  46372. */
  46373. pixelWidth: number;
  46374. /**
  46375. * Gets image height in pixel
  46376. */
  46377. pixelHeight: number;
  46378. /**
  46379. * Gets image depth in pixels
  46380. */
  46381. pixelDepth: number;
  46382. /**
  46383. * Gets the number of array elements
  46384. */
  46385. numberOfArrayElements: number;
  46386. /**
  46387. * Gets the number of faces
  46388. */
  46389. numberOfFaces: number;
  46390. /**
  46391. * Gets the number of mipmap levels
  46392. */
  46393. numberOfMipmapLevels: number;
  46394. /**
  46395. * Gets the bytes of key value data
  46396. */
  46397. bytesOfKeyValueData: number;
  46398. /**
  46399. * Gets the load type
  46400. */
  46401. loadType: number;
  46402. /**
  46403. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46404. */
  46405. isInvalid: boolean;
  46406. /**
  46407. * Creates a new KhronosTextureContainer
  46408. * @param arrayBuffer contents of the KTX container file
  46409. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46410. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46411. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46412. */
  46413. constructor(
  46414. /** contents of the KTX container file */
  46415. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46416. /**
  46417. * Uploads KTX content to a Babylon Texture.
  46418. * It is assumed that the texture has already been created & is currently bound
  46419. * @hidden
  46420. */
  46421. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46422. private _upload2DCompressedLevels;
  46423. }
  46424. }
  46425. declare module BABYLON {
  46426. /**
  46427. * Implementation of the KTX Texture Loader.
  46428. * @hidden
  46429. */
  46430. export class _KTXTextureLoader implements IInternalTextureLoader {
  46431. /**
  46432. * Defines wether the loader supports cascade loading the different faces.
  46433. */
  46434. readonly supportCascades: boolean;
  46435. /**
  46436. * This returns if the loader support the current file information.
  46437. * @param extension defines the file extension of the file being loaded
  46438. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46439. * @param fallback defines the fallback internal texture if any
  46440. * @param isBase64 defines whether the texture is encoded as a base64
  46441. * @param isBuffer defines whether the texture data are stored as a buffer
  46442. * @returns true if the loader can load the specified file
  46443. */
  46444. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46445. /**
  46446. * Transform the url before loading if required.
  46447. * @param rootUrl the url of the texture
  46448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46449. * @returns the transformed texture
  46450. */
  46451. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46452. /**
  46453. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46454. * @param rootUrl the url of the texture
  46455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46456. * @returns the fallback texture
  46457. */
  46458. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46459. /**
  46460. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46461. * @param data contains the texture data
  46462. * @param texture defines the BabylonJS internal texture
  46463. * @param createPolynomials will be true if polynomials have been requested
  46464. * @param onLoad defines the callback to trigger once the texture is ready
  46465. * @param onError defines the callback to trigger in case of error
  46466. */
  46467. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46468. /**
  46469. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46470. * @param data contains the texture data
  46471. * @param texture defines the BabylonJS internal texture
  46472. * @param callback defines the method to call once ready to upload
  46473. */
  46474. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46475. }
  46476. }
  46477. declare module BABYLON {
  46478. /** @hidden */
  46479. export var _forceSceneHelpersToBundle: boolean;
  46480. interface Scene {
  46481. /**
  46482. * Creates a default light for the scene.
  46483. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46484. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46485. */
  46486. createDefaultLight(replace?: boolean): void;
  46487. /**
  46488. * Creates a default camera for the scene.
  46489. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46490. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46491. * @param replace has default false, when true replaces the active camera in the scene
  46492. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46493. */
  46494. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46495. /**
  46496. * Creates a default camera and a default light.
  46497. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46498. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46499. * @param replace has the default false, when true replaces the active camera/light in the scene
  46500. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46501. */
  46502. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46503. /**
  46504. * Creates a new sky box
  46505. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46506. * @param environmentTexture defines the texture to use as environment texture
  46507. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46508. * @param scale defines the overall scale of the skybox
  46509. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46510. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46511. * @returns a new mesh holding the sky box
  46512. */
  46513. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46514. /**
  46515. * Creates a new environment
  46516. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46517. * @param options defines the options you can use to configure the environment
  46518. * @returns the new EnvironmentHelper
  46519. */
  46520. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46521. /**
  46522. * Creates a new VREXperienceHelper
  46523. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46524. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46525. * @returns a new VREXperienceHelper
  46526. */
  46527. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46528. /**
  46529. * Creates a new XREXperienceHelper
  46530. * @see http://doc.babylonjs.com/how_to/webxr
  46531. * @returns a promise for a new XREXperienceHelper
  46532. */
  46533. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46534. }
  46535. }
  46536. declare module BABYLON {
  46537. /**
  46538. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46539. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46540. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46541. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46542. */
  46543. export class VideoDome extends TransformNode {
  46544. /**
  46545. * Define the video source as a Monoscopic panoramic 360 video.
  46546. */
  46547. static readonly MODE_MONOSCOPIC: number;
  46548. /**
  46549. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46550. */
  46551. static readonly MODE_TOPBOTTOM: number;
  46552. /**
  46553. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46554. */
  46555. static readonly MODE_SIDEBYSIDE: number;
  46556. private _useDirectMapping;
  46557. /**
  46558. * The video texture being displayed on the sphere
  46559. */
  46560. protected _videoTexture: VideoTexture;
  46561. /**
  46562. * Gets the video texture being displayed on the sphere
  46563. */
  46564. readonly videoTexture: VideoTexture;
  46565. /**
  46566. * The skybox material
  46567. */
  46568. protected _material: BackgroundMaterial;
  46569. /**
  46570. * The surface used for the skybox
  46571. */
  46572. protected _mesh: Mesh;
  46573. /**
  46574. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46575. * Also see the options.resolution property.
  46576. */
  46577. fovMultiplier: number;
  46578. private _videoMode;
  46579. /**
  46580. * Gets or set the current video mode for the video. It can be:
  46581. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46582. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46583. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46584. */
  46585. videoMode: number;
  46586. /**
  46587. * Oberserver used in Stereoscopic VR Mode.
  46588. */
  46589. private _onBeforeCameraRenderObserver;
  46590. /**
  46591. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46592. * @param name Element's name, child elements will append suffixes for their own names.
  46593. * @param urlsOrVideo defines the url(s) or the video element to use
  46594. * @param options An object containing optional or exposed sub element properties
  46595. */
  46596. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46597. resolution?: number;
  46598. clickToPlay?: boolean;
  46599. autoPlay?: boolean;
  46600. loop?: boolean;
  46601. size?: number;
  46602. poster?: string;
  46603. faceForward?: boolean;
  46604. useDirectMapping?: boolean;
  46605. }, scene: Scene);
  46606. private _changeVideoMode;
  46607. /**
  46608. * Releases resources associated with this node.
  46609. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46610. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46611. */
  46612. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46613. }
  46614. }
  46615. declare module BABYLON {
  46616. /**
  46617. * This class can be used to get instrumentation data from a Babylon engine
  46618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46619. */
  46620. export class EngineInstrumentation implements IDisposable {
  46621. /**
  46622. * Define the instrumented engine.
  46623. */
  46624. engine: Engine;
  46625. private _captureGPUFrameTime;
  46626. private _gpuFrameTimeToken;
  46627. private _gpuFrameTime;
  46628. private _captureShaderCompilationTime;
  46629. private _shaderCompilationTime;
  46630. private _onBeginFrameObserver;
  46631. private _onEndFrameObserver;
  46632. private _onBeforeShaderCompilationObserver;
  46633. private _onAfterShaderCompilationObserver;
  46634. /**
  46635. * Gets the perf counter used for GPU frame time
  46636. */
  46637. readonly gpuFrameTimeCounter: PerfCounter;
  46638. /**
  46639. * Gets the GPU frame time capture status
  46640. */
  46641. /**
  46642. * Enable or disable the GPU frame time capture
  46643. */
  46644. captureGPUFrameTime: boolean;
  46645. /**
  46646. * Gets the perf counter used for shader compilation time
  46647. */
  46648. readonly shaderCompilationTimeCounter: PerfCounter;
  46649. /**
  46650. * Gets the shader compilation time capture status
  46651. */
  46652. /**
  46653. * Enable or disable the shader compilation time capture
  46654. */
  46655. captureShaderCompilationTime: boolean;
  46656. /**
  46657. * Instantiates a new engine instrumentation.
  46658. * This class can be used to get instrumentation data from a Babylon engine
  46659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46660. * @param engine Defines the engine to instrument
  46661. */
  46662. constructor(
  46663. /**
  46664. * Define the instrumented engine.
  46665. */
  46666. engine: Engine);
  46667. /**
  46668. * Dispose and release associated resources.
  46669. */
  46670. dispose(): void;
  46671. }
  46672. }
  46673. declare module BABYLON {
  46674. /**
  46675. * This class can be used to get instrumentation data from a Babylon engine
  46676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46677. */
  46678. export class SceneInstrumentation implements IDisposable {
  46679. /**
  46680. * Defines the scene to instrument
  46681. */
  46682. scene: Scene;
  46683. private _captureActiveMeshesEvaluationTime;
  46684. private _activeMeshesEvaluationTime;
  46685. private _captureRenderTargetsRenderTime;
  46686. private _renderTargetsRenderTime;
  46687. private _captureFrameTime;
  46688. private _frameTime;
  46689. private _captureRenderTime;
  46690. private _renderTime;
  46691. private _captureInterFrameTime;
  46692. private _interFrameTime;
  46693. private _captureParticlesRenderTime;
  46694. private _particlesRenderTime;
  46695. private _captureSpritesRenderTime;
  46696. private _spritesRenderTime;
  46697. private _capturePhysicsTime;
  46698. private _physicsTime;
  46699. private _captureAnimationsTime;
  46700. private _animationsTime;
  46701. private _captureCameraRenderTime;
  46702. private _cameraRenderTime;
  46703. private _onBeforeActiveMeshesEvaluationObserver;
  46704. private _onAfterActiveMeshesEvaluationObserver;
  46705. private _onBeforeRenderTargetsRenderObserver;
  46706. private _onAfterRenderTargetsRenderObserver;
  46707. private _onAfterRenderObserver;
  46708. private _onBeforeDrawPhaseObserver;
  46709. private _onAfterDrawPhaseObserver;
  46710. private _onBeforeAnimationsObserver;
  46711. private _onBeforeParticlesRenderingObserver;
  46712. private _onAfterParticlesRenderingObserver;
  46713. private _onBeforeSpritesRenderingObserver;
  46714. private _onAfterSpritesRenderingObserver;
  46715. private _onBeforePhysicsObserver;
  46716. private _onAfterPhysicsObserver;
  46717. private _onAfterAnimationsObserver;
  46718. private _onBeforeCameraRenderObserver;
  46719. private _onAfterCameraRenderObserver;
  46720. /**
  46721. * Gets the perf counter used for active meshes evaluation time
  46722. */
  46723. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46724. /**
  46725. * Gets the active meshes evaluation time capture status
  46726. */
  46727. /**
  46728. * Enable or disable the active meshes evaluation time capture
  46729. */
  46730. captureActiveMeshesEvaluationTime: boolean;
  46731. /**
  46732. * Gets the perf counter used for render targets render time
  46733. */
  46734. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46735. /**
  46736. * Gets the render targets render time capture status
  46737. */
  46738. /**
  46739. * Enable or disable the render targets render time capture
  46740. */
  46741. captureRenderTargetsRenderTime: boolean;
  46742. /**
  46743. * Gets the perf counter used for particles render time
  46744. */
  46745. readonly particlesRenderTimeCounter: PerfCounter;
  46746. /**
  46747. * Gets the particles render time capture status
  46748. */
  46749. /**
  46750. * Enable or disable the particles render time capture
  46751. */
  46752. captureParticlesRenderTime: boolean;
  46753. /**
  46754. * Gets the perf counter used for sprites render time
  46755. */
  46756. readonly spritesRenderTimeCounter: PerfCounter;
  46757. /**
  46758. * Gets the sprites render time capture status
  46759. */
  46760. /**
  46761. * Enable or disable the sprites render time capture
  46762. */
  46763. captureSpritesRenderTime: boolean;
  46764. /**
  46765. * Gets the perf counter used for physics time
  46766. */
  46767. readonly physicsTimeCounter: PerfCounter;
  46768. /**
  46769. * Gets the physics time capture status
  46770. */
  46771. /**
  46772. * Enable or disable the physics time capture
  46773. */
  46774. capturePhysicsTime: boolean;
  46775. /**
  46776. * Gets the perf counter used for animations time
  46777. */
  46778. readonly animationsTimeCounter: PerfCounter;
  46779. /**
  46780. * Gets the animations time capture status
  46781. */
  46782. /**
  46783. * Enable or disable the animations time capture
  46784. */
  46785. captureAnimationsTime: boolean;
  46786. /**
  46787. * Gets the perf counter used for frame time capture
  46788. */
  46789. readonly frameTimeCounter: PerfCounter;
  46790. /**
  46791. * Gets the frame time capture status
  46792. */
  46793. /**
  46794. * Enable or disable the frame time capture
  46795. */
  46796. captureFrameTime: boolean;
  46797. /**
  46798. * Gets the perf counter used for inter-frames time capture
  46799. */
  46800. readonly interFrameTimeCounter: PerfCounter;
  46801. /**
  46802. * Gets the inter-frames time capture status
  46803. */
  46804. /**
  46805. * Enable or disable the inter-frames time capture
  46806. */
  46807. captureInterFrameTime: boolean;
  46808. /**
  46809. * Gets the perf counter used for render time capture
  46810. */
  46811. readonly renderTimeCounter: PerfCounter;
  46812. /**
  46813. * Gets the render time capture status
  46814. */
  46815. /**
  46816. * Enable or disable the render time capture
  46817. */
  46818. captureRenderTime: boolean;
  46819. /**
  46820. * Gets the perf counter used for camera render time capture
  46821. */
  46822. readonly cameraRenderTimeCounter: PerfCounter;
  46823. /**
  46824. * Gets the camera render time capture status
  46825. */
  46826. /**
  46827. * Enable or disable the camera render time capture
  46828. */
  46829. captureCameraRenderTime: boolean;
  46830. /**
  46831. * Gets the perf counter used for draw calls
  46832. */
  46833. readonly drawCallsCounter: PerfCounter;
  46834. /**
  46835. * Instantiates a new scene instrumentation.
  46836. * This class can be used to get instrumentation data from a Babylon engine
  46837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46838. * @param scene Defines the scene to instrument
  46839. */
  46840. constructor(
  46841. /**
  46842. * Defines the scene to instrument
  46843. */
  46844. scene: Scene);
  46845. /**
  46846. * Dispose and release associated resources.
  46847. */
  46848. dispose(): void;
  46849. }
  46850. }
  46851. declare module BABYLON {
  46852. /** @hidden */
  46853. export var glowMapGenerationPixelShader: {
  46854. name: string;
  46855. shader: string;
  46856. };
  46857. }
  46858. declare module BABYLON {
  46859. /** @hidden */
  46860. export var glowMapGenerationVertexShader: {
  46861. name: string;
  46862. shader: string;
  46863. };
  46864. }
  46865. declare module BABYLON {
  46866. /**
  46867. * Effect layer options. This helps customizing the behaviour
  46868. * of the effect layer.
  46869. */
  46870. export interface IEffectLayerOptions {
  46871. /**
  46872. * Multiplication factor apply to the canvas size to compute the render target size
  46873. * used to generated the objects (the smaller the faster).
  46874. */
  46875. mainTextureRatio: number;
  46876. /**
  46877. * Enforces a fixed size texture to ensure effect stability across devices.
  46878. */
  46879. mainTextureFixedSize?: number;
  46880. /**
  46881. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46882. */
  46883. alphaBlendingMode: number;
  46884. /**
  46885. * The camera attached to the layer.
  46886. */
  46887. camera: Nullable<Camera>;
  46888. /**
  46889. * The rendering group to draw the layer in.
  46890. */
  46891. renderingGroupId: number;
  46892. }
  46893. /**
  46894. * The effect layer Helps adding post process effect blended with the main pass.
  46895. *
  46896. * This can be for instance use to generate glow or higlight effects on the scene.
  46897. *
  46898. * The effect layer class can not be used directly and is intented to inherited from to be
  46899. * customized per effects.
  46900. */
  46901. export abstract class EffectLayer {
  46902. private _vertexBuffers;
  46903. private _indexBuffer;
  46904. private _cachedDefines;
  46905. private _effectLayerMapGenerationEffect;
  46906. private _effectLayerOptions;
  46907. private _mergeEffect;
  46908. protected _scene: Scene;
  46909. protected _engine: Engine;
  46910. protected _maxSize: number;
  46911. protected _mainTextureDesiredSize: ISize;
  46912. protected _mainTexture: RenderTargetTexture;
  46913. protected _shouldRender: boolean;
  46914. protected _postProcesses: PostProcess[];
  46915. protected _textures: BaseTexture[];
  46916. protected _emissiveTextureAndColor: {
  46917. texture: Nullable<BaseTexture>;
  46918. color: Color4;
  46919. };
  46920. /**
  46921. * The name of the layer
  46922. */
  46923. name: string;
  46924. /**
  46925. * The clear color of the texture used to generate the glow map.
  46926. */
  46927. neutralColor: Color4;
  46928. /**
  46929. * Specifies wether the highlight layer is enabled or not.
  46930. */
  46931. isEnabled: boolean;
  46932. /**
  46933. * Gets the camera attached to the layer.
  46934. */
  46935. readonly camera: Nullable<Camera>;
  46936. /**
  46937. * Gets the rendering group id the layer should render in.
  46938. */
  46939. readonly renderingGroupId: number;
  46940. /**
  46941. * An event triggered when the effect layer has been disposed.
  46942. */
  46943. onDisposeObservable: Observable<EffectLayer>;
  46944. /**
  46945. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46946. */
  46947. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46948. /**
  46949. * An event triggered when the generated texture is being merged in the scene.
  46950. */
  46951. onBeforeComposeObservable: Observable<EffectLayer>;
  46952. /**
  46953. * An event triggered when the generated texture has been merged in the scene.
  46954. */
  46955. onAfterComposeObservable: Observable<EffectLayer>;
  46956. /**
  46957. * An event triggered when the efffect layer changes its size.
  46958. */
  46959. onSizeChangedObservable: Observable<EffectLayer>;
  46960. /** @hidden */
  46961. static _SceneComponentInitialization: (scene: Scene) => void;
  46962. /**
  46963. * Instantiates a new effect Layer and references it in the scene.
  46964. * @param name The name of the layer
  46965. * @param scene The scene to use the layer in
  46966. */
  46967. constructor(
  46968. /** The Friendly of the effect in the scene */
  46969. name: string, scene: Scene);
  46970. /**
  46971. * Get the effect name of the layer.
  46972. * @return The effect name
  46973. */
  46974. abstract getEffectName(): string;
  46975. /**
  46976. * Checks for the readiness of the element composing the layer.
  46977. * @param subMesh the mesh to check for
  46978. * @param useInstances specify wether or not to use instances to render the mesh
  46979. * @return true if ready otherwise, false
  46980. */
  46981. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46982. /**
  46983. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46984. * @returns true if the effect requires stencil during the main canvas render pass.
  46985. */
  46986. abstract needStencil(): boolean;
  46987. /**
  46988. * Create the merge effect. This is the shader use to blit the information back
  46989. * to the main canvas at the end of the scene rendering.
  46990. * @returns The effect containing the shader used to merge the effect on the main canvas
  46991. */
  46992. protected abstract _createMergeEffect(): Effect;
  46993. /**
  46994. * Creates the render target textures and post processes used in the effect layer.
  46995. */
  46996. protected abstract _createTextureAndPostProcesses(): void;
  46997. /**
  46998. * Implementation specific of rendering the generating effect on the main canvas.
  46999. * @param effect The effect used to render through
  47000. */
  47001. protected abstract _internalRender(effect: Effect): void;
  47002. /**
  47003. * Sets the required values for both the emissive texture and and the main color.
  47004. */
  47005. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47006. /**
  47007. * Free any resources and references associated to a mesh.
  47008. * Internal use
  47009. * @param mesh The mesh to free.
  47010. */
  47011. abstract _disposeMesh(mesh: Mesh): void;
  47012. /**
  47013. * Serializes this layer (Glow or Highlight for example)
  47014. * @returns a serialized layer object
  47015. */
  47016. abstract serialize?(): any;
  47017. /**
  47018. * Initializes the effect layer with the required options.
  47019. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47020. */
  47021. protected _init(options: Partial<IEffectLayerOptions>): void;
  47022. /**
  47023. * Generates the index buffer of the full screen quad blending to the main canvas.
  47024. */
  47025. private _generateIndexBuffer;
  47026. /**
  47027. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47028. */
  47029. private _generateVertexBuffer;
  47030. /**
  47031. * Sets the main texture desired size which is the closest power of two
  47032. * of the engine canvas size.
  47033. */
  47034. private _setMainTextureSize;
  47035. /**
  47036. * Creates the main texture for the effect layer.
  47037. */
  47038. protected _createMainTexture(): void;
  47039. /**
  47040. * Adds specific effects defines.
  47041. * @param defines The defines to add specifics to.
  47042. */
  47043. protected _addCustomEffectDefines(defines: string[]): void;
  47044. /**
  47045. * Checks for the readiness of the element composing the layer.
  47046. * @param subMesh the mesh to check for
  47047. * @param useInstances specify wether or not to use instances to render the mesh
  47048. * @param emissiveTexture the associated emissive texture used to generate the glow
  47049. * @return true if ready otherwise, false
  47050. */
  47051. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47052. /**
  47053. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47054. */
  47055. render(): void;
  47056. /**
  47057. * Determine if a given mesh will be used in the current effect.
  47058. * @param mesh mesh to test
  47059. * @returns true if the mesh will be used
  47060. */
  47061. hasMesh(mesh: AbstractMesh): boolean;
  47062. /**
  47063. * Returns true if the layer contains information to display, otherwise false.
  47064. * @returns true if the glow layer should be rendered
  47065. */
  47066. shouldRender(): boolean;
  47067. /**
  47068. * Returns true if the mesh should render, otherwise false.
  47069. * @param mesh The mesh to render
  47070. * @returns true if it should render otherwise false
  47071. */
  47072. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47073. /**
  47074. * Returns true if the mesh can be rendered, otherwise false.
  47075. * @param mesh The mesh to render
  47076. * @param material The material used on the mesh
  47077. * @returns true if it can be rendered otherwise false
  47078. */
  47079. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47080. /**
  47081. * Returns true if the mesh should render, otherwise false.
  47082. * @param mesh The mesh to render
  47083. * @returns true if it should render otherwise false
  47084. */
  47085. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47086. /**
  47087. * Renders the submesh passed in parameter to the generation map.
  47088. */
  47089. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47090. /**
  47091. * Rebuild the required buffers.
  47092. * @hidden Internal use only.
  47093. */
  47094. _rebuild(): void;
  47095. /**
  47096. * Dispose only the render target textures and post process.
  47097. */
  47098. private _disposeTextureAndPostProcesses;
  47099. /**
  47100. * Dispose the highlight layer and free resources.
  47101. */
  47102. dispose(): void;
  47103. /**
  47104. * Gets the class name of the effect layer
  47105. * @returns the string with the class name of the effect layer
  47106. */
  47107. getClassName(): string;
  47108. /**
  47109. * Creates an effect layer from parsed effect layer data
  47110. * @param parsedEffectLayer defines effect layer data
  47111. * @param scene defines the current scene
  47112. * @param rootUrl defines the root URL containing the effect layer information
  47113. * @returns a parsed effect Layer
  47114. */
  47115. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47116. }
  47117. }
  47118. declare module BABYLON {
  47119. interface AbstractScene {
  47120. /**
  47121. * The list of effect layers (highlights/glow) added to the scene
  47122. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47123. * @see http://doc.babylonjs.com/how_to/glow_layer
  47124. */
  47125. effectLayers: Array<EffectLayer>;
  47126. /**
  47127. * Removes the given effect layer from this scene.
  47128. * @param toRemove defines the effect layer to remove
  47129. * @returns the index of the removed effect layer
  47130. */
  47131. removeEffectLayer(toRemove: EffectLayer): number;
  47132. /**
  47133. * Adds the given effect layer to this scene
  47134. * @param newEffectLayer defines the effect layer to add
  47135. */
  47136. addEffectLayer(newEffectLayer: EffectLayer): void;
  47137. }
  47138. /**
  47139. * Defines the layer scene component responsible to manage any effect layers
  47140. * in a given scene.
  47141. */
  47142. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47143. /**
  47144. * The component name helpfull to identify the component in the list of scene components.
  47145. */
  47146. readonly name: string;
  47147. /**
  47148. * The scene the component belongs to.
  47149. */
  47150. scene: Scene;
  47151. private _engine;
  47152. private _renderEffects;
  47153. private _needStencil;
  47154. private _previousStencilState;
  47155. /**
  47156. * Creates a new instance of the component for the given scene
  47157. * @param scene Defines the scene to register the component in
  47158. */
  47159. constructor(scene: Scene);
  47160. /**
  47161. * Registers the component in a given scene
  47162. */
  47163. register(): void;
  47164. /**
  47165. * Rebuilds the elements related to this component in case of
  47166. * context lost for instance.
  47167. */
  47168. rebuild(): void;
  47169. /**
  47170. * Serializes the component data to the specified json object
  47171. * @param serializationObject The object to serialize to
  47172. */
  47173. serialize(serializationObject: any): void;
  47174. /**
  47175. * Adds all the element from the container to the scene
  47176. * @param container the container holding the elements
  47177. */
  47178. addFromContainer(container: AbstractScene): void;
  47179. /**
  47180. * Removes all the elements in the container from the scene
  47181. * @param container contains the elements to remove
  47182. * @param dispose if the removed element should be disposed (default: false)
  47183. */
  47184. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47185. /**
  47186. * Disposes the component and the associated ressources.
  47187. */
  47188. dispose(): void;
  47189. private _isReadyForMesh;
  47190. private _renderMainTexture;
  47191. private _setStencil;
  47192. private _setStencilBack;
  47193. private _draw;
  47194. private _drawCamera;
  47195. private _drawRenderingGroup;
  47196. }
  47197. }
  47198. declare module BABYLON {
  47199. /** @hidden */
  47200. export var glowMapMergePixelShader: {
  47201. name: string;
  47202. shader: string;
  47203. };
  47204. }
  47205. declare module BABYLON {
  47206. /** @hidden */
  47207. export var glowMapMergeVertexShader: {
  47208. name: string;
  47209. shader: string;
  47210. };
  47211. }
  47212. declare module BABYLON {
  47213. interface AbstractScene {
  47214. /**
  47215. * Return a the first highlight layer of the scene with a given name.
  47216. * @param name The name of the highlight layer to look for.
  47217. * @return The highlight layer if found otherwise null.
  47218. */
  47219. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47220. }
  47221. /**
  47222. * Glow layer options. This helps customizing the behaviour
  47223. * of the glow layer.
  47224. */
  47225. export interface IGlowLayerOptions {
  47226. /**
  47227. * Multiplication factor apply to the canvas size to compute the render target size
  47228. * used to generated the glowing objects (the smaller the faster).
  47229. */
  47230. mainTextureRatio: number;
  47231. /**
  47232. * Enforces a fixed size texture to ensure resize independant blur.
  47233. */
  47234. mainTextureFixedSize?: number;
  47235. /**
  47236. * How big is the kernel of the blur texture.
  47237. */
  47238. blurKernelSize: number;
  47239. /**
  47240. * The camera attached to the layer.
  47241. */
  47242. camera: Nullable<Camera>;
  47243. /**
  47244. * Enable MSAA by chosing the number of samples.
  47245. */
  47246. mainTextureSamples?: number;
  47247. /**
  47248. * The rendering group to draw the layer in.
  47249. */
  47250. renderingGroupId: number;
  47251. }
  47252. /**
  47253. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47254. *
  47255. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47256. * glowy meshes to your scene.
  47257. *
  47258. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47259. */
  47260. export class GlowLayer extends EffectLayer {
  47261. /**
  47262. * Effect Name of the layer.
  47263. */
  47264. static readonly EffectName: string;
  47265. /**
  47266. * The default blur kernel size used for the glow.
  47267. */
  47268. static DefaultBlurKernelSize: number;
  47269. /**
  47270. * The default texture size ratio used for the glow.
  47271. */
  47272. static DefaultTextureRatio: number;
  47273. /**
  47274. * Sets the kernel size of the blur.
  47275. */
  47276. /**
  47277. * Gets the kernel size of the blur.
  47278. */
  47279. blurKernelSize: number;
  47280. /**
  47281. * Sets the glow intensity.
  47282. */
  47283. /**
  47284. * Gets the glow intensity.
  47285. */
  47286. intensity: number;
  47287. private _options;
  47288. private _intensity;
  47289. private _horizontalBlurPostprocess1;
  47290. private _verticalBlurPostprocess1;
  47291. private _horizontalBlurPostprocess2;
  47292. private _verticalBlurPostprocess2;
  47293. private _blurTexture1;
  47294. private _blurTexture2;
  47295. private _postProcesses1;
  47296. private _postProcesses2;
  47297. private _includedOnlyMeshes;
  47298. private _excludedMeshes;
  47299. /**
  47300. * Callback used to let the user override the color selection on a per mesh basis
  47301. */
  47302. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47303. /**
  47304. * Callback used to let the user override the texture selection on a per mesh basis
  47305. */
  47306. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47307. /**
  47308. * Instantiates a new glow Layer and references it to the scene.
  47309. * @param name The name of the layer
  47310. * @param scene The scene to use the layer in
  47311. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47312. */
  47313. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47314. /**
  47315. * Get the effect name of the layer.
  47316. * @return The effect name
  47317. */
  47318. getEffectName(): string;
  47319. /**
  47320. * Create the merge effect. This is the shader use to blit the information back
  47321. * to the main canvas at the end of the scene rendering.
  47322. */
  47323. protected _createMergeEffect(): Effect;
  47324. /**
  47325. * Creates the render target textures and post processes used in the glow layer.
  47326. */
  47327. protected _createTextureAndPostProcesses(): void;
  47328. /**
  47329. * Checks for the readiness of the element composing the layer.
  47330. * @param subMesh the mesh to check for
  47331. * @param useInstances specify wether or not to use instances to render the mesh
  47332. * @param emissiveTexture the associated emissive texture used to generate the glow
  47333. * @return true if ready otherwise, false
  47334. */
  47335. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47336. /**
  47337. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47338. */
  47339. needStencil(): boolean;
  47340. /**
  47341. * Returns true if the mesh can be rendered, otherwise false.
  47342. * @param mesh The mesh to render
  47343. * @param material The material used on the mesh
  47344. * @returns true if it can be rendered otherwise false
  47345. */
  47346. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47347. /**
  47348. * Implementation specific of rendering the generating effect on the main canvas.
  47349. * @param effect The effect used to render through
  47350. */
  47351. protected _internalRender(effect: Effect): void;
  47352. /**
  47353. * Sets the required values for both the emissive texture and and the main color.
  47354. */
  47355. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47356. /**
  47357. * Returns true if the mesh should render, otherwise false.
  47358. * @param mesh The mesh to render
  47359. * @returns true if it should render otherwise false
  47360. */
  47361. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47362. /**
  47363. * Adds specific effects defines.
  47364. * @param defines The defines to add specifics to.
  47365. */
  47366. protected _addCustomEffectDefines(defines: string[]): void;
  47367. /**
  47368. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47369. * @param mesh The mesh to exclude from the glow layer
  47370. */
  47371. addExcludedMesh(mesh: Mesh): void;
  47372. /**
  47373. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47374. * @param mesh The mesh to remove
  47375. */
  47376. removeExcludedMesh(mesh: Mesh): void;
  47377. /**
  47378. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47379. * @param mesh The mesh to include in the glow layer
  47380. */
  47381. addIncludedOnlyMesh(mesh: Mesh): void;
  47382. /**
  47383. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47384. * @param mesh The mesh to remove
  47385. */
  47386. removeIncludedOnlyMesh(mesh: Mesh): void;
  47387. /**
  47388. * Determine if a given mesh will be used in the glow layer
  47389. * @param mesh The mesh to test
  47390. * @returns true if the mesh will be highlighted by the current glow layer
  47391. */
  47392. hasMesh(mesh: AbstractMesh): boolean;
  47393. /**
  47394. * Free any resources and references associated to a mesh.
  47395. * Internal use
  47396. * @param mesh The mesh to free.
  47397. * @hidden
  47398. */
  47399. _disposeMesh(mesh: Mesh): void;
  47400. /**
  47401. * Gets the class name of the effect layer
  47402. * @returns the string with the class name of the effect layer
  47403. */
  47404. getClassName(): string;
  47405. /**
  47406. * Serializes this glow layer
  47407. * @returns a serialized glow layer object
  47408. */
  47409. serialize(): any;
  47410. /**
  47411. * Creates a Glow Layer from parsed glow layer data
  47412. * @param parsedGlowLayer defines glow layer data
  47413. * @param scene defines the current scene
  47414. * @param rootUrl defines the root URL containing the glow layer information
  47415. * @returns a parsed Glow Layer
  47416. */
  47417. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47418. }
  47419. }
  47420. declare module BABYLON {
  47421. /** @hidden */
  47422. export var glowBlurPostProcessPixelShader: {
  47423. name: string;
  47424. shader: string;
  47425. };
  47426. }
  47427. declare module BABYLON {
  47428. interface AbstractScene {
  47429. /**
  47430. * Return a the first highlight layer of the scene with a given name.
  47431. * @param name The name of the highlight layer to look for.
  47432. * @return The highlight layer if found otherwise null.
  47433. */
  47434. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47435. }
  47436. /**
  47437. * Highlight layer options. This helps customizing the behaviour
  47438. * of the highlight layer.
  47439. */
  47440. export interface IHighlightLayerOptions {
  47441. /**
  47442. * Multiplication factor apply to the canvas size to compute the render target size
  47443. * used to generated the glowing objects (the smaller the faster).
  47444. */
  47445. mainTextureRatio: number;
  47446. /**
  47447. * Enforces a fixed size texture to ensure resize independant blur.
  47448. */
  47449. mainTextureFixedSize?: number;
  47450. /**
  47451. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47452. * of the picture to blur (the smaller the faster).
  47453. */
  47454. blurTextureSizeRatio: number;
  47455. /**
  47456. * How big in texel of the blur texture is the vertical blur.
  47457. */
  47458. blurVerticalSize: number;
  47459. /**
  47460. * How big in texel of the blur texture is the horizontal blur.
  47461. */
  47462. blurHorizontalSize: number;
  47463. /**
  47464. * Alpha blending mode used to apply the blur. Default is combine.
  47465. */
  47466. alphaBlendingMode: number;
  47467. /**
  47468. * The camera attached to the layer.
  47469. */
  47470. camera: Nullable<Camera>;
  47471. /**
  47472. * Should we display highlight as a solid stroke?
  47473. */
  47474. isStroke?: boolean;
  47475. /**
  47476. * The rendering group to draw the layer in.
  47477. */
  47478. renderingGroupId: number;
  47479. }
  47480. /**
  47481. * The highlight layer Helps adding a glow effect around a mesh.
  47482. *
  47483. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47484. * glowy meshes to your scene.
  47485. *
  47486. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47487. */
  47488. export class HighlightLayer extends EffectLayer {
  47489. name: string;
  47490. /**
  47491. * Effect Name of the highlight layer.
  47492. */
  47493. static readonly EffectName: string;
  47494. /**
  47495. * The neutral color used during the preparation of the glow effect.
  47496. * This is black by default as the blend operation is a blend operation.
  47497. */
  47498. static NeutralColor: Color4;
  47499. /**
  47500. * Stencil value used for glowing meshes.
  47501. */
  47502. static GlowingMeshStencilReference: number;
  47503. /**
  47504. * Stencil value used for the other meshes in the scene.
  47505. */
  47506. static NormalMeshStencilReference: number;
  47507. /**
  47508. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47509. */
  47510. innerGlow: boolean;
  47511. /**
  47512. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47513. */
  47514. outerGlow: boolean;
  47515. /**
  47516. * Specifies the horizontal size of the blur.
  47517. */
  47518. /**
  47519. * Gets the horizontal size of the blur.
  47520. */
  47521. blurHorizontalSize: number;
  47522. /**
  47523. * Specifies the vertical size of the blur.
  47524. */
  47525. /**
  47526. * Gets the vertical size of the blur.
  47527. */
  47528. blurVerticalSize: number;
  47529. /**
  47530. * An event triggered when the highlight layer is being blurred.
  47531. */
  47532. onBeforeBlurObservable: Observable<HighlightLayer>;
  47533. /**
  47534. * An event triggered when the highlight layer has been blurred.
  47535. */
  47536. onAfterBlurObservable: Observable<HighlightLayer>;
  47537. private _instanceGlowingMeshStencilReference;
  47538. private _options;
  47539. private _downSamplePostprocess;
  47540. private _horizontalBlurPostprocess;
  47541. private _verticalBlurPostprocess;
  47542. private _blurTexture;
  47543. private _meshes;
  47544. private _excludedMeshes;
  47545. /**
  47546. * Instantiates a new highlight Layer and references it to the scene..
  47547. * @param name The name of the layer
  47548. * @param scene The scene to use the layer in
  47549. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47550. */
  47551. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47552. /**
  47553. * Get the effect name of the layer.
  47554. * @return The effect name
  47555. */
  47556. getEffectName(): string;
  47557. /**
  47558. * Create the merge effect. This is the shader use to blit the information back
  47559. * to the main canvas at the end of the scene rendering.
  47560. */
  47561. protected _createMergeEffect(): Effect;
  47562. /**
  47563. * Creates the render target textures and post processes used in the highlight layer.
  47564. */
  47565. protected _createTextureAndPostProcesses(): void;
  47566. /**
  47567. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47568. */
  47569. needStencil(): boolean;
  47570. /**
  47571. * Checks for the readiness of the element composing the layer.
  47572. * @param subMesh the mesh to check for
  47573. * @param useInstances specify wether or not to use instances to render the mesh
  47574. * @param emissiveTexture the associated emissive texture used to generate the glow
  47575. * @return true if ready otherwise, false
  47576. */
  47577. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47578. /**
  47579. * Implementation specific of rendering the generating effect on the main canvas.
  47580. * @param effect The effect used to render through
  47581. */
  47582. protected _internalRender(effect: Effect): void;
  47583. /**
  47584. * Returns true if the layer contains information to display, otherwise false.
  47585. */
  47586. shouldRender(): boolean;
  47587. /**
  47588. * Returns true if the mesh should render, otherwise false.
  47589. * @param mesh The mesh to render
  47590. * @returns true if it should render otherwise false
  47591. */
  47592. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47593. /**
  47594. * Sets the required values for both the emissive texture and and the main color.
  47595. */
  47596. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47597. /**
  47598. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47599. * @param mesh The mesh to exclude from the highlight layer
  47600. */
  47601. addExcludedMesh(mesh: Mesh): void;
  47602. /**
  47603. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47604. * @param mesh The mesh to highlight
  47605. */
  47606. removeExcludedMesh(mesh: Mesh): void;
  47607. /**
  47608. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47609. * @param mesh mesh to test
  47610. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47611. */
  47612. hasMesh(mesh: AbstractMesh): boolean;
  47613. /**
  47614. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47615. * @param mesh The mesh to highlight
  47616. * @param color The color of the highlight
  47617. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47618. */
  47619. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47620. /**
  47621. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47622. * @param mesh The mesh to highlight
  47623. */
  47624. removeMesh(mesh: Mesh): void;
  47625. /**
  47626. * Force the stencil to the normal expected value for none glowing parts
  47627. */
  47628. private _defaultStencilReference;
  47629. /**
  47630. * Free any resources and references associated to a mesh.
  47631. * Internal use
  47632. * @param mesh The mesh to free.
  47633. * @hidden
  47634. */
  47635. _disposeMesh(mesh: Mesh): void;
  47636. /**
  47637. * Dispose the highlight layer and free resources.
  47638. */
  47639. dispose(): void;
  47640. /**
  47641. * Gets the class name of the effect layer
  47642. * @returns the string with the class name of the effect layer
  47643. */
  47644. getClassName(): string;
  47645. /**
  47646. * Serializes this Highlight layer
  47647. * @returns a serialized Highlight layer object
  47648. */
  47649. serialize(): any;
  47650. /**
  47651. * Creates a Highlight layer from parsed Highlight layer data
  47652. * @param parsedHightlightLayer defines the Highlight layer data
  47653. * @param scene defines the current scene
  47654. * @param rootUrl defines the root URL containing the Highlight layer information
  47655. * @returns a parsed Highlight layer
  47656. */
  47657. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47658. }
  47659. }
  47660. declare module BABYLON {
  47661. /** @hidden */
  47662. export var lensFlarePixelShader: {
  47663. name: string;
  47664. shader: string;
  47665. };
  47666. }
  47667. declare module BABYLON {
  47668. /** @hidden */
  47669. export var lensFlareVertexShader: {
  47670. name: string;
  47671. shader: string;
  47672. };
  47673. }
  47674. declare module BABYLON {
  47675. /**
  47676. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47677. * It is usually composed of several `lensFlare`.
  47678. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47679. */
  47680. export class LensFlareSystem {
  47681. /**
  47682. * Define the name of the lens flare system
  47683. */
  47684. name: string;
  47685. /**
  47686. * List of lens flares used in this system.
  47687. */
  47688. lensFlares: LensFlare[];
  47689. /**
  47690. * Define a limit from the border the lens flare can be visible.
  47691. */
  47692. borderLimit: number;
  47693. /**
  47694. * Define a viewport border we do not want to see the lens flare in.
  47695. */
  47696. viewportBorder: number;
  47697. /**
  47698. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47699. */
  47700. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47701. /**
  47702. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47703. */
  47704. layerMask: number;
  47705. /**
  47706. * Define the id of the lens flare system in the scene.
  47707. * (equal to name by default)
  47708. */
  47709. id: string;
  47710. private _scene;
  47711. private _emitter;
  47712. private _vertexBuffers;
  47713. private _indexBuffer;
  47714. private _effect;
  47715. private _positionX;
  47716. private _positionY;
  47717. private _isEnabled;
  47718. /** @hidden */
  47719. static _SceneComponentInitialization: (scene: Scene) => void;
  47720. /**
  47721. * Instantiates a lens flare system.
  47722. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47723. * It is usually composed of several `lensFlare`.
  47724. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47725. * @param name Define the name of the lens flare system in the scene
  47726. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47727. * @param scene Define the scene the lens flare system belongs to
  47728. */
  47729. constructor(
  47730. /**
  47731. * Define the name of the lens flare system
  47732. */
  47733. name: string, emitter: any, scene: Scene);
  47734. /**
  47735. * Define if the lens flare system is enabled.
  47736. */
  47737. isEnabled: boolean;
  47738. /**
  47739. * Get the scene the effects belongs to.
  47740. * @returns the scene holding the lens flare system
  47741. */
  47742. getScene(): Scene;
  47743. /**
  47744. * Get the emitter of the lens flare system.
  47745. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47746. * @returns the emitter of the lens flare system
  47747. */
  47748. getEmitter(): any;
  47749. /**
  47750. * Set the emitter of the lens flare system.
  47751. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47752. * @param newEmitter Define the new emitter of the system
  47753. */
  47754. setEmitter(newEmitter: any): void;
  47755. /**
  47756. * Get the lens flare system emitter position.
  47757. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47758. * @returns the position
  47759. */
  47760. getEmitterPosition(): Vector3;
  47761. /**
  47762. * @hidden
  47763. */
  47764. computeEffectivePosition(globalViewport: Viewport): boolean;
  47765. /** @hidden */
  47766. _isVisible(): boolean;
  47767. /**
  47768. * @hidden
  47769. */
  47770. render(): boolean;
  47771. /**
  47772. * Dispose and release the lens flare with its associated resources.
  47773. */
  47774. dispose(): void;
  47775. /**
  47776. * Parse a lens flare system from a JSON repressentation
  47777. * @param parsedLensFlareSystem Define the JSON to parse
  47778. * @param scene Define the scene the parsed system should be instantiated in
  47779. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47780. * @returns the parsed system
  47781. */
  47782. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47783. /**
  47784. * Serialize the current Lens Flare System into a JSON representation.
  47785. * @returns the serialized JSON
  47786. */
  47787. serialize(): any;
  47788. }
  47789. }
  47790. declare module BABYLON {
  47791. /**
  47792. * This represents one of the lens effect in a `lensFlareSystem`.
  47793. * It controls one of the indiviual texture used in the effect.
  47794. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47795. */
  47796. export class LensFlare {
  47797. /**
  47798. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47799. */
  47800. size: number;
  47801. /**
  47802. * 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.
  47803. */
  47804. position: number;
  47805. /**
  47806. * Define the lens color.
  47807. */
  47808. color: Color3;
  47809. /**
  47810. * Define the lens texture.
  47811. */
  47812. texture: Nullable<Texture>;
  47813. /**
  47814. * Define the alpha mode to render this particular lens.
  47815. */
  47816. alphaMode: number;
  47817. private _system;
  47818. /**
  47819. * Creates a new Lens Flare.
  47820. * This represents one of the lens effect in a `lensFlareSystem`.
  47821. * It controls one of the indiviual texture used in the effect.
  47822. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47823. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47824. * @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.
  47825. * @param color Define the lens color
  47826. * @param imgUrl Define the lens texture url
  47827. * @param system Define the `lensFlareSystem` this flare is part of
  47828. * @returns The newly created Lens Flare
  47829. */
  47830. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47831. /**
  47832. * Instantiates a new Lens Flare.
  47833. * This represents one of the lens effect in a `lensFlareSystem`.
  47834. * It controls one of the indiviual texture used in the effect.
  47835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47836. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47837. * @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.
  47838. * @param color Define the lens color
  47839. * @param imgUrl Define the lens texture url
  47840. * @param system Define the `lensFlareSystem` this flare is part of
  47841. */
  47842. constructor(
  47843. /**
  47844. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47845. */
  47846. size: number,
  47847. /**
  47848. * 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.
  47849. */
  47850. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47851. /**
  47852. * Dispose and release the lens flare with its associated resources.
  47853. */
  47854. dispose(): void;
  47855. }
  47856. }
  47857. declare module BABYLON {
  47858. interface AbstractScene {
  47859. /**
  47860. * The list of lens flare system added to the scene
  47861. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47862. */
  47863. lensFlareSystems: Array<LensFlareSystem>;
  47864. /**
  47865. * Removes the given lens flare system from this scene.
  47866. * @param toRemove The lens flare system to remove
  47867. * @returns The index of the removed lens flare system
  47868. */
  47869. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47870. /**
  47871. * Adds the given lens flare system to this scene
  47872. * @param newLensFlareSystem The lens flare system to add
  47873. */
  47874. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47875. /**
  47876. * Gets a lens flare system using its name
  47877. * @param name defines the name to look for
  47878. * @returns the lens flare system or null if not found
  47879. */
  47880. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47881. /**
  47882. * Gets a lens flare system using its id
  47883. * @param id defines the id to look for
  47884. * @returns the lens flare system or null if not found
  47885. */
  47886. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47887. }
  47888. /**
  47889. * Defines the lens flare scene component responsible to manage any lens flares
  47890. * in a given scene.
  47891. */
  47892. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47893. /**
  47894. * The component name helpfull to identify the component in the list of scene components.
  47895. */
  47896. readonly name: string;
  47897. /**
  47898. * The scene the component belongs to.
  47899. */
  47900. scene: Scene;
  47901. /**
  47902. * Creates a new instance of the component for the given scene
  47903. * @param scene Defines the scene to register the component in
  47904. */
  47905. constructor(scene: Scene);
  47906. /**
  47907. * Registers the component in a given scene
  47908. */
  47909. register(): void;
  47910. /**
  47911. * Rebuilds the elements related to this component in case of
  47912. * context lost for instance.
  47913. */
  47914. rebuild(): void;
  47915. /**
  47916. * Adds all the element from the container to the scene
  47917. * @param container the container holding the elements
  47918. */
  47919. addFromContainer(container: AbstractScene): void;
  47920. /**
  47921. * Removes all the elements in the container from the scene
  47922. * @param container contains the elements to remove
  47923. * @param dispose if the removed element should be disposed (default: false)
  47924. */
  47925. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47926. /**
  47927. * Serializes the component data to the specified json object
  47928. * @param serializationObject The object to serialize to
  47929. */
  47930. serialize(serializationObject: any): void;
  47931. /**
  47932. * Disposes the component and the associated ressources.
  47933. */
  47934. dispose(): void;
  47935. private _draw;
  47936. }
  47937. }
  47938. declare module BABYLON {
  47939. /**
  47940. * Defines the shadow generator component responsible to manage any shadow generators
  47941. * in a given scene.
  47942. */
  47943. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47944. /**
  47945. * The component name helpfull to identify the component in the list of scene components.
  47946. */
  47947. readonly name: string;
  47948. /**
  47949. * The scene the component belongs to.
  47950. */
  47951. scene: Scene;
  47952. /**
  47953. * Creates a new instance of the component for the given scene
  47954. * @param scene Defines the scene to register the component in
  47955. */
  47956. constructor(scene: Scene);
  47957. /**
  47958. * Registers the component in a given scene
  47959. */
  47960. register(): void;
  47961. /**
  47962. * Rebuilds the elements related to this component in case of
  47963. * context lost for instance.
  47964. */
  47965. rebuild(): void;
  47966. /**
  47967. * Serializes the component data to the specified json object
  47968. * @param serializationObject The object to serialize to
  47969. */
  47970. serialize(serializationObject: any): void;
  47971. /**
  47972. * Adds all the element from the container to the scene
  47973. * @param container the container holding the elements
  47974. */
  47975. addFromContainer(container: AbstractScene): void;
  47976. /**
  47977. * Removes all the elements in the container from the scene
  47978. * @param container contains the elements to remove
  47979. * @param dispose if the removed element should be disposed (default: false)
  47980. */
  47981. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47982. /**
  47983. * Rebuilds the elements related to this component in case of
  47984. * context lost for instance.
  47985. */
  47986. dispose(): void;
  47987. private _gatherRenderTargets;
  47988. }
  47989. }
  47990. declare module BABYLON {
  47991. /**
  47992. * A point light is a light defined by an unique point in world space.
  47993. * The light is emitted in every direction from this point.
  47994. * A good example of a point light is a standard light bulb.
  47995. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47996. */
  47997. export class PointLight extends ShadowLight {
  47998. private _shadowAngle;
  47999. /**
  48000. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48001. * This specifies what angle the shadow will use to be created.
  48002. *
  48003. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48004. */
  48005. /**
  48006. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48007. * This specifies what angle the shadow will use to be created.
  48008. *
  48009. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48010. */
  48011. shadowAngle: number;
  48012. /**
  48013. * Gets the direction if it has been set.
  48014. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48015. */
  48016. /**
  48017. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48018. */
  48019. direction: Vector3;
  48020. /**
  48021. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48022. * A PointLight emits the light in every direction.
  48023. * It can cast shadows.
  48024. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48025. * ```javascript
  48026. * var pointLight = new PointLight("pl", camera.position, scene);
  48027. * ```
  48028. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48029. * @param name The light friendly name
  48030. * @param position The position of the point light in the scene
  48031. * @param scene The scene the lights belongs to
  48032. */
  48033. constructor(name: string, position: Vector3, scene: Scene);
  48034. /**
  48035. * Returns the string "PointLight"
  48036. * @returns the class name
  48037. */
  48038. getClassName(): string;
  48039. /**
  48040. * Returns the integer 0.
  48041. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48042. */
  48043. getTypeID(): number;
  48044. /**
  48045. * Specifies wether or not the shadowmap should be a cube texture.
  48046. * @returns true if the shadowmap needs to be a cube texture.
  48047. */
  48048. needCube(): boolean;
  48049. /**
  48050. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48051. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48052. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48053. */
  48054. getShadowDirection(faceIndex?: number): Vector3;
  48055. /**
  48056. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48057. * - fov = PI / 2
  48058. * - aspect ratio : 1.0
  48059. * - z-near and far equal to the active camera minZ and maxZ.
  48060. * Returns the PointLight.
  48061. */
  48062. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48063. protected _buildUniformLayout(): void;
  48064. /**
  48065. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48066. * @param effect The effect to update
  48067. * @param lightIndex The index of the light in the effect to update
  48068. * @returns The point light
  48069. */
  48070. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48071. /**
  48072. * Prepares the list of defines specific to the light type.
  48073. * @param defines the list of defines
  48074. * @param lightIndex defines the index of the light for the effect
  48075. */
  48076. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48077. }
  48078. }
  48079. declare module BABYLON {
  48080. /**
  48081. * Header information of HDR texture files.
  48082. */
  48083. export interface HDRInfo {
  48084. /**
  48085. * The height of the texture in pixels.
  48086. */
  48087. height: number;
  48088. /**
  48089. * The width of the texture in pixels.
  48090. */
  48091. width: number;
  48092. /**
  48093. * The index of the beginning of the data in the binary file.
  48094. */
  48095. dataPosition: number;
  48096. }
  48097. /**
  48098. * This groups tools to convert HDR texture to native colors array.
  48099. */
  48100. export class HDRTools {
  48101. private static Ldexp;
  48102. private static Rgbe2float;
  48103. private static readStringLine;
  48104. /**
  48105. * Reads header information from an RGBE texture stored in a native array.
  48106. * More information on this format are available here:
  48107. * https://en.wikipedia.org/wiki/RGBE_image_format
  48108. *
  48109. * @param uint8array The binary file stored in native array.
  48110. * @return The header information.
  48111. */
  48112. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48113. /**
  48114. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48115. * This RGBE texture needs to store the information as a panorama.
  48116. *
  48117. * More information on this format are available here:
  48118. * https://en.wikipedia.org/wiki/RGBE_image_format
  48119. *
  48120. * @param buffer The binary file stored in an array buffer.
  48121. * @param size The expected size of the extracted cubemap.
  48122. * @return The Cube Map information.
  48123. */
  48124. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48125. /**
  48126. * Returns the pixels data extracted from an RGBE texture.
  48127. * This pixels will be stored left to right up to down in the R G B order in one array.
  48128. *
  48129. * More information on this format are available here:
  48130. * https://en.wikipedia.org/wiki/RGBE_image_format
  48131. *
  48132. * @param uint8array The binary file stored in an array buffer.
  48133. * @param hdrInfo The header information of the file.
  48134. * @return The pixels data in RGB right to left up to down order.
  48135. */
  48136. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48137. private static RGBE_ReadPixels_RLE;
  48138. }
  48139. }
  48140. declare module BABYLON {
  48141. /**
  48142. * This represents a texture coming from an HDR input.
  48143. *
  48144. * The only supported format is currently panorama picture stored in RGBE format.
  48145. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48146. */
  48147. export class HDRCubeTexture extends BaseTexture {
  48148. private static _facesMapping;
  48149. private _generateHarmonics;
  48150. private _noMipmap;
  48151. private _textureMatrix;
  48152. private _size;
  48153. private _onLoad;
  48154. private _onError;
  48155. /**
  48156. * The texture URL.
  48157. */
  48158. url: string;
  48159. /**
  48160. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48161. */
  48162. coordinatesMode: number;
  48163. protected _isBlocking: boolean;
  48164. /**
  48165. * Sets wether or not the texture is blocking during loading.
  48166. */
  48167. /**
  48168. * Gets wether or not the texture is blocking during loading.
  48169. */
  48170. isBlocking: boolean;
  48171. protected _rotationY: number;
  48172. /**
  48173. * Sets texture matrix rotation angle around Y axis in radians.
  48174. */
  48175. /**
  48176. * Gets texture matrix rotation angle around Y axis radians.
  48177. */
  48178. rotationY: number;
  48179. /**
  48180. * Gets or sets the center of the bounding box associated with the cube texture
  48181. * It must define where the camera used to render the texture was set
  48182. */
  48183. boundingBoxPosition: Vector3;
  48184. private _boundingBoxSize;
  48185. /**
  48186. * Gets or sets the size of the bounding box associated with the cube texture
  48187. * When defined, the cubemap will switch to local mode
  48188. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48189. * @example https://www.babylonjs-playground.com/#RNASML
  48190. */
  48191. boundingBoxSize: Vector3;
  48192. /**
  48193. * Instantiates an HDRTexture from the following parameters.
  48194. *
  48195. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48196. * @param scene The scene the texture will be used in
  48197. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48198. * @param noMipmap Forces to not generate the mipmap if true
  48199. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48200. * @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)
  48201. * @param reserved Reserved flag for internal use.
  48202. */
  48203. 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>);
  48204. /**
  48205. * Get the current class name of the texture useful for serialization or dynamic coding.
  48206. * @returns "HDRCubeTexture"
  48207. */
  48208. getClassName(): string;
  48209. /**
  48210. * Occurs when the file is raw .hdr file.
  48211. */
  48212. private loadTexture;
  48213. clone(): HDRCubeTexture;
  48214. delayLoad(): void;
  48215. /**
  48216. * Get the texture reflection matrix used to rotate/transform the reflection.
  48217. * @returns the reflection matrix
  48218. */
  48219. getReflectionTextureMatrix(): Matrix;
  48220. /**
  48221. * Set the texture reflection matrix used to rotate/transform the reflection.
  48222. * @param value Define the reflection matrix to set
  48223. */
  48224. setReflectionTextureMatrix(value: Matrix): void;
  48225. /**
  48226. * Parses a JSON representation of an HDR Texture in order to create the texture
  48227. * @param parsedTexture Define the JSON representation
  48228. * @param scene Define the scene the texture should be created in
  48229. * @param rootUrl Define the root url in case we need to load relative dependencies
  48230. * @returns the newly created texture after parsing
  48231. */
  48232. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48233. serialize(): any;
  48234. }
  48235. }
  48236. declare module BABYLON {
  48237. /**
  48238. * Class used to control physics engine
  48239. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48240. */
  48241. export class PhysicsEngine implements IPhysicsEngine {
  48242. private _physicsPlugin;
  48243. /**
  48244. * Global value used to control the smallest number supported by the simulation
  48245. */
  48246. static Epsilon: number;
  48247. private _impostors;
  48248. private _joints;
  48249. /**
  48250. * Gets the gravity vector used by the simulation
  48251. */
  48252. gravity: Vector3;
  48253. /**
  48254. * Factory used to create the default physics plugin.
  48255. * @returns The default physics plugin
  48256. */
  48257. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48258. /**
  48259. * Creates a new Physics Engine
  48260. * @param gravity defines the gravity vector used by the simulation
  48261. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48262. */
  48263. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48264. /**
  48265. * Sets the gravity vector used by the simulation
  48266. * @param gravity defines the gravity vector to use
  48267. */
  48268. setGravity(gravity: Vector3): void;
  48269. /**
  48270. * Set the time step of the physics engine.
  48271. * Default is 1/60.
  48272. * To slow it down, enter 1/600 for example.
  48273. * To speed it up, 1/30
  48274. * @param newTimeStep defines the new timestep to apply to this world.
  48275. */
  48276. setTimeStep(newTimeStep?: number): void;
  48277. /**
  48278. * Get the time step of the physics engine.
  48279. * @returns the current time step
  48280. */
  48281. getTimeStep(): number;
  48282. /**
  48283. * Release all resources
  48284. */
  48285. dispose(): void;
  48286. /**
  48287. * Gets the name of the current physics plugin
  48288. * @returns the name of the plugin
  48289. */
  48290. getPhysicsPluginName(): string;
  48291. /**
  48292. * Adding a new impostor for the impostor tracking.
  48293. * This will be done by the impostor itself.
  48294. * @param impostor the impostor to add
  48295. */
  48296. addImpostor(impostor: PhysicsImpostor): void;
  48297. /**
  48298. * Remove an impostor from the engine.
  48299. * This impostor and its mesh will not longer be updated by the physics engine.
  48300. * @param impostor the impostor to remove
  48301. */
  48302. removeImpostor(impostor: PhysicsImpostor): void;
  48303. /**
  48304. * Add a joint to the physics engine
  48305. * @param mainImpostor defines the main impostor to which the joint is added.
  48306. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48307. * @param joint defines the joint that will connect both impostors.
  48308. */
  48309. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48310. /**
  48311. * Removes a joint from the simulation
  48312. * @param mainImpostor defines the impostor used with the joint
  48313. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48314. * @param joint defines the joint to remove
  48315. */
  48316. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48317. /**
  48318. * Called by the scene. No need to call it.
  48319. * @param delta defines the timespam between frames
  48320. */
  48321. _step(delta: number): void;
  48322. /**
  48323. * Gets the current plugin used to run the simulation
  48324. * @returns current plugin
  48325. */
  48326. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48327. /**
  48328. * Gets the list of physic impostors
  48329. * @returns an array of PhysicsImpostor
  48330. */
  48331. getImpostors(): Array<PhysicsImpostor>;
  48332. /**
  48333. * Gets the impostor for a physics enabled object
  48334. * @param object defines the object impersonated by the impostor
  48335. * @returns the PhysicsImpostor or null if not found
  48336. */
  48337. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48338. /**
  48339. * Gets the impostor for a physics body object
  48340. * @param body defines physics body used by the impostor
  48341. * @returns the PhysicsImpostor or null if not found
  48342. */
  48343. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48344. /**
  48345. * Does a raycast in the physics world
  48346. * @param from when should the ray start?
  48347. * @param to when should the ray end?
  48348. * @returns PhysicsRaycastResult
  48349. */
  48350. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48351. }
  48352. }
  48353. declare module BABYLON {
  48354. /** @hidden */
  48355. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48356. private _useDeltaForWorldStep;
  48357. world: any;
  48358. name: string;
  48359. private _physicsMaterials;
  48360. private _fixedTimeStep;
  48361. private _cannonRaycastResult;
  48362. private _raycastResult;
  48363. private _removeAfterStep;
  48364. BJSCANNON: any;
  48365. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48366. setGravity(gravity: Vector3): void;
  48367. setTimeStep(timeStep: number): void;
  48368. getTimeStep(): number;
  48369. executeStep(delta: number): void;
  48370. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48371. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48372. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48373. private _processChildMeshes;
  48374. removePhysicsBody(impostor: PhysicsImpostor): void;
  48375. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48376. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48377. private _addMaterial;
  48378. private _checkWithEpsilon;
  48379. private _createShape;
  48380. private _createHeightmap;
  48381. private _minus90X;
  48382. private _plus90X;
  48383. private _tmpPosition;
  48384. private _tmpDeltaPosition;
  48385. private _tmpUnityRotation;
  48386. private _updatePhysicsBodyTransformation;
  48387. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48388. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48389. isSupported(): boolean;
  48390. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48391. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48392. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48393. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48394. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48395. getBodyMass(impostor: PhysicsImpostor): number;
  48396. getBodyFriction(impostor: PhysicsImpostor): number;
  48397. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48398. getBodyRestitution(impostor: PhysicsImpostor): number;
  48399. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48400. sleepBody(impostor: PhysicsImpostor): void;
  48401. wakeUpBody(impostor: PhysicsImpostor): void;
  48402. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48403. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48404. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48405. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48406. getRadius(impostor: PhysicsImpostor): number;
  48407. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48408. dispose(): void;
  48409. private _extendNamespace;
  48410. /**
  48411. * Does a raycast in the physics world
  48412. * @param from when should the ray start?
  48413. * @param to when should the ray end?
  48414. * @returns PhysicsRaycastResult
  48415. */
  48416. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48417. }
  48418. }
  48419. declare module BABYLON {
  48420. /** @hidden */
  48421. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48422. world: any;
  48423. name: string;
  48424. BJSOIMO: any;
  48425. private _raycastResult;
  48426. constructor(iterations?: number, oimoInjection?: any);
  48427. setGravity(gravity: Vector3): void;
  48428. setTimeStep(timeStep: number): void;
  48429. getTimeStep(): number;
  48430. private _tmpImpostorsArray;
  48431. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48432. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48433. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48434. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48435. private _tmpPositionVector;
  48436. removePhysicsBody(impostor: PhysicsImpostor): void;
  48437. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48438. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48439. isSupported(): boolean;
  48440. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48441. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48442. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48443. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48444. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48445. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48446. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48447. getBodyMass(impostor: PhysicsImpostor): number;
  48448. getBodyFriction(impostor: PhysicsImpostor): number;
  48449. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48450. getBodyRestitution(impostor: PhysicsImpostor): number;
  48451. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48452. sleepBody(impostor: PhysicsImpostor): void;
  48453. wakeUpBody(impostor: PhysicsImpostor): void;
  48454. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48455. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48456. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48457. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48458. getRadius(impostor: PhysicsImpostor): number;
  48459. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48460. dispose(): void;
  48461. /**
  48462. * Does a raycast in the physics world
  48463. * @param from when should the ray start?
  48464. * @param to when should the ray end?
  48465. * @returns PhysicsRaycastResult
  48466. */
  48467. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48468. }
  48469. }
  48470. declare module BABYLON {
  48471. /**
  48472. * Class containing static functions to help procedurally build meshes
  48473. */
  48474. export class RibbonBuilder {
  48475. /**
  48476. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48477. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48478. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48479. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48480. * * 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
  48481. * * 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
  48482. * * 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
  48483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48484. * * 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
  48485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48486. * * 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
  48487. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48488. * * 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
  48489. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48491. * @param name defines the name of the mesh
  48492. * @param options defines the options used to create the mesh
  48493. * @param scene defines the hosting scene
  48494. * @returns the ribbon mesh
  48495. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48497. */
  48498. static CreateRibbon(name: string, options: {
  48499. pathArray: Vector3[][];
  48500. closeArray?: boolean;
  48501. closePath?: boolean;
  48502. offset?: number;
  48503. updatable?: boolean;
  48504. sideOrientation?: number;
  48505. frontUVs?: Vector4;
  48506. backUVs?: Vector4;
  48507. instance?: Mesh;
  48508. invertUV?: boolean;
  48509. uvs?: Vector2[];
  48510. colors?: Color4[];
  48511. }, scene?: Nullable<Scene>): Mesh;
  48512. }
  48513. }
  48514. declare module BABYLON {
  48515. /**
  48516. * Class containing static functions to help procedurally build meshes
  48517. */
  48518. export class ShapeBuilder {
  48519. /**
  48520. * 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.
  48521. * * 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.
  48522. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48523. * * 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.
  48524. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48525. * * 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
  48526. * * 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
  48527. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48529. * * 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
  48530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48532. * @param name defines the name of the mesh
  48533. * @param options defines the options used to create the mesh
  48534. * @param scene defines the hosting scene
  48535. * @returns the extruded shape mesh
  48536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48538. */
  48539. static ExtrudeShape(name: string, options: {
  48540. shape: Vector3[];
  48541. path: Vector3[];
  48542. scale?: number;
  48543. rotation?: number;
  48544. cap?: number;
  48545. updatable?: boolean;
  48546. sideOrientation?: number;
  48547. frontUVs?: Vector4;
  48548. backUVs?: Vector4;
  48549. instance?: Mesh;
  48550. invertUV?: boolean;
  48551. }, scene?: Nullable<Scene>): Mesh;
  48552. /**
  48553. * Creates an custom extruded shape mesh.
  48554. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48555. * * 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.
  48556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48557. * * 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
  48558. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48559. * * 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
  48560. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48561. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48562. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48563. * * 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
  48564. * * 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
  48565. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48567. * * 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
  48568. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48570. * @param name defines the name of the mesh
  48571. * @param options defines the options used to create the mesh
  48572. * @param scene defines the hosting scene
  48573. * @returns the custom extruded shape mesh
  48574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48575. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48577. */
  48578. static ExtrudeShapeCustom(name: string, options: {
  48579. shape: Vector3[];
  48580. path: Vector3[];
  48581. scaleFunction?: any;
  48582. rotationFunction?: any;
  48583. ribbonCloseArray?: boolean;
  48584. ribbonClosePath?: boolean;
  48585. cap?: number;
  48586. updatable?: boolean;
  48587. sideOrientation?: number;
  48588. frontUVs?: Vector4;
  48589. backUVs?: Vector4;
  48590. instance?: Mesh;
  48591. invertUV?: boolean;
  48592. }, scene?: Nullable<Scene>): Mesh;
  48593. private static _ExtrudeShapeGeneric;
  48594. }
  48595. }
  48596. declare module BABYLON {
  48597. /**
  48598. * AmmoJS Physics plugin
  48599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48600. * @see https://github.com/kripken/ammo.js/
  48601. */
  48602. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48603. private _useDeltaForWorldStep;
  48604. /**
  48605. * Reference to the Ammo library
  48606. */
  48607. bjsAMMO: any;
  48608. /**
  48609. * Created ammoJS world which physics bodies are added to
  48610. */
  48611. world: any;
  48612. /**
  48613. * Name of the plugin
  48614. */
  48615. name: string;
  48616. private _timeStep;
  48617. private _fixedTimeStep;
  48618. private _maxSteps;
  48619. private _tmpQuaternion;
  48620. private _tmpAmmoTransform;
  48621. private _tmpAmmoQuaternion;
  48622. private _tmpAmmoConcreteContactResultCallback;
  48623. private _collisionConfiguration;
  48624. private _dispatcher;
  48625. private _overlappingPairCache;
  48626. private _solver;
  48627. private _softBodySolver;
  48628. private _tmpAmmoVectorA;
  48629. private _tmpAmmoVectorB;
  48630. private _tmpAmmoVectorC;
  48631. private _tmpAmmoVectorD;
  48632. private _tmpContactCallbackResult;
  48633. private _tmpAmmoVectorRCA;
  48634. private _tmpAmmoVectorRCB;
  48635. private _raycastResult;
  48636. private static readonly DISABLE_COLLISION_FLAG;
  48637. private static readonly KINEMATIC_FLAG;
  48638. private static readonly DISABLE_DEACTIVATION_FLAG;
  48639. /**
  48640. * Initializes the ammoJS plugin
  48641. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48642. * @param ammoInjection can be used to inject your own ammo reference
  48643. */
  48644. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48645. /**
  48646. * Sets the gravity of the physics world (m/(s^2))
  48647. * @param gravity Gravity to set
  48648. */
  48649. setGravity(gravity: Vector3): void;
  48650. /**
  48651. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48652. * @param timeStep timestep to use in seconds
  48653. */
  48654. setTimeStep(timeStep: number): void;
  48655. /**
  48656. * 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)
  48657. * @param fixedTimeStep fixedTimeStep to use in seconds
  48658. */
  48659. setFixedTimeStep(fixedTimeStep: number): void;
  48660. /**
  48661. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48662. * @param maxSteps the maximum number of steps by the physics engine per frame
  48663. */
  48664. setMaxSteps(maxSteps: number): void;
  48665. /**
  48666. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48667. * @returns the current timestep in seconds
  48668. */
  48669. getTimeStep(): number;
  48670. private _isImpostorInContact;
  48671. private _isImpostorPairInContact;
  48672. private _stepSimulation;
  48673. /**
  48674. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48675. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48676. * After the step the babylon meshes are set to the position of the physics imposters
  48677. * @param delta amount of time to step forward
  48678. * @param impostors array of imposters to update before/after the step
  48679. */
  48680. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48681. /**
  48682. * Update babylon mesh to match physics world object
  48683. * @param impostor imposter to match
  48684. */
  48685. private _afterSoftStep;
  48686. /**
  48687. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48688. * @param impostor imposter to match
  48689. */
  48690. private _ropeStep;
  48691. /**
  48692. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48693. * @param impostor imposter to match
  48694. */
  48695. private _softbodyOrClothStep;
  48696. private _tmpVector;
  48697. private _tmpMatrix;
  48698. /**
  48699. * Applies an impulse on the imposter
  48700. * @param impostor imposter to apply impulse to
  48701. * @param force amount of force to be applied to the imposter
  48702. * @param contactPoint the location to apply the impulse on the imposter
  48703. */
  48704. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48705. /**
  48706. * Applies a force on the imposter
  48707. * @param impostor imposter to apply force
  48708. * @param force amount of force to be applied to the imposter
  48709. * @param contactPoint the location to apply the force on the imposter
  48710. */
  48711. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48712. /**
  48713. * Creates a physics body using the plugin
  48714. * @param impostor the imposter to create the physics body on
  48715. */
  48716. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48717. /**
  48718. * Removes the physics body from the imposter and disposes of the body's memory
  48719. * @param impostor imposter to remove the physics body from
  48720. */
  48721. removePhysicsBody(impostor: PhysicsImpostor): void;
  48722. /**
  48723. * Generates a joint
  48724. * @param impostorJoint the imposter joint to create the joint with
  48725. */
  48726. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48727. /**
  48728. * Removes a joint
  48729. * @param impostorJoint the imposter joint to remove the joint from
  48730. */
  48731. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48732. private _addMeshVerts;
  48733. /**
  48734. * Initialise the soft body vertices to match its object's (mesh) vertices
  48735. * Softbody vertices (nodes) are in world space and to match this
  48736. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48737. * @param impostor to create the softbody for
  48738. */
  48739. private _softVertexData;
  48740. /**
  48741. * Create an impostor's soft body
  48742. * @param impostor to create the softbody for
  48743. */
  48744. private _createSoftbody;
  48745. /**
  48746. * Create cloth for an impostor
  48747. * @param impostor to create the softbody for
  48748. */
  48749. private _createCloth;
  48750. /**
  48751. * Create rope for an impostor
  48752. * @param impostor to create the softbody for
  48753. */
  48754. private _createRope;
  48755. private _addHullVerts;
  48756. private _createShape;
  48757. /**
  48758. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48759. * @param impostor imposter containing the physics body and babylon object
  48760. */
  48761. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48762. /**
  48763. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48764. * @param impostor imposter containing the physics body and babylon object
  48765. * @param newPosition new position
  48766. * @param newRotation new rotation
  48767. */
  48768. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48769. /**
  48770. * If this plugin is supported
  48771. * @returns true if its supported
  48772. */
  48773. isSupported(): boolean;
  48774. /**
  48775. * Sets the linear velocity of the physics body
  48776. * @param impostor imposter to set the velocity on
  48777. * @param velocity velocity to set
  48778. */
  48779. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48780. /**
  48781. * Sets the angular velocity of the physics body
  48782. * @param impostor imposter to set the velocity on
  48783. * @param velocity velocity to set
  48784. */
  48785. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48786. /**
  48787. * gets the linear velocity
  48788. * @param impostor imposter to get linear velocity from
  48789. * @returns linear velocity
  48790. */
  48791. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48792. /**
  48793. * gets the angular velocity
  48794. * @param impostor imposter to get angular velocity from
  48795. * @returns angular velocity
  48796. */
  48797. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48798. /**
  48799. * Sets the mass of physics body
  48800. * @param impostor imposter to set the mass on
  48801. * @param mass mass to set
  48802. */
  48803. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48804. /**
  48805. * Gets the mass of the physics body
  48806. * @param impostor imposter to get the mass from
  48807. * @returns mass
  48808. */
  48809. getBodyMass(impostor: PhysicsImpostor): number;
  48810. /**
  48811. * Gets friction of the impostor
  48812. * @param impostor impostor to get friction from
  48813. * @returns friction value
  48814. */
  48815. getBodyFriction(impostor: PhysicsImpostor): number;
  48816. /**
  48817. * Sets friction of the impostor
  48818. * @param impostor impostor to set friction on
  48819. * @param friction friction value
  48820. */
  48821. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48822. /**
  48823. * Gets restitution of the impostor
  48824. * @param impostor impostor to get restitution from
  48825. * @returns restitution value
  48826. */
  48827. getBodyRestitution(impostor: PhysicsImpostor): number;
  48828. /**
  48829. * Sets resitution of the impostor
  48830. * @param impostor impostor to set resitution on
  48831. * @param restitution resitution value
  48832. */
  48833. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48834. /**
  48835. * Gets pressure inside the impostor
  48836. * @param impostor impostor to get pressure from
  48837. * @returns pressure value
  48838. */
  48839. getBodyPressure(impostor: PhysicsImpostor): number;
  48840. /**
  48841. * Sets pressure inside a soft body impostor
  48842. * Cloth and rope must remain 0 pressure
  48843. * @param impostor impostor to set pressure on
  48844. * @param pressure pressure value
  48845. */
  48846. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48847. /**
  48848. * Gets stiffness of the impostor
  48849. * @param impostor impostor to get stiffness from
  48850. * @returns pressure value
  48851. */
  48852. getBodyStiffness(impostor: PhysicsImpostor): number;
  48853. /**
  48854. * Sets stiffness of the impostor
  48855. * @param impostor impostor to set stiffness on
  48856. * @param stiffness stiffness value from 0 to 1
  48857. */
  48858. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48859. /**
  48860. * Gets velocityIterations of the impostor
  48861. * @param impostor impostor to get velocity iterations from
  48862. * @returns velocityIterations value
  48863. */
  48864. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48865. /**
  48866. * Sets velocityIterations of the impostor
  48867. * @param impostor impostor to set velocity iterations on
  48868. * @param velocityIterations velocityIterations value
  48869. */
  48870. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48871. /**
  48872. * Gets positionIterations of the impostor
  48873. * @param impostor impostor to get position iterations from
  48874. * @returns positionIterations value
  48875. */
  48876. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48877. /**
  48878. * Sets positionIterations of the impostor
  48879. * @param impostor impostor to set position on
  48880. * @param positionIterations positionIterations value
  48881. */
  48882. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48883. /**
  48884. * Append an anchor to a cloth object
  48885. * @param impostor is the cloth impostor to add anchor to
  48886. * @param otherImpostor is the rigid impostor to anchor to
  48887. * @param width ratio across width from 0 to 1
  48888. * @param height ratio up height from 0 to 1
  48889. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48890. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48891. */
  48892. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48893. /**
  48894. * Append an hook to a rope object
  48895. * @param impostor is the rope impostor to add hook to
  48896. * @param otherImpostor is the rigid impostor to hook to
  48897. * @param length ratio along the rope from 0 to 1
  48898. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48899. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48900. */
  48901. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48902. /**
  48903. * Sleeps the physics body and stops it from being active
  48904. * @param impostor impostor to sleep
  48905. */
  48906. sleepBody(impostor: PhysicsImpostor): void;
  48907. /**
  48908. * Activates the physics body
  48909. * @param impostor impostor to activate
  48910. */
  48911. wakeUpBody(impostor: PhysicsImpostor): void;
  48912. /**
  48913. * Updates the distance parameters of the joint
  48914. * @param joint joint to update
  48915. * @param maxDistance maximum distance of the joint
  48916. * @param minDistance minimum distance of the joint
  48917. */
  48918. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48919. /**
  48920. * Sets a motor on the joint
  48921. * @param joint joint to set motor on
  48922. * @param speed speed of the motor
  48923. * @param maxForce maximum force of the motor
  48924. * @param motorIndex index of the motor
  48925. */
  48926. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48927. /**
  48928. * Sets the motors limit
  48929. * @param joint joint to set limit on
  48930. * @param upperLimit upper limit
  48931. * @param lowerLimit lower limit
  48932. */
  48933. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48934. /**
  48935. * Syncs the position and rotation of a mesh with the impostor
  48936. * @param mesh mesh to sync
  48937. * @param impostor impostor to update the mesh with
  48938. */
  48939. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48940. /**
  48941. * Gets the radius of the impostor
  48942. * @param impostor impostor to get radius from
  48943. * @returns the radius
  48944. */
  48945. getRadius(impostor: PhysicsImpostor): number;
  48946. /**
  48947. * Gets the box size of the impostor
  48948. * @param impostor impostor to get box size from
  48949. * @param result the resulting box size
  48950. */
  48951. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48952. /**
  48953. * Disposes of the impostor
  48954. */
  48955. dispose(): void;
  48956. /**
  48957. * Does a raycast in the physics world
  48958. * @param from when should the ray start?
  48959. * @param to when should the ray end?
  48960. * @returns PhysicsRaycastResult
  48961. */
  48962. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48963. }
  48964. }
  48965. declare module BABYLON {
  48966. interface AbstractScene {
  48967. /**
  48968. * The list of reflection probes added to the scene
  48969. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48970. */
  48971. reflectionProbes: Array<ReflectionProbe>;
  48972. /**
  48973. * Removes the given reflection probe from this scene.
  48974. * @param toRemove The reflection probe to remove
  48975. * @returns The index of the removed reflection probe
  48976. */
  48977. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48978. /**
  48979. * Adds the given reflection probe to this scene.
  48980. * @param newReflectionProbe The reflection probe to add
  48981. */
  48982. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48983. }
  48984. /**
  48985. * Class used to generate realtime reflection / refraction cube textures
  48986. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48987. */
  48988. export class ReflectionProbe {
  48989. /** defines the name of the probe */
  48990. name: string;
  48991. private _scene;
  48992. private _renderTargetTexture;
  48993. private _projectionMatrix;
  48994. private _viewMatrix;
  48995. private _target;
  48996. private _add;
  48997. private _attachedMesh;
  48998. private _invertYAxis;
  48999. /** Gets or sets probe position (center of the cube map) */
  49000. position: Vector3;
  49001. /**
  49002. * Creates a new reflection probe
  49003. * @param name defines the name of the probe
  49004. * @param size defines the texture resolution (for each face)
  49005. * @param scene defines the hosting scene
  49006. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49007. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49008. */
  49009. constructor(
  49010. /** defines the name of the probe */
  49011. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49012. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49013. samples: number;
  49014. /** Gets or sets the refresh rate to use (on every frame by default) */
  49015. refreshRate: number;
  49016. /**
  49017. * Gets the hosting scene
  49018. * @returns a Scene
  49019. */
  49020. getScene(): Scene;
  49021. /** Gets the internal CubeTexture used to render to */
  49022. readonly cubeTexture: RenderTargetTexture;
  49023. /** Gets the list of meshes to render */
  49024. readonly renderList: Nullable<AbstractMesh[]>;
  49025. /**
  49026. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49027. * @param mesh defines the mesh to attach to
  49028. */
  49029. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49030. /**
  49031. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49032. * @param renderingGroupId The rendering group id corresponding to its index
  49033. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49034. */
  49035. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49036. /**
  49037. * Clean all associated resources
  49038. */
  49039. dispose(): void;
  49040. /**
  49041. * Converts the reflection probe information to a readable string for debug purpose.
  49042. * @param fullDetails Supports for multiple levels of logging within scene loading
  49043. * @returns the human readable reflection probe info
  49044. */
  49045. toString(fullDetails?: boolean): string;
  49046. /**
  49047. * Get the class name of the relfection probe.
  49048. * @returns "ReflectionProbe"
  49049. */
  49050. getClassName(): string;
  49051. /**
  49052. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49053. * @returns The JSON representation of the texture
  49054. */
  49055. serialize(): any;
  49056. /**
  49057. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49058. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49059. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49060. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49061. * @returns The parsed reflection probe if successful
  49062. */
  49063. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49064. }
  49065. }
  49066. declare module BABYLON {
  49067. /** @hidden */
  49068. export var _BabylonLoaderRegistered: boolean;
  49069. }
  49070. declare module BABYLON {
  49071. /**
  49072. * The Physically based simple base material of BJS.
  49073. *
  49074. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49075. * It is used as the base class for both the specGloss and metalRough conventions.
  49076. */
  49077. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49078. /**
  49079. * Number of Simultaneous lights allowed on the material.
  49080. */
  49081. maxSimultaneousLights: number;
  49082. /**
  49083. * If sets to true, disables all the lights affecting the material.
  49084. */
  49085. disableLighting: boolean;
  49086. /**
  49087. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49088. */
  49089. environmentTexture: BaseTexture;
  49090. /**
  49091. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49092. */
  49093. invertNormalMapX: boolean;
  49094. /**
  49095. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49096. */
  49097. invertNormalMapY: boolean;
  49098. /**
  49099. * Normal map used in the model.
  49100. */
  49101. normalTexture: BaseTexture;
  49102. /**
  49103. * Emissivie color used to self-illuminate the model.
  49104. */
  49105. emissiveColor: Color3;
  49106. /**
  49107. * Emissivie texture used to self-illuminate the model.
  49108. */
  49109. emissiveTexture: BaseTexture;
  49110. /**
  49111. * Occlusion Channel Strenght.
  49112. */
  49113. occlusionStrength: number;
  49114. /**
  49115. * Occlusion Texture of the material (adding extra occlusion effects).
  49116. */
  49117. occlusionTexture: BaseTexture;
  49118. /**
  49119. * Defines the alpha limits in alpha test mode.
  49120. */
  49121. alphaCutOff: number;
  49122. /**
  49123. * Gets the current double sided mode.
  49124. */
  49125. /**
  49126. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49127. */
  49128. doubleSided: boolean;
  49129. /**
  49130. * Stores the pre-calculated light information of a mesh in a texture.
  49131. */
  49132. lightmapTexture: BaseTexture;
  49133. /**
  49134. * If true, the light map contains occlusion information instead of lighting info.
  49135. */
  49136. useLightmapAsShadowmap: boolean;
  49137. /**
  49138. * Instantiates a new PBRMaterial instance.
  49139. *
  49140. * @param name The material name
  49141. * @param scene The scene the material will be use in.
  49142. */
  49143. constructor(name: string, scene: Scene);
  49144. getClassName(): string;
  49145. }
  49146. }
  49147. declare module BABYLON {
  49148. /**
  49149. * The PBR material of BJS following the metal roughness convention.
  49150. *
  49151. * This fits to the PBR convention in the GLTF definition:
  49152. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49153. */
  49154. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49155. /**
  49156. * The base color has two different interpretations depending on the value of metalness.
  49157. * When the material is a metal, the base color is the specific measured reflectance value
  49158. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49159. * of the material.
  49160. */
  49161. baseColor: Color3;
  49162. /**
  49163. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49164. * well as opacity information in the alpha channel.
  49165. */
  49166. baseTexture: BaseTexture;
  49167. /**
  49168. * Specifies the metallic scalar value of the material.
  49169. * Can also be used to scale the metalness values of the metallic texture.
  49170. */
  49171. metallic: number;
  49172. /**
  49173. * Specifies the roughness scalar value of the material.
  49174. * Can also be used to scale the roughness values of the metallic texture.
  49175. */
  49176. roughness: number;
  49177. /**
  49178. * Texture containing both the metallic value in the B channel and the
  49179. * roughness value in the G channel to keep better precision.
  49180. */
  49181. metallicRoughnessTexture: BaseTexture;
  49182. /**
  49183. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49184. *
  49185. * @param name The material name
  49186. * @param scene The scene the material will be use in.
  49187. */
  49188. constructor(name: string, scene: Scene);
  49189. /**
  49190. * Return the currrent class name of the material.
  49191. */
  49192. getClassName(): string;
  49193. /**
  49194. * Makes a duplicate of the current material.
  49195. * @param name - name to use for the new material.
  49196. */
  49197. clone(name: string): PBRMetallicRoughnessMaterial;
  49198. /**
  49199. * Serialize the material to a parsable JSON object.
  49200. */
  49201. serialize(): any;
  49202. /**
  49203. * Parses a JSON object correponding to the serialize function.
  49204. */
  49205. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49206. }
  49207. }
  49208. declare module BABYLON {
  49209. /**
  49210. * The PBR material of BJS following the specular glossiness convention.
  49211. *
  49212. * This fits to the PBR convention in the GLTF definition:
  49213. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49214. */
  49215. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49216. /**
  49217. * Specifies the diffuse color of the material.
  49218. */
  49219. diffuseColor: Color3;
  49220. /**
  49221. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49222. * channel.
  49223. */
  49224. diffuseTexture: BaseTexture;
  49225. /**
  49226. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49227. */
  49228. specularColor: Color3;
  49229. /**
  49230. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49231. */
  49232. glossiness: number;
  49233. /**
  49234. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49235. */
  49236. specularGlossinessTexture: BaseTexture;
  49237. /**
  49238. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49239. *
  49240. * @param name The material name
  49241. * @param scene The scene the material will be use in.
  49242. */
  49243. constructor(name: string, scene: Scene);
  49244. /**
  49245. * Return the currrent class name of the material.
  49246. */
  49247. getClassName(): string;
  49248. /**
  49249. * Makes a duplicate of the current material.
  49250. * @param name - name to use for the new material.
  49251. */
  49252. clone(name: string): PBRSpecularGlossinessMaterial;
  49253. /**
  49254. * Serialize the material to a parsable JSON object.
  49255. */
  49256. serialize(): any;
  49257. /**
  49258. * Parses a JSON object correponding to the serialize function.
  49259. */
  49260. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49261. }
  49262. }
  49263. declare module BABYLON {
  49264. /**
  49265. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49266. * It can help converting any input color in a desired output one. This can then be used to create effects
  49267. * from sepia, black and white to sixties or futuristic rendering...
  49268. *
  49269. * The only supported format is currently 3dl.
  49270. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49271. */
  49272. export class ColorGradingTexture extends BaseTexture {
  49273. /**
  49274. * The current texture matrix. (will always be identity in color grading texture)
  49275. */
  49276. private _textureMatrix;
  49277. /**
  49278. * The texture URL.
  49279. */
  49280. url: string;
  49281. /**
  49282. * Empty line regex stored for GC.
  49283. */
  49284. private static _noneEmptyLineRegex;
  49285. private _engine;
  49286. /**
  49287. * Instantiates a ColorGradingTexture from the following parameters.
  49288. *
  49289. * @param url The location of the color gradind data (currently only supporting 3dl)
  49290. * @param scene The scene the texture will be used in
  49291. */
  49292. constructor(url: string, scene: Scene);
  49293. /**
  49294. * Returns the texture matrix used in most of the material.
  49295. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49296. */
  49297. getTextureMatrix(): Matrix;
  49298. /**
  49299. * Occurs when the file being loaded is a .3dl LUT file.
  49300. */
  49301. private load3dlTexture;
  49302. /**
  49303. * Starts the loading process of the texture.
  49304. */
  49305. private loadTexture;
  49306. /**
  49307. * Clones the color gradind texture.
  49308. */
  49309. clone(): ColorGradingTexture;
  49310. /**
  49311. * Called during delayed load for textures.
  49312. */
  49313. delayLoad(): void;
  49314. /**
  49315. * Parses a color grading texture serialized by Babylon.
  49316. * @param parsedTexture The texture information being parsedTexture
  49317. * @param scene The scene to load the texture in
  49318. * @param rootUrl The root url of the data assets to load
  49319. * @return A color gradind texture
  49320. */
  49321. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49322. /**
  49323. * Serializes the LUT texture to json format.
  49324. */
  49325. serialize(): any;
  49326. }
  49327. }
  49328. declare module BABYLON {
  49329. /**
  49330. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49331. */
  49332. export class EquiRectangularCubeTexture extends BaseTexture {
  49333. /** The six faces of the cube. */
  49334. private static _FacesMapping;
  49335. private _noMipmap;
  49336. private _onLoad;
  49337. private _onError;
  49338. /** The size of the cubemap. */
  49339. private _size;
  49340. /** The buffer of the image. */
  49341. private _buffer;
  49342. /** The width of the input image. */
  49343. private _width;
  49344. /** The height of the input image. */
  49345. private _height;
  49346. /** The URL to the image. */
  49347. url: string;
  49348. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49349. coordinatesMode: number;
  49350. /**
  49351. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49352. * @param url The location of the image
  49353. * @param scene The scene the texture will be used in
  49354. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49355. * @param noMipmap Forces to not generate the mipmap if true
  49356. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49357. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49358. * @param onLoad — defines a callback called when texture is loaded
  49359. * @param onError — defines a callback called if there is an error
  49360. */
  49361. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49362. /**
  49363. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49364. */
  49365. private loadImage;
  49366. /**
  49367. * Convert the image buffer into a cubemap and create a CubeTexture.
  49368. */
  49369. private loadTexture;
  49370. /**
  49371. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49372. * @param buffer The ArrayBuffer that should be converted.
  49373. * @returns The buffer as Float32Array.
  49374. */
  49375. private getFloat32ArrayFromArrayBuffer;
  49376. /**
  49377. * Get the current class name of the texture useful for serialization or dynamic coding.
  49378. * @returns "EquiRectangularCubeTexture"
  49379. */
  49380. getClassName(): string;
  49381. /**
  49382. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49383. * @returns A clone of the current EquiRectangularCubeTexture.
  49384. */
  49385. clone(): EquiRectangularCubeTexture;
  49386. }
  49387. }
  49388. declare module BABYLON {
  49389. /**
  49390. * Based on jsTGALoader - Javascript loader for TGA file
  49391. * By Vincent Thibault
  49392. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49393. */
  49394. export class TGATools {
  49395. private static _TYPE_INDEXED;
  49396. private static _TYPE_RGB;
  49397. private static _TYPE_GREY;
  49398. private static _TYPE_RLE_INDEXED;
  49399. private static _TYPE_RLE_RGB;
  49400. private static _TYPE_RLE_GREY;
  49401. private static _ORIGIN_MASK;
  49402. private static _ORIGIN_SHIFT;
  49403. private static _ORIGIN_BL;
  49404. private static _ORIGIN_BR;
  49405. private static _ORIGIN_UL;
  49406. private static _ORIGIN_UR;
  49407. /**
  49408. * Gets the header of a TGA file
  49409. * @param data defines the TGA data
  49410. * @returns the header
  49411. */
  49412. static GetTGAHeader(data: Uint8Array): any;
  49413. /**
  49414. * Uploads TGA content to a Babylon Texture
  49415. * @hidden
  49416. */
  49417. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49418. /** @hidden */
  49419. 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;
  49420. /** @hidden */
  49421. 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;
  49422. /** @hidden */
  49423. 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;
  49424. /** @hidden */
  49425. 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;
  49426. /** @hidden */
  49427. 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;
  49428. /** @hidden */
  49429. 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;
  49430. }
  49431. }
  49432. declare module BABYLON {
  49433. /**
  49434. * Implementation of the TGA Texture Loader.
  49435. * @hidden
  49436. */
  49437. export class _TGATextureLoader implements IInternalTextureLoader {
  49438. /**
  49439. * Defines wether the loader supports cascade loading the different faces.
  49440. */
  49441. readonly supportCascades: boolean;
  49442. /**
  49443. * This returns if the loader support the current file information.
  49444. * @param extension defines the file extension of the file being loaded
  49445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49446. * @param fallback defines the fallback internal texture if any
  49447. * @param isBase64 defines whether the texture is encoded as a base64
  49448. * @param isBuffer defines whether the texture data are stored as a buffer
  49449. * @returns true if the loader can load the specified file
  49450. */
  49451. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49452. /**
  49453. * Transform the url before loading if required.
  49454. * @param rootUrl the url of the texture
  49455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49456. * @returns the transformed texture
  49457. */
  49458. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49459. /**
  49460. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49461. * @param rootUrl the url of the texture
  49462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49463. * @returns the fallback texture
  49464. */
  49465. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49466. /**
  49467. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49468. * @param data contains the texture data
  49469. * @param texture defines the BabylonJS internal texture
  49470. * @param createPolynomials will be true if polynomials have been requested
  49471. * @param onLoad defines the callback to trigger once the texture is ready
  49472. * @param onError defines the callback to trigger in case of error
  49473. */
  49474. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49475. /**
  49476. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49477. * @param data contains the texture data
  49478. * @param texture defines the BabylonJS internal texture
  49479. * @param callback defines the method to call once ready to upload
  49480. */
  49481. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49482. }
  49483. }
  49484. declare module BABYLON {
  49485. /**
  49486. * 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.
  49487. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49488. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49489. */
  49490. export class CustomProceduralTexture extends ProceduralTexture {
  49491. private _animate;
  49492. private _time;
  49493. private _config;
  49494. private _texturePath;
  49495. /**
  49496. * Instantiates a new Custom Procedural Texture.
  49497. * 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.
  49498. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49499. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49500. * @param name Define the name of the texture
  49501. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49502. * @param size Define the size of the texture to create
  49503. * @param scene Define the scene the texture belongs to
  49504. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49505. * @param generateMipMaps Define if the texture should creates mip maps or not
  49506. */
  49507. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49508. private _loadJson;
  49509. /**
  49510. * Is the texture ready to be used ? (rendered at least once)
  49511. * @returns true if ready, otherwise, false.
  49512. */
  49513. isReady(): boolean;
  49514. /**
  49515. * Render the texture to its associated render target.
  49516. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49517. */
  49518. render(useCameraPostProcess?: boolean): void;
  49519. /**
  49520. * Update the list of dependant textures samplers in the shader.
  49521. */
  49522. updateTextures(): void;
  49523. /**
  49524. * Update the uniform values of the procedural texture in the shader.
  49525. */
  49526. updateShaderUniforms(): void;
  49527. /**
  49528. * Define if the texture animates or not.
  49529. */
  49530. animate: boolean;
  49531. }
  49532. }
  49533. declare module BABYLON {
  49534. /** @hidden */
  49535. export var noisePixelShader: {
  49536. name: string;
  49537. shader: string;
  49538. };
  49539. }
  49540. declare module BABYLON {
  49541. /**
  49542. * Class used to generate noise procedural textures
  49543. */
  49544. export class NoiseProceduralTexture extends ProceduralTexture {
  49545. private _time;
  49546. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49547. brightness: number;
  49548. /** Defines the number of octaves to process */
  49549. octaves: number;
  49550. /** Defines the level of persistence (0.8 by default) */
  49551. persistence: number;
  49552. /** Gets or sets animation speed factor (default is 1) */
  49553. animationSpeedFactor: number;
  49554. /**
  49555. * Creates a new NoiseProceduralTexture
  49556. * @param name defines the name fo the texture
  49557. * @param size defines the size of the texture (default is 256)
  49558. * @param scene defines the hosting scene
  49559. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49560. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49561. */
  49562. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49563. private _updateShaderUniforms;
  49564. protected _getDefines(): string;
  49565. /** Generate the current state of the procedural texture */
  49566. render(useCameraPostProcess?: boolean): void;
  49567. /**
  49568. * Serializes this noise procedural texture
  49569. * @returns a serialized noise procedural texture object
  49570. */
  49571. serialize(): any;
  49572. /**
  49573. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49574. * @param parsedTexture defines parsed texture data
  49575. * @param scene defines the current scene
  49576. * @param rootUrl defines the root URL containing noise procedural texture information
  49577. * @returns a parsed NoiseProceduralTexture
  49578. */
  49579. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49580. }
  49581. }
  49582. declare module BABYLON {
  49583. /**
  49584. * Raw cube texture where the raw buffers are passed in
  49585. */
  49586. export class RawCubeTexture extends CubeTexture {
  49587. /**
  49588. * Creates a cube texture where the raw buffers are passed in.
  49589. * @param scene defines the scene the texture is attached to
  49590. * @param data defines the array of data to use to create each face
  49591. * @param size defines the size of the textures
  49592. * @param format defines the format of the data
  49593. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49594. * @param generateMipMaps defines if the engine should generate the mip levels
  49595. * @param invertY defines if data must be stored with Y axis inverted
  49596. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49597. * @param compression defines the compression used (null by default)
  49598. */
  49599. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49600. /**
  49601. * Updates the raw cube texture.
  49602. * @param data defines the data to store
  49603. * @param format defines the data format
  49604. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49605. * @param invertY defines if data must be stored with Y axis inverted
  49606. * @param compression defines the compression used (null by default)
  49607. * @param level defines which level of the texture to update
  49608. */
  49609. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49610. /**
  49611. * Updates a raw cube texture with RGBD encoded data.
  49612. * @param data defines the array of data [mipmap][face] to use to create each face
  49613. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49614. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49615. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49616. * @returns a promsie that resolves when the operation is complete
  49617. */
  49618. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49619. /**
  49620. * Clones the raw cube texture.
  49621. * @return a new cube texture
  49622. */
  49623. clone(): CubeTexture;
  49624. /** @hidden */
  49625. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49626. }
  49627. }
  49628. declare module BABYLON {
  49629. /**
  49630. * Class used to store 3D textures containing user data
  49631. */
  49632. export class RawTexture3D extends Texture {
  49633. /** Gets or sets the texture format to use */
  49634. format: number;
  49635. private _engine;
  49636. /**
  49637. * Create a new RawTexture3D
  49638. * @param data defines the data of the texture
  49639. * @param width defines the width of the texture
  49640. * @param height defines the height of the texture
  49641. * @param depth defines the depth of the texture
  49642. * @param format defines the texture format to use
  49643. * @param scene defines the hosting scene
  49644. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49645. * @param invertY defines if texture must be stored with Y axis inverted
  49646. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49647. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49648. */
  49649. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49650. /** Gets or sets the texture format to use */
  49651. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49652. /**
  49653. * Update the texture with new data
  49654. * @param data defines the data to store in the texture
  49655. */
  49656. update(data: ArrayBufferView): void;
  49657. }
  49658. }
  49659. declare module BABYLON {
  49660. /**
  49661. * Creates a refraction texture used by refraction channel of the standard material.
  49662. * It is like a mirror but to see through a material.
  49663. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49664. */
  49665. export class RefractionTexture extends RenderTargetTexture {
  49666. /**
  49667. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49668. * 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.
  49669. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49670. */
  49671. refractionPlane: Plane;
  49672. /**
  49673. * Define how deep under the surface we should see.
  49674. */
  49675. depth: number;
  49676. /**
  49677. * Creates a refraction texture used by refraction channel of the standard material.
  49678. * It is like a mirror but to see through a material.
  49679. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49680. * @param name Define the texture name
  49681. * @param size Define the size of the underlying texture
  49682. * @param scene Define the scene the refraction belongs to
  49683. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49684. */
  49685. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49686. /**
  49687. * Clone the refraction texture.
  49688. * @returns the cloned texture
  49689. */
  49690. clone(): RefractionTexture;
  49691. /**
  49692. * Serialize the texture to a JSON representation you could use in Parse later on
  49693. * @returns the serialized JSON representation
  49694. */
  49695. serialize(): any;
  49696. }
  49697. }
  49698. declare module BABYLON {
  49699. /**
  49700. * Defines the options related to the creation of an HtmlElementTexture
  49701. */
  49702. export interface IHtmlElementTextureOptions {
  49703. /**
  49704. * Defines wether mip maps should be created or not.
  49705. */
  49706. generateMipMaps?: boolean;
  49707. /**
  49708. * Defines the sampling mode of the texture.
  49709. */
  49710. samplingMode?: number;
  49711. /**
  49712. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49713. */
  49714. engine: Nullable<Engine>;
  49715. /**
  49716. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49717. */
  49718. scene: Nullable<Scene>;
  49719. }
  49720. /**
  49721. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49722. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49723. * is automatically managed.
  49724. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49725. * in your application.
  49726. *
  49727. * As the update is not automatic, you need to call them manually.
  49728. */
  49729. export class HtmlElementTexture extends BaseTexture {
  49730. /**
  49731. * The texture URL.
  49732. */
  49733. element: HTMLVideoElement | HTMLCanvasElement;
  49734. private static readonly DefaultOptions;
  49735. private _textureMatrix;
  49736. private _engine;
  49737. private _isVideo;
  49738. private _generateMipMaps;
  49739. private _samplingMode;
  49740. /**
  49741. * Instantiates a HtmlElementTexture from the following parameters.
  49742. *
  49743. * @param name Defines the name of the texture
  49744. * @param element Defines the video or canvas the texture is filled with
  49745. * @param options Defines the other none mandatory texture creation options
  49746. */
  49747. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49748. private _createInternalTexture;
  49749. /**
  49750. * Returns the texture matrix used in most of the material.
  49751. */
  49752. getTextureMatrix(): Matrix;
  49753. /**
  49754. * Updates the content of the texture.
  49755. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49756. */
  49757. update(invertY?: Nullable<boolean>): void;
  49758. }
  49759. }
  49760. declare module BABYLON {
  49761. /**
  49762. * Helper class to push actions to a pool of workers.
  49763. */
  49764. export class WorkerPool implements IDisposable {
  49765. private _workerInfos;
  49766. private _pendingActions;
  49767. /**
  49768. * Constructor
  49769. * @param workers Array of workers to use for actions
  49770. */
  49771. constructor(workers: Array<Worker>);
  49772. /**
  49773. * Terminates all workers and clears any pending actions.
  49774. */
  49775. dispose(): void;
  49776. /**
  49777. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49778. * pended until a worker has completed its action.
  49779. * @param action The action to perform. Call onComplete when the action is complete.
  49780. */
  49781. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49782. private _execute;
  49783. }
  49784. }
  49785. declare module BABYLON {
  49786. /**
  49787. * Configuration for Draco compression
  49788. */
  49789. export interface IDracoCompressionConfiguration {
  49790. /**
  49791. * Configuration for the decoder.
  49792. */
  49793. decoder: {
  49794. /**
  49795. * The url to the WebAssembly module.
  49796. */
  49797. wasmUrl?: string;
  49798. /**
  49799. * The url to the WebAssembly binary.
  49800. */
  49801. wasmBinaryUrl?: string;
  49802. /**
  49803. * The url to the fallback JavaScript module.
  49804. */
  49805. fallbackUrl?: string;
  49806. };
  49807. }
  49808. /**
  49809. * Draco compression (https://google.github.io/draco/)
  49810. *
  49811. * This class wraps the Draco module.
  49812. *
  49813. * **Encoder**
  49814. *
  49815. * The encoder is not currently implemented.
  49816. *
  49817. * **Decoder**
  49818. *
  49819. * 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.
  49820. *
  49821. * To update the configuration, use the following code:
  49822. * ```javascript
  49823. * DracoCompression.Configuration = {
  49824. * decoder: {
  49825. * wasmUrl: "<url to the WebAssembly library>",
  49826. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49827. * fallbackUrl: "<url to the fallback JavaScript library>",
  49828. * }
  49829. * };
  49830. * ```
  49831. *
  49832. * 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.
  49833. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49834. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  49835. *
  49836. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  49837. * ```javascript
  49838. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  49839. * ```
  49840. *
  49841. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49842. */
  49843. export class DracoCompression implements IDisposable {
  49844. private _workerPoolPromise?;
  49845. private _decoderModulePromise?;
  49846. /**
  49847. * The configuration. Defaults to the following urls:
  49848. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49849. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49850. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49851. */
  49852. static Configuration: IDracoCompressionConfiguration;
  49853. /**
  49854. * Returns true if the decoder configuration is available.
  49855. */
  49856. static readonly DecoderAvailable: boolean;
  49857. /**
  49858. * Default number of workers to create when creating the draco compression object.
  49859. */
  49860. static DefaultNumWorkers: number;
  49861. private static GetDefaultNumWorkers;
  49862. private static _Default;
  49863. /**
  49864. * Default instance for the draco compression object.
  49865. */
  49866. static readonly Default: DracoCompression;
  49867. /**
  49868. * Constructor
  49869. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  49870. */
  49871. constructor(numWorkers?: number);
  49872. /**
  49873. * Stop all async operations and release resources.
  49874. */
  49875. dispose(): void;
  49876. /**
  49877. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49878. * @returns a promise that resolves when ready
  49879. */
  49880. whenReadyAsync(): Promise<void>;
  49881. /**
  49882. * Decode Draco compressed mesh data to vertex data.
  49883. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49884. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49885. * @returns A promise that resolves with the decoded vertex data
  49886. */
  49887. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49888. [kind: string]: number;
  49889. }): Promise<VertexData>;
  49890. }
  49891. }
  49892. declare module BABYLON {
  49893. /**
  49894. * Class for building Constructive Solid Geometry
  49895. */
  49896. export class CSG {
  49897. private polygons;
  49898. /**
  49899. * The world matrix
  49900. */
  49901. matrix: Matrix;
  49902. /**
  49903. * Stores the position
  49904. */
  49905. position: Vector3;
  49906. /**
  49907. * Stores the rotation
  49908. */
  49909. rotation: Vector3;
  49910. /**
  49911. * Stores the rotation quaternion
  49912. */
  49913. rotationQuaternion: Nullable<Quaternion>;
  49914. /**
  49915. * Stores the scaling vector
  49916. */
  49917. scaling: Vector3;
  49918. /**
  49919. * Convert the Mesh to CSG
  49920. * @param mesh The Mesh to convert to CSG
  49921. * @returns A new CSG from the Mesh
  49922. */
  49923. static FromMesh(mesh: Mesh): CSG;
  49924. /**
  49925. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49926. * @param polygons Polygons used to construct a CSG solid
  49927. */
  49928. private static FromPolygons;
  49929. /**
  49930. * Clones, or makes a deep copy, of the CSG
  49931. * @returns A new CSG
  49932. */
  49933. clone(): CSG;
  49934. /**
  49935. * Unions this CSG with another CSG
  49936. * @param csg The CSG to union against this CSG
  49937. * @returns The unioned CSG
  49938. */
  49939. union(csg: CSG): CSG;
  49940. /**
  49941. * Unions this CSG with another CSG in place
  49942. * @param csg The CSG to union against this CSG
  49943. */
  49944. unionInPlace(csg: CSG): void;
  49945. /**
  49946. * Subtracts this CSG with another CSG
  49947. * @param csg The CSG to subtract against this CSG
  49948. * @returns A new CSG
  49949. */
  49950. subtract(csg: CSG): CSG;
  49951. /**
  49952. * Subtracts this CSG with another CSG in place
  49953. * @param csg The CSG to subtact against this CSG
  49954. */
  49955. subtractInPlace(csg: CSG): void;
  49956. /**
  49957. * Intersect this CSG with another CSG
  49958. * @param csg The CSG to intersect against this CSG
  49959. * @returns A new CSG
  49960. */
  49961. intersect(csg: CSG): CSG;
  49962. /**
  49963. * Intersects this CSG with another CSG in place
  49964. * @param csg The CSG to intersect against this CSG
  49965. */
  49966. intersectInPlace(csg: CSG): void;
  49967. /**
  49968. * Return a new CSG solid with solid and empty space switched. This solid is
  49969. * not modified.
  49970. * @returns A new CSG solid with solid and empty space switched
  49971. */
  49972. inverse(): CSG;
  49973. /**
  49974. * Inverses the CSG in place
  49975. */
  49976. inverseInPlace(): void;
  49977. /**
  49978. * This is used to keep meshes transformations so they can be restored
  49979. * when we build back a Babylon Mesh
  49980. * NB : All CSG operations are performed in world coordinates
  49981. * @param csg The CSG to copy the transform attributes from
  49982. * @returns This CSG
  49983. */
  49984. copyTransformAttributes(csg: CSG): CSG;
  49985. /**
  49986. * Build Raw mesh from CSG
  49987. * Coordinates here are in world space
  49988. * @param name The name of the mesh geometry
  49989. * @param scene The Scene
  49990. * @param keepSubMeshes Specifies if the submeshes should be kept
  49991. * @returns A new Mesh
  49992. */
  49993. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49994. /**
  49995. * Build Mesh from CSG taking material and transforms into account
  49996. * @param name The name of the Mesh
  49997. * @param material The material of the Mesh
  49998. * @param scene The Scene
  49999. * @param keepSubMeshes Specifies if submeshes should be kept
  50000. * @returns The new Mesh
  50001. */
  50002. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50003. }
  50004. }
  50005. declare module BABYLON {
  50006. /**
  50007. * Class used to create a trail following a mesh
  50008. */
  50009. export class TrailMesh extends Mesh {
  50010. private _generator;
  50011. private _autoStart;
  50012. private _running;
  50013. private _diameter;
  50014. private _length;
  50015. private _sectionPolygonPointsCount;
  50016. private _sectionVectors;
  50017. private _sectionNormalVectors;
  50018. private _beforeRenderObserver;
  50019. /**
  50020. * @constructor
  50021. * @param name The value used by scene.getMeshByName() to do a lookup.
  50022. * @param generator The mesh to generate a trail.
  50023. * @param scene The scene to add this mesh to.
  50024. * @param diameter Diameter of trailing mesh. Default is 1.
  50025. * @param length Length of trailing mesh. Default is 60.
  50026. * @param autoStart Automatically start trailing mesh. Default true.
  50027. */
  50028. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50029. /**
  50030. * "TrailMesh"
  50031. * @returns "TrailMesh"
  50032. */
  50033. getClassName(): string;
  50034. private _createMesh;
  50035. /**
  50036. * Start trailing mesh.
  50037. */
  50038. start(): void;
  50039. /**
  50040. * Stop trailing mesh.
  50041. */
  50042. stop(): void;
  50043. /**
  50044. * Update trailing mesh geometry.
  50045. */
  50046. update(): void;
  50047. /**
  50048. * Returns a new TrailMesh object.
  50049. * @param name is a string, the name given to the new mesh
  50050. * @param newGenerator use new generator object for cloned trail mesh
  50051. * @returns a new mesh
  50052. */
  50053. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50054. /**
  50055. * Serializes this trail mesh
  50056. * @param serializationObject object to write serialization to
  50057. */
  50058. serialize(serializationObject: any): void;
  50059. /**
  50060. * Parses a serialized trail mesh
  50061. * @param parsedMesh the serialized mesh
  50062. * @param scene the scene to create the trail mesh in
  50063. * @returns the created trail mesh
  50064. */
  50065. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50066. }
  50067. }
  50068. declare module BABYLON {
  50069. /**
  50070. * Class containing static functions to help procedurally build meshes
  50071. */
  50072. export class TorusKnotBuilder {
  50073. /**
  50074. * Creates a torus knot mesh
  50075. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50076. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50077. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50078. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50080. * * 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
  50081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50082. * @param name defines the name of the mesh
  50083. * @param options defines the options used to create the mesh
  50084. * @param scene defines the hosting scene
  50085. * @returns the torus knot mesh
  50086. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50087. */
  50088. static CreateTorusKnot(name: string, options: {
  50089. radius?: number;
  50090. tube?: number;
  50091. radialSegments?: number;
  50092. tubularSegments?: number;
  50093. p?: number;
  50094. q?: number;
  50095. updatable?: boolean;
  50096. sideOrientation?: number;
  50097. frontUVs?: Vector4;
  50098. backUVs?: Vector4;
  50099. }, scene: any): Mesh;
  50100. }
  50101. }
  50102. declare module BABYLON {
  50103. /**
  50104. * Polygon
  50105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50106. */
  50107. export class Polygon {
  50108. /**
  50109. * Creates a rectangle
  50110. * @param xmin bottom X coord
  50111. * @param ymin bottom Y coord
  50112. * @param xmax top X coord
  50113. * @param ymax top Y coord
  50114. * @returns points that make the resulting rectation
  50115. */
  50116. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50117. /**
  50118. * Creates a circle
  50119. * @param radius radius of circle
  50120. * @param cx scale in x
  50121. * @param cy scale in y
  50122. * @param numberOfSides number of sides that make up the circle
  50123. * @returns points that make the resulting circle
  50124. */
  50125. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50126. /**
  50127. * Creates a polygon from input string
  50128. * @param input Input polygon data
  50129. * @returns the parsed points
  50130. */
  50131. static Parse(input: string): Vector2[];
  50132. /**
  50133. * Starts building a polygon from x and y coordinates
  50134. * @param x x coordinate
  50135. * @param y y coordinate
  50136. * @returns the started path2
  50137. */
  50138. static StartingAt(x: number, y: number): Path2;
  50139. }
  50140. /**
  50141. * Builds a polygon
  50142. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50143. */
  50144. export class PolygonMeshBuilder {
  50145. private _points;
  50146. private _outlinepoints;
  50147. private _holes;
  50148. private _name;
  50149. private _scene;
  50150. private _epoints;
  50151. private _eholes;
  50152. private _addToepoint;
  50153. /**
  50154. * Babylon reference to the earcut plugin.
  50155. */
  50156. bjsEarcut: any;
  50157. /**
  50158. * Creates a PolygonMeshBuilder
  50159. * @param name name of the builder
  50160. * @param contours Path of the polygon
  50161. * @param scene scene to add to when creating the mesh
  50162. * @param earcutInjection can be used to inject your own earcut reference
  50163. */
  50164. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50165. /**
  50166. * Adds a whole within the polygon
  50167. * @param hole Array of points defining the hole
  50168. * @returns this
  50169. */
  50170. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50171. /**
  50172. * Creates the polygon
  50173. * @param updatable If the mesh should be updatable
  50174. * @param depth The depth of the mesh created
  50175. * @returns the created mesh
  50176. */
  50177. build(updatable?: boolean, depth?: number): Mesh;
  50178. /**
  50179. * Creates the polygon
  50180. * @param depth The depth of the mesh created
  50181. * @returns the created VertexData
  50182. */
  50183. buildVertexData(depth?: number): VertexData;
  50184. /**
  50185. * Adds a side to the polygon
  50186. * @param positions points that make the polygon
  50187. * @param normals normals of the polygon
  50188. * @param uvs uvs of the polygon
  50189. * @param indices indices of the polygon
  50190. * @param bounds bounds of the polygon
  50191. * @param points points of the polygon
  50192. * @param depth depth of the polygon
  50193. * @param flip flip of the polygon
  50194. */
  50195. private addSide;
  50196. }
  50197. }
  50198. declare module BABYLON {
  50199. /**
  50200. * Class containing static functions to help procedurally build meshes
  50201. */
  50202. export class PolygonBuilder {
  50203. /**
  50204. * Creates a polygon mesh
  50205. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50206. * * 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
  50207. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50209. * * 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)
  50210. * * Remember you can only change the shape positions, not their number when updating a polygon
  50211. * @param name defines the name of the mesh
  50212. * @param options defines the options used to create the mesh
  50213. * @param scene defines the hosting scene
  50214. * @param earcutInjection can be used to inject your own earcut reference
  50215. * @returns the polygon mesh
  50216. */
  50217. static CreatePolygon(name: string, options: {
  50218. shape: Vector3[];
  50219. holes?: Vector3[][];
  50220. depth?: number;
  50221. faceUV?: Vector4[];
  50222. faceColors?: Color4[];
  50223. updatable?: boolean;
  50224. sideOrientation?: number;
  50225. frontUVs?: Vector4;
  50226. backUVs?: Vector4;
  50227. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50228. /**
  50229. * Creates an extruded polygon mesh, with depth in the Y direction.
  50230. * * 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)
  50231. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50232. * @param name defines the name of the mesh
  50233. * @param options defines the options used to create the mesh
  50234. * @param scene defines the hosting scene
  50235. * @param earcutInjection can be used to inject your own earcut reference
  50236. * @returns the polygon mesh
  50237. */
  50238. static ExtrudePolygon(name: string, options: {
  50239. shape: Vector3[];
  50240. holes?: Vector3[][];
  50241. depth?: number;
  50242. faceUV?: Vector4[];
  50243. faceColors?: Color4[];
  50244. updatable?: boolean;
  50245. sideOrientation?: number;
  50246. frontUVs?: Vector4;
  50247. backUVs?: Vector4;
  50248. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50249. }
  50250. }
  50251. declare module BABYLON {
  50252. /**
  50253. * Class containing static functions to help procedurally build meshes
  50254. */
  50255. export class LatheBuilder {
  50256. /**
  50257. * Creates lathe mesh.
  50258. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50259. * * 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
  50260. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50261. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50262. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50263. * * 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
  50264. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50265. * * 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
  50266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50267. * * 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
  50268. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50270. * @param name defines the name of the mesh
  50271. * @param options defines the options used to create the mesh
  50272. * @param scene defines the hosting scene
  50273. * @returns the lathe mesh
  50274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50275. */
  50276. static CreateLathe(name: string, options: {
  50277. shape: Vector3[];
  50278. radius?: number;
  50279. tessellation?: number;
  50280. clip?: number;
  50281. arc?: number;
  50282. closed?: boolean;
  50283. updatable?: boolean;
  50284. sideOrientation?: number;
  50285. frontUVs?: Vector4;
  50286. backUVs?: Vector4;
  50287. cap?: number;
  50288. invertUV?: boolean;
  50289. }, scene?: Nullable<Scene>): Mesh;
  50290. }
  50291. }
  50292. declare module BABYLON {
  50293. /**
  50294. * Class containing static functions to help procedurally build meshes
  50295. */
  50296. export class TubeBuilder {
  50297. /**
  50298. * Creates a tube mesh.
  50299. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50300. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50301. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50302. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50303. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50304. * * 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)
  50305. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50306. * * 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
  50307. * * 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
  50308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50309. * * 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
  50310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50312. * @param name defines the name of the mesh
  50313. * @param options defines the options used to create the mesh
  50314. * @param scene defines the hosting scene
  50315. * @returns the tube mesh
  50316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50317. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50318. */
  50319. static CreateTube(name: string, options: {
  50320. path: Vector3[];
  50321. radius?: number;
  50322. tessellation?: number;
  50323. radiusFunction?: {
  50324. (i: number, distance: number): number;
  50325. };
  50326. cap?: number;
  50327. arc?: number;
  50328. updatable?: boolean;
  50329. sideOrientation?: number;
  50330. frontUVs?: Vector4;
  50331. backUVs?: Vector4;
  50332. instance?: Mesh;
  50333. invertUV?: boolean;
  50334. }, scene?: Nullable<Scene>): Mesh;
  50335. }
  50336. }
  50337. declare module BABYLON {
  50338. /**
  50339. * Class containing static functions to help procedurally build meshes
  50340. */
  50341. export class IcoSphereBuilder {
  50342. /**
  50343. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50344. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50345. * * 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`)
  50346. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50347. * * 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
  50348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50349. * * 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
  50350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50351. * @param name defines the name of the mesh
  50352. * @param options defines the options used to create the mesh
  50353. * @param scene defines the hosting scene
  50354. * @returns the icosahedron mesh
  50355. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50356. */
  50357. static CreateIcoSphere(name: string, options: {
  50358. radius?: number;
  50359. radiusX?: number;
  50360. radiusY?: number;
  50361. radiusZ?: number;
  50362. flat?: boolean;
  50363. subdivisions?: number;
  50364. sideOrientation?: number;
  50365. frontUVs?: Vector4;
  50366. backUVs?: Vector4;
  50367. updatable?: boolean;
  50368. }, scene?: Nullable<Scene>): Mesh;
  50369. }
  50370. }
  50371. declare module BABYLON {
  50372. /**
  50373. * Class containing static functions to help procedurally build meshes
  50374. */
  50375. export class DecalBuilder {
  50376. /**
  50377. * Creates a decal mesh.
  50378. * 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
  50379. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50380. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50381. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50382. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50383. * @param name defines the name of the mesh
  50384. * @param sourceMesh defines the mesh where the decal must be applied
  50385. * @param options defines the options used to create the mesh
  50386. * @param scene defines the hosting scene
  50387. * @returns the decal mesh
  50388. * @see https://doc.babylonjs.com/how_to/decals
  50389. */
  50390. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50391. position?: Vector3;
  50392. normal?: Vector3;
  50393. size?: Vector3;
  50394. angle?: number;
  50395. }): Mesh;
  50396. }
  50397. }
  50398. declare module BABYLON {
  50399. /**
  50400. * Class containing static functions to help procedurally build meshes
  50401. */
  50402. export class MeshBuilder {
  50403. /**
  50404. * Creates a box mesh
  50405. * * The parameter `size` sets the size (float) of each box side (default 1)
  50406. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50407. * * 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)
  50408. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50410. * * 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
  50411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50412. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50413. * @param name defines the name of the mesh
  50414. * @param options defines the options used to create the mesh
  50415. * @param scene defines the hosting scene
  50416. * @returns the box mesh
  50417. */
  50418. static CreateBox(name: string, options: {
  50419. size?: number;
  50420. width?: number;
  50421. height?: number;
  50422. depth?: number;
  50423. faceUV?: Vector4[];
  50424. faceColors?: Color4[];
  50425. sideOrientation?: number;
  50426. frontUVs?: Vector4;
  50427. backUVs?: Vector4;
  50428. updatable?: boolean;
  50429. }, scene?: Nullable<Scene>): Mesh;
  50430. /**
  50431. * Creates a sphere mesh
  50432. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50433. * * 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`)
  50434. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50435. * * 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
  50436. * * 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)
  50437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50438. * * 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
  50439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50440. * @param name defines the name of the mesh
  50441. * @param options defines the options used to create the mesh
  50442. * @param scene defines the hosting scene
  50443. * @returns the sphere mesh
  50444. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50445. */
  50446. static CreateSphere(name: string, options: {
  50447. segments?: number;
  50448. diameter?: number;
  50449. diameterX?: number;
  50450. diameterY?: number;
  50451. diameterZ?: number;
  50452. arc?: number;
  50453. slice?: number;
  50454. sideOrientation?: number;
  50455. frontUVs?: Vector4;
  50456. backUVs?: Vector4;
  50457. updatable?: boolean;
  50458. }, scene?: Nullable<Scene>): Mesh;
  50459. /**
  50460. * Creates a plane polygonal mesh. By default, this is a disc
  50461. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50462. * * 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
  50463. * * 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
  50464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50465. * * 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
  50466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50467. * @param name defines the name of the mesh
  50468. * @param options defines the options used to create the mesh
  50469. * @param scene defines the hosting scene
  50470. * @returns the plane polygonal mesh
  50471. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50472. */
  50473. static CreateDisc(name: string, options: {
  50474. radius?: number;
  50475. tessellation?: number;
  50476. arc?: number;
  50477. updatable?: boolean;
  50478. sideOrientation?: number;
  50479. frontUVs?: Vector4;
  50480. backUVs?: Vector4;
  50481. }, scene?: Nullable<Scene>): Mesh;
  50482. /**
  50483. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50484. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50485. * * 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`)
  50486. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50487. * * 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
  50488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50489. * * 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
  50490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50491. * @param name defines the name of the mesh
  50492. * @param options defines the options used to create the mesh
  50493. * @param scene defines the hosting scene
  50494. * @returns the icosahedron mesh
  50495. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50496. */
  50497. static CreateIcoSphere(name: string, options: {
  50498. radius?: number;
  50499. radiusX?: number;
  50500. radiusY?: number;
  50501. radiusZ?: number;
  50502. flat?: boolean;
  50503. subdivisions?: number;
  50504. sideOrientation?: number;
  50505. frontUVs?: Vector4;
  50506. backUVs?: Vector4;
  50507. updatable?: boolean;
  50508. }, scene?: Nullable<Scene>): Mesh;
  50509. /**
  50510. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50511. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50512. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50513. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50514. * * 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
  50515. * * 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
  50516. * * 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
  50517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50518. * * 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
  50519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50520. * * 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
  50521. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50522. * * 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
  50523. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50525. * @param name defines the name of the mesh
  50526. * @param options defines the options used to create the mesh
  50527. * @param scene defines the hosting scene
  50528. * @returns the ribbon mesh
  50529. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50530. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50531. */
  50532. static CreateRibbon(name: string, options: {
  50533. pathArray: Vector3[][];
  50534. closeArray?: boolean;
  50535. closePath?: boolean;
  50536. offset?: number;
  50537. updatable?: boolean;
  50538. sideOrientation?: number;
  50539. frontUVs?: Vector4;
  50540. backUVs?: Vector4;
  50541. instance?: Mesh;
  50542. invertUV?: boolean;
  50543. uvs?: Vector2[];
  50544. colors?: Color4[];
  50545. }, scene?: Nullable<Scene>): Mesh;
  50546. /**
  50547. * Creates a cylinder or a cone mesh
  50548. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50549. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50550. * * 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.
  50551. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50552. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50553. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50554. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50555. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50556. * * 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).
  50557. * * 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
  50558. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50559. * * 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
  50560. * * 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.
  50561. * * If `enclose` is false, a ring surface is one element.
  50562. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50563. * * 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
  50564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50565. * * 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
  50566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50567. * @param name defines the name of the mesh
  50568. * @param options defines the options used to create the mesh
  50569. * @param scene defines the hosting scene
  50570. * @returns the cylinder mesh
  50571. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50572. */
  50573. static CreateCylinder(name: string, options: {
  50574. height?: number;
  50575. diameterTop?: number;
  50576. diameterBottom?: number;
  50577. diameter?: number;
  50578. tessellation?: number;
  50579. subdivisions?: number;
  50580. arc?: number;
  50581. faceColors?: Color4[];
  50582. faceUV?: Vector4[];
  50583. updatable?: boolean;
  50584. hasRings?: boolean;
  50585. enclose?: boolean;
  50586. sideOrientation?: number;
  50587. frontUVs?: Vector4;
  50588. backUVs?: Vector4;
  50589. }, scene?: Nullable<Scene>): Mesh;
  50590. /**
  50591. * Creates a torus mesh
  50592. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50593. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50594. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50596. * * 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
  50597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50598. * @param name defines the name of the mesh
  50599. * @param options defines the options used to create the mesh
  50600. * @param scene defines the hosting scene
  50601. * @returns the torus mesh
  50602. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50603. */
  50604. static CreateTorus(name: string, options: {
  50605. diameter?: number;
  50606. thickness?: number;
  50607. tessellation?: number;
  50608. updatable?: boolean;
  50609. sideOrientation?: number;
  50610. frontUVs?: Vector4;
  50611. backUVs?: Vector4;
  50612. }, scene?: Nullable<Scene>): Mesh;
  50613. /**
  50614. * Creates a torus knot mesh
  50615. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50616. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50617. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50618. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50620. * * 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
  50621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50622. * @param name defines the name of the mesh
  50623. * @param options defines the options used to create the mesh
  50624. * @param scene defines the hosting scene
  50625. * @returns the torus knot mesh
  50626. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50627. */
  50628. static CreateTorusKnot(name: string, options: {
  50629. radius?: number;
  50630. tube?: number;
  50631. radialSegments?: number;
  50632. tubularSegments?: number;
  50633. p?: number;
  50634. q?: number;
  50635. updatable?: boolean;
  50636. sideOrientation?: number;
  50637. frontUVs?: Vector4;
  50638. backUVs?: Vector4;
  50639. }, scene?: Nullable<Scene>): Mesh;
  50640. /**
  50641. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50642. * * 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
  50643. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50644. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50645. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50646. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50647. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50648. * * 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
  50649. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50652. * @param name defines the name of the new line system
  50653. * @param options defines the options used to create the line system
  50654. * @param scene defines the hosting scene
  50655. * @returns a new line system mesh
  50656. */
  50657. static CreateLineSystem(name: string, options: {
  50658. lines: Vector3[][];
  50659. updatable?: boolean;
  50660. instance?: Nullable<LinesMesh>;
  50661. colors?: Nullable<Color4[][]>;
  50662. useVertexAlpha?: boolean;
  50663. }, scene: Nullable<Scene>): LinesMesh;
  50664. /**
  50665. * Creates a line mesh
  50666. * 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
  50667. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50668. * * The parameter `points` is an array successive Vector3
  50669. * * 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
  50670. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50671. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50672. * * When updating an instance, remember that only point positions can change, not the number of points
  50673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50675. * @param name defines the name of the new line system
  50676. * @param options defines the options used to create the line system
  50677. * @param scene defines the hosting scene
  50678. * @returns a new line mesh
  50679. */
  50680. static CreateLines(name: string, options: {
  50681. points: Vector3[];
  50682. updatable?: boolean;
  50683. instance?: Nullable<LinesMesh>;
  50684. colors?: Color4[];
  50685. useVertexAlpha?: boolean;
  50686. }, scene?: Nullable<Scene>): LinesMesh;
  50687. /**
  50688. * Creates a dashed line mesh
  50689. * * 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
  50690. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50691. * * The parameter `points` is an array successive Vector3
  50692. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50693. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50694. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50695. * * 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
  50696. * * When updating an instance, remember that only point positions can change, not the number of points
  50697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50698. * @param name defines the name of the mesh
  50699. * @param options defines the options used to create the mesh
  50700. * @param scene defines the hosting scene
  50701. * @returns the dashed line mesh
  50702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50703. */
  50704. static CreateDashedLines(name: string, options: {
  50705. points: Vector3[];
  50706. dashSize?: number;
  50707. gapSize?: number;
  50708. dashNb?: number;
  50709. updatable?: boolean;
  50710. instance?: LinesMesh;
  50711. }, scene?: Nullable<Scene>): LinesMesh;
  50712. /**
  50713. * 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.
  50714. * * 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.
  50715. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50716. * * 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.
  50717. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50718. * * 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
  50719. * * 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
  50720. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50722. * * 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
  50723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50725. * @param name defines the name of the mesh
  50726. * @param options defines the options used to create the mesh
  50727. * @param scene defines the hosting scene
  50728. * @returns the extruded shape mesh
  50729. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50731. */
  50732. static ExtrudeShape(name: string, options: {
  50733. shape: Vector3[];
  50734. path: Vector3[];
  50735. scale?: number;
  50736. rotation?: number;
  50737. cap?: number;
  50738. updatable?: boolean;
  50739. sideOrientation?: number;
  50740. frontUVs?: Vector4;
  50741. backUVs?: Vector4;
  50742. instance?: Mesh;
  50743. invertUV?: boolean;
  50744. }, scene?: Nullable<Scene>): Mesh;
  50745. /**
  50746. * Creates an custom extruded shape mesh.
  50747. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50748. * * 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.
  50749. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50750. * * 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
  50751. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50752. * * 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
  50753. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50754. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50755. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50756. * * 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
  50757. * * 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
  50758. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50760. * * 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
  50761. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50763. * @param name defines the name of the mesh
  50764. * @param options defines the options used to create the mesh
  50765. * @param scene defines the hosting scene
  50766. * @returns the custom extruded shape mesh
  50767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50768. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50769. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50770. */
  50771. static ExtrudeShapeCustom(name: string, options: {
  50772. shape: Vector3[];
  50773. path: Vector3[];
  50774. scaleFunction?: any;
  50775. rotationFunction?: any;
  50776. ribbonCloseArray?: boolean;
  50777. ribbonClosePath?: boolean;
  50778. cap?: number;
  50779. updatable?: boolean;
  50780. sideOrientation?: number;
  50781. frontUVs?: Vector4;
  50782. backUVs?: Vector4;
  50783. instance?: Mesh;
  50784. invertUV?: boolean;
  50785. }, scene?: Nullable<Scene>): Mesh;
  50786. /**
  50787. * Creates lathe mesh.
  50788. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50789. * * 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
  50790. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50791. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50792. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50793. * * 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
  50794. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50795. * * 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
  50796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50797. * * 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
  50798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50800. * @param name defines the name of the mesh
  50801. * @param options defines the options used to create the mesh
  50802. * @param scene defines the hosting scene
  50803. * @returns the lathe mesh
  50804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50805. */
  50806. static CreateLathe(name: string, options: {
  50807. shape: Vector3[];
  50808. radius?: number;
  50809. tessellation?: number;
  50810. clip?: number;
  50811. arc?: number;
  50812. closed?: boolean;
  50813. updatable?: boolean;
  50814. sideOrientation?: number;
  50815. frontUVs?: Vector4;
  50816. backUVs?: Vector4;
  50817. cap?: number;
  50818. invertUV?: boolean;
  50819. }, scene?: Nullable<Scene>): Mesh;
  50820. /**
  50821. * Creates a plane mesh
  50822. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50823. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50824. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50826. * * 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
  50827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50828. * @param name defines the name of the mesh
  50829. * @param options defines the options used to create the mesh
  50830. * @param scene defines the hosting scene
  50831. * @returns the plane mesh
  50832. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50833. */
  50834. static CreatePlane(name: string, options: {
  50835. size?: number;
  50836. width?: number;
  50837. height?: number;
  50838. sideOrientation?: number;
  50839. frontUVs?: Vector4;
  50840. backUVs?: Vector4;
  50841. updatable?: boolean;
  50842. sourcePlane?: Plane;
  50843. }, scene?: Nullable<Scene>): Mesh;
  50844. /**
  50845. * Creates a ground mesh
  50846. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50847. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50849. * @param name defines the name of the mesh
  50850. * @param options defines the options used to create the mesh
  50851. * @param scene defines the hosting scene
  50852. * @returns the ground mesh
  50853. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50854. */
  50855. static CreateGround(name: string, options: {
  50856. width?: number;
  50857. height?: number;
  50858. subdivisions?: number;
  50859. subdivisionsX?: number;
  50860. subdivisionsY?: number;
  50861. updatable?: boolean;
  50862. }, scene?: Nullable<Scene>): Mesh;
  50863. /**
  50864. * Creates a tiled ground mesh
  50865. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50866. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50867. * * 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
  50868. * * 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
  50869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50870. * @param name defines the name of the mesh
  50871. * @param options defines the options used to create the mesh
  50872. * @param scene defines the hosting scene
  50873. * @returns the tiled ground mesh
  50874. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50875. */
  50876. static CreateTiledGround(name: string, options: {
  50877. xmin: number;
  50878. zmin: number;
  50879. xmax: number;
  50880. zmax: number;
  50881. subdivisions?: {
  50882. w: number;
  50883. h: number;
  50884. };
  50885. precision?: {
  50886. w: number;
  50887. h: number;
  50888. };
  50889. updatable?: boolean;
  50890. }, scene?: Nullable<Scene>): Mesh;
  50891. /**
  50892. * Creates a ground mesh from a height map
  50893. * * The parameter `url` sets the URL of the height map image resource.
  50894. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50895. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50896. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50897. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50898. * * 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.
  50899. * * 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).
  50900. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50902. * @param name defines the name of the mesh
  50903. * @param url defines the url to the height map
  50904. * @param options defines the options used to create the mesh
  50905. * @param scene defines the hosting scene
  50906. * @returns the ground mesh
  50907. * @see https://doc.babylonjs.com/babylon101/height_map
  50908. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50909. */
  50910. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50911. width?: number;
  50912. height?: number;
  50913. subdivisions?: number;
  50914. minHeight?: number;
  50915. maxHeight?: number;
  50916. colorFilter?: Color3;
  50917. alphaFilter?: number;
  50918. updatable?: boolean;
  50919. onReady?: (mesh: GroundMesh) => void;
  50920. }, scene?: Nullable<Scene>): GroundMesh;
  50921. /**
  50922. * Creates a polygon mesh
  50923. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50924. * * 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
  50925. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50927. * * 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)
  50928. * * Remember you can only change the shape positions, not their number when updating a polygon
  50929. * @param name defines the name of the mesh
  50930. * @param options defines the options used to create the mesh
  50931. * @param scene defines the hosting scene
  50932. * @param earcutInjection can be used to inject your own earcut reference
  50933. * @returns the polygon mesh
  50934. */
  50935. static CreatePolygon(name: string, options: {
  50936. shape: Vector3[];
  50937. holes?: Vector3[][];
  50938. depth?: number;
  50939. faceUV?: Vector4[];
  50940. faceColors?: Color4[];
  50941. updatable?: boolean;
  50942. sideOrientation?: number;
  50943. frontUVs?: Vector4;
  50944. backUVs?: Vector4;
  50945. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50946. /**
  50947. * Creates an extruded polygon mesh, with depth in the Y direction.
  50948. * * 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)
  50949. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50950. * @param name defines the name of the mesh
  50951. * @param options defines the options used to create the mesh
  50952. * @param scene defines the hosting scene
  50953. * @param earcutInjection can be used to inject your own earcut reference
  50954. * @returns the polygon mesh
  50955. */
  50956. static ExtrudePolygon(name: string, options: {
  50957. shape: Vector3[];
  50958. holes?: Vector3[][];
  50959. depth?: number;
  50960. faceUV?: Vector4[];
  50961. faceColors?: Color4[];
  50962. updatable?: boolean;
  50963. sideOrientation?: number;
  50964. frontUVs?: Vector4;
  50965. backUVs?: Vector4;
  50966. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50967. /**
  50968. * Creates a tube mesh.
  50969. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50970. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50971. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50972. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50973. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50974. * * 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)
  50975. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50976. * * 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
  50977. * * 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
  50978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50979. * * 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
  50980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50982. * @param name defines the name of the mesh
  50983. * @param options defines the options used to create the mesh
  50984. * @param scene defines the hosting scene
  50985. * @returns the tube mesh
  50986. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50987. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50988. */
  50989. static CreateTube(name: string, options: {
  50990. path: Vector3[];
  50991. radius?: number;
  50992. tessellation?: number;
  50993. radiusFunction?: {
  50994. (i: number, distance: number): number;
  50995. };
  50996. cap?: number;
  50997. arc?: number;
  50998. updatable?: boolean;
  50999. sideOrientation?: number;
  51000. frontUVs?: Vector4;
  51001. backUVs?: Vector4;
  51002. instance?: Mesh;
  51003. invertUV?: boolean;
  51004. }, scene?: Nullable<Scene>): Mesh;
  51005. /**
  51006. * Creates a polyhedron mesh
  51007. * * 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
  51008. * * The parameter `size` (positive float, default 1) sets the polygon size
  51009. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51010. * * 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`
  51011. * * 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
  51012. * * 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)`)
  51013. * * 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
  51014. * * 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
  51015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51016. * * 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
  51017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51018. * @param name defines the name of the mesh
  51019. * @param options defines the options used to create the mesh
  51020. * @param scene defines the hosting scene
  51021. * @returns the polyhedron mesh
  51022. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51023. */
  51024. static CreatePolyhedron(name: string, options: {
  51025. type?: number;
  51026. size?: number;
  51027. sizeX?: number;
  51028. sizeY?: number;
  51029. sizeZ?: number;
  51030. custom?: any;
  51031. faceUV?: Vector4[];
  51032. faceColors?: Color4[];
  51033. flat?: boolean;
  51034. updatable?: boolean;
  51035. sideOrientation?: number;
  51036. frontUVs?: Vector4;
  51037. backUVs?: Vector4;
  51038. }, scene?: Nullable<Scene>): Mesh;
  51039. /**
  51040. * Creates a decal mesh.
  51041. * 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
  51042. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51043. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51044. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51045. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51046. * @param name defines the name of the mesh
  51047. * @param sourceMesh defines the mesh where the decal must be applied
  51048. * @param options defines the options used to create the mesh
  51049. * @param scene defines the hosting scene
  51050. * @returns the decal mesh
  51051. * @see https://doc.babylonjs.com/how_to/decals
  51052. */
  51053. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51054. position?: Vector3;
  51055. normal?: Vector3;
  51056. size?: Vector3;
  51057. angle?: number;
  51058. }): Mesh;
  51059. }
  51060. }
  51061. declare module BABYLON {
  51062. /**
  51063. * A simplifier interface for future simplification implementations
  51064. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51065. */
  51066. export interface ISimplifier {
  51067. /**
  51068. * Simplification of a given mesh according to the given settings.
  51069. * Since this requires computation, it is assumed that the function runs async.
  51070. * @param settings The settings of the simplification, including quality and distance
  51071. * @param successCallback A callback that will be called after the mesh was simplified.
  51072. * @param errorCallback in case of an error, this callback will be called. optional.
  51073. */
  51074. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51075. }
  51076. /**
  51077. * Expected simplification settings.
  51078. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51079. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51080. */
  51081. export interface ISimplificationSettings {
  51082. /**
  51083. * Gets or sets the expected quality
  51084. */
  51085. quality: number;
  51086. /**
  51087. * Gets or sets the distance when this optimized version should be used
  51088. */
  51089. distance: number;
  51090. /**
  51091. * Gets an already optimized mesh
  51092. */
  51093. optimizeMesh?: boolean;
  51094. }
  51095. /**
  51096. * Class used to specify simplification options
  51097. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51098. */
  51099. export class SimplificationSettings implements ISimplificationSettings {
  51100. /** expected quality */
  51101. quality: number;
  51102. /** distance when this optimized version should be used */
  51103. distance: number;
  51104. /** already optimized mesh */
  51105. optimizeMesh?: boolean | undefined;
  51106. /**
  51107. * Creates a SimplificationSettings
  51108. * @param quality expected quality
  51109. * @param distance distance when this optimized version should be used
  51110. * @param optimizeMesh already optimized mesh
  51111. */
  51112. constructor(
  51113. /** expected quality */
  51114. quality: number,
  51115. /** distance when this optimized version should be used */
  51116. distance: number,
  51117. /** already optimized mesh */
  51118. optimizeMesh?: boolean | undefined);
  51119. }
  51120. /**
  51121. * Interface used to define a simplification task
  51122. */
  51123. export interface ISimplificationTask {
  51124. /**
  51125. * Array of settings
  51126. */
  51127. settings: Array<ISimplificationSettings>;
  51128. /**
  51129. * Simplification type
  51130. */
  51131. simplificationType: SimplificationType;
  51132. /**
  51133. * Mesh to simplify
  51134. */
  51135. mesh: Mesh;
  51136. /**
  51137. * Callback called on success
  51138. */
  51139. successCallback?: () => void;
  51140. /**
  51141. * Defines if parallel processing can be used
  51142. */
  51143. parallelProcessing: boolean;
  51144. }
  51145. /**
  51146. * Queue used to order the simplification tasks
  51147. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51148. */
  51149. export class SimplificationQueue {
  51150. private _simplificationArray;
  51151. /**
  51152. * Gets a boolean indicating that the process is still running
  51153. */
  51154. running: boolean;
  51155. /**
  51156. * Creates a new queue
  51157. */
  51158. constructor();
  51159. /**
  51160. * Adds a new simplification task
  51161. * @param task defines a task to add
  51162. */
  51163. addTask(task: ISimplificationTask): void;
  51164. /**
  51165. * Execute next task
  51166. */
  51167. executeNext(): void;
  51168. /**
  51169. * Execute a simplification task
  51170. * @param task defines the task to run
  51171. */
  51172. runSimplification(task: ISimplificationTask): void;
  51173. private getSimplifier;
  51174. }
  51175. /**
  51176. * The implemented types of simplification
  51177. * At the moment only Quadratic Error Decimation is implemented
  51178. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51179. */
  51180. export enum SimplificationType {
  51181. /** Quadratic error decimation */
  51182. QUADRATIC = 0
  51183. }
  51184. }
  51185. declare module BABYLON {
  51186. interface Scene {
  51187. /** @hidden (Backing field) */
  51188. _simplificationQueue: SimplificationQueue;
  51189. /**
  51190. * Gets or sets the simplification queue attached to the scene
  51191. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51192. */
  51193. simplificationQueue: SimplificationQueue;
  51194. }
  51195. interface Mesh {
  51196. /**
  51197. * Simplify the mesh according to the given array of settings.
  51198. * Function will return immediately and will simplify async
  51199. * @param settings a collection of simplification settings
  51200. * @param parallelProcessing should all levels calculate parallel or one after the other
  51201. * @param simplificationType the type of simplification to run
  51202. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51203. * @returns the current mesh
  51204. */
  51205. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51206. }
  51207. /**
  51208. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51209. * created in a scene
  51210. */
  51211. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51212. /**
  51213. * The component name helpfull to identify the component in the list of scene components.
  51214. */
  51215. readonly name: string;
  51216. /**
  51217. * The scene the component belongs to.
  51218. */
  51219. scene: Scene;
  51220. /**
  51221. * Creates a new instance of the component for the given scene
  51222. * @param scene Defines the scene to register the component in
  51223. */
  51224. constructor(scene: Scene);
  51225. /**
  51226. * Registers the component in a given scene
  51227. */
  51228. register(): void;
  51229. /**
  51230. * Rebuilds the elements related to this component in case of
  51231. * context lost for instance.
  51232. */
  51233. rebuild(): void;
  51234. /**
  51235. * Disposes the component and the associated ressources
  51236. */
  51237. dispose(): void;
  51238. private _beforeCameraUpdate;
  51239. }
  51240. }
  51241. declare module BABYLON {
  51242. /**
  51243. * Class used to enable access to IndexedDB
  51244. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51245. */
  51246. export class Database implements IOfflineProvider {
  51247. private _callbackManifestChecked;
  51248. private _currentSceneUrl;
  51249. private _db;
  51250. private _enableSceneOffline;
  51251. private _enableTexturesOffline;
  51252. private _manifestVersionFound;
  51253. private _mustUpdateRessources;
  51254. private _hasReachedQuota;
  51255. private _isSupported;
  51256. private _idbFactory;
  51257. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51258. private static IsUASupportingBlobStorage;
  51259. /**
  51260. * Gets a boolean indicating if Database storate is enabled (off by default)
  51261. */
  51262. static IDBStorageEnabled: boolean;
  51263. /**
  51264. * Gets a boolean indicating if scene must be saved in the database
  51265. */
  51266. readonly enableSceneOffline: boolean;
  51267. /**
  51268. * Gets a boolean indicating if textures must be saved in the database
  51269. */
  51270. readonly enableTexturesOffline: boolean;
  51271. /**
  51272. * Creates a new Database
  51273. * @param urlToScene defines the url to load the scene
  51274. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51275. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51276. */
  51277. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51278. private static _ParseURL;
  51279. private static _ReturnFullUrlLocation;
  51280. private _checkManifestFile;
  51281. /**
  51282. * Open the database and make it available
  51283. * @param successCallback defines the callback to call on success
  51284. * @param errorCallback defines the callback to call on error
  51285. */
  51286. open(successCallback: () => void, errorCallback: () => void): void;
  51287. /**
  51288. * Loads an image from the database
  51289. * @param url defines the url to load from
  51290. * @param image defines the target DOM image
  51291. */
  51292. loadImage(url: string, image: HTMLImageElement): void;
  51293. private _loadImageFromDBAsync;
  51294. private _saveImageIntoDBAsync;
  51295. private _checkVersionFromDB;
  51296. private _loadVersionFromDBAsync;
  51297. private _saveVersionIntoDBAsync;
  51298. /**
  51299. * Loads a file from database
  51300. * @param url defines the URL to load from
  51301. * @param sceneLoaded defines a callback to call on success
  51302. * @param progressCallBack defines a callback to call when progress changed
  51303. * @param errorCallback defines a callback to call on error
  51304. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51305. */
  51306. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51307. private _loadFileAsync;
  51308. private _saveFileAsync;
  51309. /**
  51310. * Validates if xhr data is correct
  51311. * @param xhr defines the request to validate
  51312. * @param dataType defines the expected data type
  51313. * @returns true if data is correct
  51314. */
  51315. private static _ValidateXHRData;
  51316. }
  51317. }
  51318. declare module BABYLON {
  51319. /** @hidden */
  51320. export var gpuUpdateParticlesPixelShader: {
  51321. name: string;
  51322. shader: string;
  51323. };
  51324. }
  51325. declare module BABYLON {
  51326. /** @hidden */
  51327. export var gpuUpdateParticlesVertexShader: {
  51328. name: string;
  51329. shader: string;
  51330. };
  51331. }
  51332. declare module BABYLON {
  51333. /** @hidden */
  51334. export var clipPlaneFragmentDeclaration2: {
  51335. name: string;
  51336. shader: string;
  51337. };
  51338. }
  51339. declare module BABYLON {
  51340. /** @hidden */
  51341. export var gpuRenderParticlesPixelShader: {
  51342. name: string;
  51343. shader: string;
  51344. };
  51345. }
  51346. declare module BABYLON {
  51347. /** @hidden */
  51348. export var clipPlaneVertexDeclaration2: {
  51349. name: string;
  51350. shader: string;
  51351. };
  51352. }
  51353. declare module BABYLON {
  51354. /** @hidden */
  51355. export var gpuRenderParticlesVertexShader: {
  51356. name: string;
  51357. shader: string;
  51358. };
  51359. }
  51360. declare module BABYLON {
  51361. /**
  51362. * This represents a GPU particle system in Babylon
  51363. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51364. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51365. */
  51366. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51367. /**
  51368. * The layer mask we are rendering the particles through.
  51369. */
  51370. layerMask: number;
  51371. private _capacity;
  51372. private _activeCount;
  51373. private _currentActiveCount;
  51374. private _accumulatedCount;
  51375. private _renderEffect;
  51376. private _updateEffect;
  51377. private _buffer0;
  51378. private _buffer1;
  51379. private _spriteBuffer;
  51380. private _updateVAO;
  51381. private _renderVAO;
  51382. private _targetIndex;
  51383. private _sourceBuffer;
  51384. private _targetBuffer;
  51385. private _engine;
  51386. private _currentRenderId;
  51387. private _started;
  51388. private _stopped;
  51389. private _timeDelta;
  51390. private _randomTexture;
  51391. private _randomTexture2;
  51392. private _attributesStrideSize;
  51393. private _updateEffectOptions;
  51394. private _randomTextureSize;
  51395. private _actualFrame;
  51396. private readonly _rawTextureWidth;
  51397. /**
  51398. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51399. */
  51400. static readonly IsSupported: boolean;
  51401. /**
  51402. * An event triggered when the system is disposed.
  51403. */
  51404. onDisposeObservable: Observable<GPUParticleSystem>;
  51405. /**
  51406. * Gets the maximum number of particles active at the same time.
  51407. * @returns The max number of active particles.
  51408. */
  51409. getCapacity(): number;
  51410. /**
  51411. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51412. * to override the particles.
  51413. */
  51414. forceDepthWrite: boolean;
  51415. /**
  51416. * Gets or set the number of active particles
  51417. */
  51418. activeParticleCount: number;
  51419. private _preWarmDone;
  51420. /**
  51421. * Is this system ready to be used/rendered
  51422. * @return true if the system is ready
  51423. */
  51424. isReady(): boolean;
  51425. /**
  51426. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51427. * @returns True if it has been started, otherwise false.
  51428. */
  51429. isStarted(): boolean;
  51430. /**
  51431. * Starts the particle system and begins to emit
  51432. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51433. */
  51434. start(delay?: number): void;
  51435. /**
  51436. * Stops the particle system.
  51437. */
  51438. stop(): void;
  51439. /**
  51440. * Remove all active particles
  51441. */
  51442. reset(): void;
  51443. /**
  51444. * Returns the string "GPUParticleSystem"
  51445. * @returns a string containing the class name
  51446. */
  51447. getClassName(): string;
  51448. private _colorGradientsTexture;
  51449. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51450. /**
  51451. * Adds a new color gradient
  51452. * @param gradient defines the gradient to use (between 0 and 1)
  51453. * @param color1 defines the color to affect to the specified gradient
  51454. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51455. * @returns the current particle system
  51456. */
  51457. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51458. /**
  51459. * Remove a specific color gradient
  51460. * @param gradient defines the gradient to remove
  51461. * @returns the current particle system
  51462. */
  51463. removeColorGradient(gradient: number): GPUParticleSystem;
  51464. private _angularSpeedGradientsTexture;
  51465. private _sizeGradientsTexture;
  51466. private _velocityGradientsTexture;
  51467. private _limitVelocityGradientsTexture;
  51468. private _dragGradientsTexture;
  51469. private _addFactorGradient;
  51470. /**
  51471. * Adds a new size gradient
  51472. * @param gradient defines the gradient to use (between 0 and 1)
  51473. * @param factor defines the size factor to affect to the specified gradient
  51474. * @returns the current particle system
  51475. */
  51476. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51477. /**
  51478. * Remove a specific size gradient
  51479. * @param gradient defines the gradient to remove
  51480. * @returns the current particle system
  51481. */
  51482. removeSizeGradient(gradient: number): GPUParticleSystem;
  51483. /**
  51484. * Adds a new angular speed gradient
  51485. * @param gradient defines the gradient to use (between 0 and 1)
  51486. * @param factor defines the angular speed to affect to the specified gradient
  51487. * @returns the current particle system
  51488. */
  51489. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51490. /**
  51491. * Remove a specific angular speed gradient
  51492. * @param gradient defines the gradient to remove
  51493. * @returns the current particle system
  51494. */
  51495. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51496. /**
  51497. * Adds a new velocity gradient
  51498. * @param gradient defines the gradient to use (between 0 and 1)
  51499. * @param factor defines the velocity to affect to the specified gradient
  51500. * @returns the current particle system
  51501. */
  51502. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51503. /**
  51504. * Remove a specific velocity gradient
  51505. * @param gradient defines the gradient to remove
  51506. * @returns the current particle system
  51507. */
  51508. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51509. /**
  51510. * Adds a new limit velocity gradient
  51511. * @param gradient defines the gradient to use (between 0 and 1)
  51512. * @param factor defines the limit velocity value to affect to the specified gradient
  51513. * @returns the current particle system
  51514. */
  51515. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51516. /**
  51517. * Remove a specific limit velocity gradient
  51518. * @param gradient defines the gradient to remove
  51519. * @returns the current particle system
  51520. */
  51521. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51522. /**
  51523. * Adds a new drag gradient
  51524. * @param gradient defines the gradient to use (between 0 and 1)
  51525. * @param factor defines the drag value to affect to the specified gradient
  51526. * @returns the current particle system
  51527. */
  51528. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51529. /**
  51530. * Remove a specific drag gradient
  51531. * @param gradient defines the gradient to remove
  51532. * @returns the current particle system
  51533. */
  51534. removeDragGradient(gradient: number): GPUParticleSystem;
  51535. /**
  51536. * Not supported by GPUParticleSystem
  51537. * @param gradient defines the gradient to use (between 0 and 1)
  51538. * @param factor defines the emit rate value to affect to the specified gradient
  51539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51540. * @returns the current particle system
  51541. */
  51542. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51543. /**
  51544. * Not supported by GPUParticleSystem
  51545. * @param gradient defines the gradient to remove
  51546. * @returns the current particle system
  51547. */
  51548. removeEmitRateGradient(gradient: number): IParticleSystem;
  51549. /**
  51550. * Not supported by GPUParticleSystem
  51551. * @param gradient defines the gradient to use (between 0 and 1)
  51552. * @param factor defines the start size value to affect to the specified gradient
  51553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51554. * @returns the current particle system
  51555. */
  51556. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51557. /**
  51558. * Not supported by GPUParticleSystem
  51559. * @param gradient defines the gradient to remove
  51560. * @returns the current particle system
  51561. */
  51562. removeStartSizeGradient(gradient: number): IParticleSystem;
  51563. /**
  51564. * Not supported by GPUParticleSystem
  51565. * @param gradient defines the gradient to use (between 0 and 1)
  51566. * @param min defines the color remap minimal range
  51567. * @param max defines the color remap maximal range
  51568. * @returns the current particle system
  51569. */
  51570. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51571. /**
  51572. * Not supported by GPUParticleSystem
  51573. * @param gradient defines the gradient to remove
  51574. * @returns the current particle system
  51575. */
  51576. removeColorRemapGradient(): IParticleSystem;
  51577. /**
  51578. * Not supported by GPUParticleSystem
  51579. * @param gradient defines the gradient to use (between 0 and 1)
  51580. * @param min defines the alpha remap minimal range
  51581. * @param max defines the alpha remap maximal range
  51582. * @returns the current particle system
  51583. */
  51584. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51585. /**
  51586. * Not supported by GPUParticleSystem
  51587. * @param gradient defines the gradient to remove
  51588. * @returns the current particle system
  51589. */
  51590. removeAlphaRemapGradient(): IParticleSystem;
  51591. /**
  51592. * Not supported by GPUParticleSystem
  51593. * @param gradient defines the gradient to use (between 0 and 1)
  51594. * @param color defines the color to affect to the specified gradient
  51595. * @returns the current particle system
  51596. */
  51597. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51598. /**
  51599. * Not supported by GPUParticleSystem
  51600. * @param gradient defines the gradient to remove
  51601. * @returns the current particle system
  51602. */
  51603. removeRampGradient(): IParticleSystem;
  51604. /**
  51605. * Not supported by GPUParticleSystem
  51606. * @returns the list of ramp gradients
  51607. */
  51608. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51609. /**
  51610. * Not supported by GPUParticleSystem
  51611. * Gets or sets a boolean indicating that ramp gradients must be used
  51612. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51613. */
  51614. useRampGradients: boolean;
  51615. /**
  51616. * Not supported by GPUParticleSystem
  51617. * @param gradient defines the gradient to use (between 0 and 1)
  51618. * @param factor defines the life time factor to affect to the specified gradient
  51619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51620. * @returns the current particle system
  51621. */
  51622. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51623. /**
  51624. * Not supported by GPUParticleSystem
  51625. * @param gradient defines the gradient to remove
  51626. * @returns the current particle system
  51627. */
  51628. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51629. /**
  51630. * Instantiates a GPU particle system.
  51631. * 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.
  51632. * @param name The name of the particle system
  51633. * @param options The options used to create the system
  51634. * @param scene The scene the particle system belongs to
  51635. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51636. */
  51637. constructor(name: string, options: Partial<{
  51638. capacity: number;
  51639. randomTextureSize: number;
  51640. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51641. protected _reset(): void;
  51642. private _createUpdateVAO;
  51643. private _createRenderVAO;
  51644. private _initialize;
  51645. /** @hidden */
  51646. _recreateUpdateEffect(): void;
  51647. /** @hidden */
  51648. _recreateRenderEffect(): void;
  51649. /**
  51650. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51651. * @param preWarm defines if we are in the pre-warmimg phase
  51652. */
  51653. animate(preWarm?: boolean): void;
  51654. private _createFactorGradientTexture;
  51655. private _createSizeGradientTexture;
  51656. private _createAngularSpeedGradientTexture;
  51657. private _createVelocityGradientTexture;
  51658. private _createLimitVelocityGradientTexture;
  51659. private _createDragGradientTexture;
  51660. private _createColorGradientTexture;
  51661. /**
  51662. * Renders the particle system in its current state
  51663. * @param preWarm defines if the system should only update the particles but not render them
  51664. * @returns the current number of particles
  51665. */
  51666. render(preWarm?: boolean): number;
  51667. /**
  51668. * Rebuilds the particle system
  51669. */
  51670. rebuild(): void;
  51671. private _releaseBuffers;
  51672. private _releaseVAOs;
  51673. /**
  51674. * Disposes the particle system and free the associated resources
  51675. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51676. */
  51677. dispose(disposeTexture?: boolean): void;
  51678. /**
  51679. * Clones the particle system.
  51680. * @param name The name of the cloned object
  51681. * @param newEmitter The new emitter to use
  51682. * @returns the cloned particle system
  51683. */
  51684. clone(name: string, newEmitter: any): GPUParticleSystem;
  51685. /**
  51686. * Serializes the particle system to a JSON object.
  51687. * @returns the JSON object
  51688. */
  51689. serialize(): any;
  51690. /**
  51691. * Parses a JSON object to create a GPU particle system.
  51692. * @param parsedParticleSystem The JSON object to parse
  51693. * @param scene The scene to create the particle system in
  51694. * @param rootUrl The root url to use to load external dependencies like texture
  51695. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51696. * @returns the parsed GPU particle system
  51697. */
  51698. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51699. }
  51700. }
  51701. declare module BABYLON {
  51702. /**
  51703. * Represents a set of particle systems working together to create a specific effect
  51704. */
  51705. export class ParticleSystemSet implements IDisposable {
  51706. private _emitterCreationOptions;
  51707. private _emitterNode;
  51708. /**
  51709. * Gets the particle system list
  51710. */
  51711. systems: IParticleSystem[];
  51712. /**
  51713. * Gets the emitter node used with this set
  51714. */
  51715. readonly emitterNode: Nullable<TransformNode>;
  51716. /**
  51717. * Creates a new emitter mesh as a sphere
  51718. * @param options defines the options used to create the sphere
  51719. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51720. * @param scene defines the hosting scene
  51721. */
  51722. setEmitterAsSphere(options: {
  51723. diameter: number;
  51724. segments: number;
  51725. color: Color3;
  51726. }, renderingGroupId: number, scene: Scene): void;
  51727. /**
  51728. * Starts all particle systems of the set
  51729. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51730. */
  51731. start(emitter?: AbstractMesh): void;
  51732. /**
  51733. * Release all associated resources
  51734. */
  51735. dispose(): void;
  51736. /**
  51737. * Serialize the set into a JSON compatible object
  51738. * @returns a JSON compatible representation of the set
  51739. */
  51740. serialize(): any;
  51741. /**
  51742. * Parse a new ParticleSystemSet from a serialized source
  51743. * @param data defines a JSON compatible representation of the set
  51744. * @param scene defines the hosting scene
  51745. * @param gpu defines if we want GPU particles or CPU particles
  51746. * @returns a new ParticleSystemSet
  51747. */
  51748. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51749. }
  51750. }
  51751. declare module BABYLON {
  51752. /**
  51753. * This class is made for on one-liner static method to help creating particle system set.
  51754. */
  51755. export class ParticleHelper {
  51756. /**
  51757. * Gets or sets base Assets URL
  51758. */
  51759. static BaseAssetsUrl: string;
  51760. /**
  51761. * Create a default particle system that you can tweak
  51762. * @param emitter defines the emitter to use
  51763. * @param capacity defines the system capacity (default is 500 particles)
  51764. * @param scene defines the hosting scene
  51765. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51766. * @returns the new Particle system
  51767. */
  51768. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51769. /**
  51770. * This is the main static method (one-liner) of this helper to create different particle systems
  51771. * @param type This string represents the type to the particle system to create
  51772. * @param scene The scene where the particle system should live
  51773. * @param gpu If the system will use gpu
  51774. * @returns the ParticleSystemSet created
  51775. */
  51776. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51777. /**
  51778. * Static function used to export a particle system to a ParticleSystemSet variable.
  51779. * Please note that the emitter shape is not exported
  51780. * @param systems defines the particle systems to export
  51781. * @returns the created particle system set
  51782. */
  51783. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51784. }
  51785. }
  51786. declare module BABYLON {
  51787. interface Engine {
  51788. /**
  51789. * Create an effect to use with particle systems.
  51790. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51791. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51792. * @param uniformsNames defines a list of attribute names
  51793. * @param samplers defines an array of string used to represent textures
  51794. * @param defines defines the string containing the defines to use to compile the shaders
  51795. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51796. * @param onCompiled defines a function to call when the effect creation is successful
  51797. * @param onError defines a function to call when the effect creation has failed
  51798. * @returns the new Effect
  51799. */
  51800. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51801. }
  51802. interface Mesh {
  51803. /**
  51804. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51805. * @returns an array of IParticleSystem
  51806. */
  51807. getEmittedParticleSystems(): IParticleSystem[];
  51808. /**
  51809. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51810. * @returns an array of IParticleSystem
  51811. */
  51812. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51813. }
  51814. /**
  51815. * @hidden
  51816. */
  51817. export var _IDoNeedToBeInTheBuild: number;
  51818. }
  51819. declare module BABYLON {
  51820. interface Scene {
  51821. /** @hidden (Backing field) */
  51822. _physicsEngine: Nullable<IPhysicsEngine>;
  51823. /**
  51824. * Gets the current physics engine
  51825. * @returns a IPhysicsEngine or null if none attached
  51826. */
  51827. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51828. /**
  51829. * Enables physics to the current scene
  51830. * @param gravity defines the scene's gravity for the physics engine
  51831. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51832. * @return a boolean indicating if the physics engine was initialized
  51833. */
  51834. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51835. /**
  51836. * Disables and disposes the physics engine associated with the scene
  51837. */
  51838. disablePhysicsEngine(): void;
  51839. /**
  51840. * Gets a boolean indicating if there is an active physics engine
  51841. * @returns a boolean indicating if there is an active physics engine
  51842. */
  51843. isPhysicsEnabled(): boolean;
  51844. /**
  51845. * Deletes a physics compound impostor
  51846. * @param compound defines the compound to delete
  51847. */
  51848. deleteCompoundImpostor(compound: any): void;
  51849. /**
  51850. * An event triggered when physic simulation is about to be run
  51851. */
  51852. onBeforePhysicsObservable: Observable<Scene>;
  51853. /**
  51854. * An event triggered when physic simulation has been done
  51855. */
  51856. onAfterPhysicsObservable: Observable<Scene>;
  51857. }
  51858. interface AbstractMesh {
  51859. /** @hidden */
  51860. _physicsImpostor: Nullable<PhysicsImpostor>;
  51861. /**
  51862. * Gets or sets impostor used for physic simulation
  51863. * @see http://doc.babylonjs.com/features/physics_engine
  51864. */
  51865. physicsImpostor: Nullable<PhysicsImpostor>;
  51866. /**
  51867. * Gets the current physics impostor
  51868. * @see http://doc.babylonjs.com/features/physics_engine
  51869. * @returns a physics impostor or null
  51870. */
  51871. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51872. /** Apply a physic impulse to the mesh
  51873. * @param force defines the force to apply
  51874. * @param contactPoint defines where to apply the force
  51875. * @returns the current mesh
  51876. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51877. */
  51878. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51879. /**
  51880. * Creates a physic joint between two meshes
  51881. * @param otherMesh defines the other mesh to use
  51882. * @param pivot1 defines the pivot to use on this mesh
  51883. * @param pivot2 defines the pivot to use on the other mesh
  51884. * @param options defines additional options (can be plugin dependent)
  51885. * @returns the current mesh
  51886. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51887. */
  51888. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51889. /** @hidden */
  51890. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51891. }
  51892. /**
  51893. * Defines the physics engine scene component responsible to manage a physics engine
  51894. */
  51895. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51896. /**
  51897. * The component name helpful to identify the component in the list of scene components.
  51898. */
  51899. readonly name: string;
  51900. /**
  51901. * The scene the component belongs to.
  51902. */
  51903. scene: Scene;
  51904. /**
  51905. * Creates a new instance of the component for the given scene
  51906. * @param scene Defines the scene to register the component in
  51907. */
  51908. constructor(scene: Scene);
  51909. /**
  51910. * Registers the component in a given scene
  51911. */
  51912. register(): void;
  51913. /**
  51914. * Rebuilds the elements related to this component in case of
  51915. * context lost for instance.
  51916. */
  51917. rebuild(): void;
  51918. /**
  51919. * Disposes the component and the associated ressources
  51920. */
  51921. dispose(): void;
  51922. }
  51923. }
  51924. declare module BABYLON {
  51925. /**
  51926. * A helper for physics simulations
  51927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51928. */
  51929. export class PhysicsHelper {
  51930. private _scene;
  51931. private _physicsEngine;
  51932. /**
  51933. * Initializes the Physics helper
  51934. * @param scene Babylon.js scene
  51935. */
  51936. constructor(scene: Scene);
  51937. /**
  51938. * Applies a radial explosion impulse
  51939. * @param origin the origin of the explosion
  51940. * @param radiusOrEventOptions the radius or the options of radial explosion
  51941. * @param strength the explosion strength
  51942. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51943. * @returns A physics radial explosion event, or null
  51944. */
  51945. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51946. /**
  51947. * Applies a radial explosion force
  51948. * @param origin the origin of the explosion
  51949. * @param radiusOrEventOptions the radius or the options of radial explosion
  51950. * @param strength the explosion strength
  51951. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51952. * @returns A physics radial explosion event, or null
  51953. */
  51954. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51955. /**
  51956. * Creates a gravitational field
  51957. * @param origin the origin of the explosion
  51958. * @param radiusOrEventOptions the radius or the options of radial explosion
  51959. * @param strength the explosion strength
  51960. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51961. * @returns A physics gravitational field event, or null
  51962. */
  51963. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51964. /**
  51965. * Creates a physics updraft event
  51966. * @param origin the origin of the updraft
  51967. * @param radiusOrEventOptions the radius or the options of the updraft
  51968. * @param strength the strength of the updraft
  51969. * @param height the height of the updraft
  51970. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51971. * @returns A physics updraft event, or null
  51972. */
  51973. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51974. /**
  51975. * Creates a physics vortex event
  51976. * @param origin the of the vortex
  51977. * @param radiusOrEventOptions the radius or the options of the vortex
  51978. * @param strength the strength of the vortex
  51979. * @param height the height of the vortex
  51980. * @returns a Physics vortex event, or null
  51981. * A physics vortex event or null
  51982. */
  51983. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51984. }
  51985. /**
  51986. * Represents a physics radial explosion event
  51987. */
  51988. class PhysicsRadialExplosionEvent {
  51989. private _scene;
  51990. private _options;
  51991. private _sphere;
  51992. private _dataFetched;
  51993. /**
  51994. * Initializes a radial explosioin event
  51995. * @param _scene BabylonJS scene
  51996. * @param _options The options for the vortex event
  51997. */
  51998. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51999. /**
  52000. * Returns the data related to the radial explosion event (sphere).
  52001. * @returns The radial explosion event data
  52002. */
  52003. getData(): PhysicsRadialExplosionEventData;
  52004. /**
  52005. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52006. * @param impostor A physics imposter
  52007. * @param origin the origin of the explosion
  52008. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  52009. */
  52010. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  52011. /**
  52012. * Triggers affecterd impostors callbacks
  52013. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  52014. */
  52015. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  52016. /**
  52017. * Disposes the sphere.
  52018. * @param force Specifies if the sphere should be disposed by force
  52019. */
  52020. dispose(force?: boolean): void;
  52021. /*** Helpers ***/
  52022. private _prepareSphere;
  52023. private _intersectsWithSphere;
  52024. }
  52025. /**
  52026. * Represents a gravitational field event
  52027. */
  52028. class PhysicsGravitationalFieldEvent {
  52029. private _physicsHelper;
  52030. private _scene;
  52031. private _origin;
  52032. private _options;
  52033. private _tickCallback;
  52034. private _sphere;
  52035. private _dataFetched;
  52036. /**
  52037. * Initializes the physics gravitational field event
  52038. * @param _physicsHelper A physics helper
  52039. * @param _scene BabylonJS scene
  52040. * @param _origin The origin position of the gravitational field event
  52041. * @param _options The options for the vortex event
  52042. */
  52043. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52044. /**
  52045. * Returns the data related to the gravitational field event (sphere).
  52046. * @returns A gravitational field event
  52047. */
  52048. getData(): PhysicsGravitationalFieldEventData;
  52049. /**
  52050. * Enables the gravitational field.
  52051. */
  52052. enable(): void;
  52053. /**
  52054. * Disables the gravitational field.
  52055. */
  52056. disable(): void;
  52057. /**
  52058. * Disposes the sphere.
  52059. * @param force The force to dispose from the gravitational field event
  52060. */
  52061. dispose(force?: boolean): void;
  52062. private _tick;
  52063. }
  52064. /**
  52065. * Represents a physics updraft event
  52066. */
  52067. class PhysicsUpdraftEvent {
  52068. private _scene;
  52069. private _origin;
  52070. private _options;
  52071. private _physicsEngine;
  52072. private _originTop;
  52073. private _originDirection;
  52074. private _tickCallback;
  52075. private _cylinder;
  52076. private _cylinderPosition;
  52077. private _dataFetched;
  52078. /**
  52079. * Initializes the physics updraft event
  52080. * @param _scene BabylonJS scene
  52081. * @param _origin The origin position of the updraft
  52082. * @param _options The options for the updraft event
  52083. */
  52084. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52085. /**
  52086. * Returns the data related to the updraft event (cylinder).
  52087. * @returns A physics updraft event
  52088. */
  52089. getData(): PhysicsUpdraftEventData;
  52090. /**
  52091. * Enables the updraft.
  52092. */
  52093. enable(): void;
  52094. /**
  52095. * Disables the updraft.
  52096. */
  52097. disable(): void;
  52098. /**
  52099. * Disposes the cylinder.
  52100. * @param force Specifies if the updraft should be disposed by force
  52101. */
  52102. dispose(force?: boolean): void;
  52103. private getImpostorHitData;
  52104. private _tick;
  52105. /*** Helpers ***/
  52106. private _prepareCylinder;
  52107. private _intersectsWithCylinder;
  52108. }
  52109. /**
  52110. * Represents a physics vortex event
  52111. */
  52112. class PhysicsVortexEvent {
  52113. private _scene;
  52114. private _origin;
  52115. private _options;
  52116. private _physicsEngine;
  52117. private _originTop;
  52118. private _tickCallback;
  52119. private _cylinder;
  52120. private _cylinderPosition;
  52121. private _dataFetched;
  52122. /**
  52123. * Initializes the physics vortex event
  52124. * @param _scene The BabylonJS scene
  52125. * @param _origin The origin position of the vortex
  52126. * @param _options The options for the vortex event
  52127. */
  52128. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52129. /**
  52130. * Returns the data related to the vortex event (cylinder).
  52131. * @returns The physics vortex event data
  52132. */
  52133. getData(): PhysicsVortexEventData;
  52134. /**
  52135. * Enables the vortex.
  52136. */
  52137. enable(): void;
  52138. /**
  52139. * Disables the cortex.
  52140. */
  52141. disable(): void;
  52142. /**
  52143. * Disposes the sphere.
  52144. * @param force
  52145. */
  52146. dispose(force?: boolean): void;
  52147. private getImpostorHitData;
  52148. private _tick;
  52149. /*** Helpers ***/
  52150. private _prepareCylinder;
  52151. private _intersectsWithCylinder;
  52152. }
  52153. /**
  52154. * Options fot the radial explosion event
  52155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52156. */
  52157. export class PhysicsRadialExplosionEventOptions {
  52158. /**
  52159. * The radius of the sphere for the radial explosion.
  52160. */
  52161. radius: number;
  52162. /**
  52163. * The strenth of the explosion.
  52164. */
  52165. strength: number;
  52166. /**
  52167. * The strenght of the force in correspondence to the distance of the affected object
  52168. */
  52169. falloff: PhysicsRadialImpulseFalloff;
  52170. /**
  52171. * Sphere options for the radial explosion.
  52172. */
  52173. sphere: {
  52174. segments: number;
  52175. diameter: number;
  52176. };
  52177. /**
  52178. * Sphere options for the radial explosion.
  52179. */
  52180. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  52181. }
  52182. /**
  52183. * Options fot the updraft event
  52184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52185. */
  52186. export class PhysicsUpdraftEventOptions {
  52187. /**
  52188. * The radius of the cylinder for the vortex
  52189. */
  52190. radius: number;
  52191. /**
  52192. * The strenth of the updraft.
  52193. */
  52194. strength: number;
  52195. /**
  52196. * The height of the cylinder for the updraft.
  52197. */
  52198. height: number;
  52199. /**
  52200. * The mode for the the updraft.
  52201. */
  52202. updraftMode: PhysicsUpdraftMode;
  52203. }
  52204. /**
  52205. * Options fot the vortex event
  52206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52207. */
  52208. export class PhysicsVortexEventOptions {
  52209. /**
  52210. * The radius of the cylinder for the vortex
  52211. */
  52212. radius: number;
  52213. /**
  52214. * The strenth of the vortex.
  52215. */
  52216. strength: number;
  52217. /**
  52218. * The height of the cylinder for the vortex.
  52219. */
  52220. height: number;
  52221. /**
  52222. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52223. */
  52224. centripetalForceThreshold: number;
  52225. /**
  52226. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52227. */
  52228. centripetalForceMultiplier: number;
  52229. /**
  52230. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52231. */
  52232. centrifugalForceMultiplier: number;
  52233. /**
  52234. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52235. */
  52236. updraftForceMultiplier: number;
  52237. }
  52238. /**
  52239. * The strenght of the force in correspondence to the distance of the affected object
  52240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52241. */
  52242. export enum PhysicsRadialImpulseFalloff {
  52243. /** Defines that impulse is constant in strength across it's whole radius */
  52244. Constant = 0,
  52245. /** Defines that impulse gets weaker if it's further from the origin */
  52246. Linear = 1
  52247. }
  52248. /**
  52249. * The strength of the force in correspondence to the distance of the affected object
  52250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52251. */
  52252. export enum PhysicsUpdraftMode {
  52253. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52254. Center = 0,
  52255. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52256. Perpendicular = 1
  52257. }
  52258. /**
  52259. * Interface for a physics hit data
  52260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52261. */
  52262. export interface PhysicsHitData {
  52263. /**
  52264. * The force applied at the contact point
  52265. */
  52266. force: Vector3;
  52267. /**
  52268. * The contact point
  52269. */
  52270. contactPoint: Vector3;
  52271. /**
  52272. * The distance from the origin to the contact point
  52273. */
  52274. distanceFromOrigin: number;
  52275. }
  52276. /**
  52277. * Interface for radial explosion event data
  52278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52279. */
  52280. export interface PhysicsRadialExplosionEventData {
  52281. /**
  52282. * A sphere used for the radial explosion event
  52283. */
  52284. sphere: Mesh;
  52285. }
  52286. /**
  52287. * Interface for gravitational field event data
  52288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52289. */
  52290. export interface PhysicsGravitationalFieldEventData {
  52291. /**
  52292. * A sphere mesh used for the gravitational field event
  52293. */
  52294. sphere: Mesh;
  52295. }
  52296. /**
  52297. * Interface for updraft event data
  52298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52299. */
  52300. export interface PhysicsUpdraftEventData {
  52301. /**
  52302. * A cylinder used for the updraft event
  52303. */
  52304. cylinder: Mesh;
  52305. }
  52306. /**
  52307. * Interface for vortex event data
  52308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52309. */
  52310. export interface PhysicsVortexEventData {
  52311. /**
  52312. * A cylinder used for the vortex event
  52313. */
  52314. cylinder: Mesh;
  52315. }
  52316. /**
  52317. * Interface for an affected physics impostor
  52318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52319. */
  52320. export interface PhysicsAffectedImpostorWithData {
  52321. /**
  52322. * The impostor affected by the effect
  52323. */
  52324. impostor: PhysicsImpostor;
  52325. /**
  52326. * The data about the hit/horce from the explosion
  52327. */
  52328. hitData: PhysicsHitData;
  52329. }
  52330. }
  52331. declare module BABYLON {
  52332. /** @hidden */
  52333. export var blackAndWhitePixelShader: {
  52334. name: string;
  52335. shader: string;
  52336. };
  52337. }
  52338. declare module BABYLON {
  52339. /**
  52340. * Post process used to render in black and white
  52341. */
  52342. export class BlackAndWhitePostProcess extends PostProcess {
  52343. /**
  52344. * Linear about to convert he result to black and white (default: 1)
  52345. */
  52346. degree: number;
  52347. /**
  52348. * Creates a black and white post process
  52349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52350. * @param name The name of the effect.
  52351. * @param options The required width/height ratio to downsize to before computing the render pass.
  52352. * @param camera The camera to apply the render pass to.
  52353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52354. * @param engine The engine which the post process will be applied. (default: current engine)
  52355. * @param reusable If the post process can be reused on the same frame. (default: false)
  52356. */
  52357. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52358. }
  52359. }
  52360. declare module BABYLON {
  52361. /**
  52362. * This represents a set of one or more post processes in Babylon.
  52363. * A post process can be used to apply a shader to a texture after it is rendered.
  52364. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52365. */
  52366. export class PostProcessRenderEffect {
  52367. private _postProcesses;
  52368. private _getPostProcesses;
  52369. private _singleInstance;
  52370. private _cameras;
  52371. private _indicesForCamera;
  52372. /**
  52373. * Name of the effect
  52374. * @hidden
  52375. */
  52376. _name: string;
  52377. /**
  52378. * Instantiates a post process render effect.
  52379. * A post process can be used to apply a shader to a texture after it is rendered.
  52380. * @param engine The engine the effect is tied to
  52381. * @param name The name of the effect
  52382. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52383. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52384. */
  52385. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52386. /**
  52387. * Checks if all the post processes in the effect are supported.
  52388. */
  52389. readonly isSupported: boolean;
  52390. /**
  52391. * Updates the current state of the effect
  52392. * @hidden
  52393. */
  52394. _update(): void;
  52395. /**
  52396. * Attaches the effect on cameras
  52397. * @param cameras The camera to attach to.
  52398. * @hidden
  52399. */
  52400. _attachCameras(cameras: Camera): void;
  52401. /**
  52402. * Attaches the effect on cameras
  52403. * @param cameras The camera to attach to.
  52404. * @hidden
  52405. */
  52406. _attachCameras(cameras: Camera[]): void;
  52407. /**
  52408. * Detaches the effect on cameras
  52409. * @param cameras The camera to detatch from.
  52410. * @hidden
  52411. */
  52412. _detachCameras(cameras: Camera): void;
  52413. /**
  52414. * Detatches the effect on cameras
  52415. * @param cameras The camera to detatch from.
  52416. * @hidden
  52417. */
  52418. _detachCameras(cameras: Camera[]): void;
  52419. /**
  52420. * Enables the effect on given cameras
  52421. * @param cameras The camera to enable.
  52422. * @hidden
  52423. */
  52424. _enable(cameras: Camera): void;
  52425. /**
  52426. * Enables the effect on given cameras
  52427. * @param cameras The camera to enable.
  52428. * @hidden
  52429. */
  52430. _enable(cameras: Nullable<Camera[]>): void;
  52431. /**
  52432. * Disables the effect on the given cameras
  52433. * @param cameras The camera to disable.
  52434. * @hidden
  52435. */
  52436. _disable(cameras: Camera): void;
  52437. /**
  52438. * Disables the effect on the given cameras
  52439. * @param cameras The camera to disable.
  52440. * @hidden
  52441. */
  52442. _disable(cameras: Nullable<Camera[]>): void;
  52443. /**
  52444. * Gets a list of the post processes contained in the effect.
  52445. * @param camera The camera to get the post processes on.
  52446. * @returns The list of the post processes in the effect.
  52447. */
  52448. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52449. }
  52450. }
  52451. declare module BABYLON {
  52452. /** @hidden */
  52453. export var extractHighlightsPixelShader: {
  52454. name: string;
  52455. shader: string;
  52456. };
  52457. }
  52458. declare module BABYLON {
  52459. /**
  52460. * 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.
  52461. */
  52462. export class ExtractHighlightsPostProcess extends PostProcess {
  52463. /**
  52464. * The luminance threshold, pixels below this value will be set to black.
  52465. */
  52466. threshold: number;
  52467. /** @hidden */
  52468. _exposure: number;
  52469. /**
  52470. * Post process which has the input texture to be used when performing highlight extraction
  52471. * @hidden
  52472. */
  52473. _inputPostProcess: Nullable<PostProcess>;
  52474. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52475. }
  52476. }
  52477. declare module BABYLON {
  52478. /** @hidden */
  52479. export var bloomMergePixelShader: {
  52480. name: string;
  52481. shader: string;
  52482. };
  52483. }
  52484. declare module BABYLON {
  52485. /**
  52486. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52487. */
  52488. export class BloomMergePostProcess extends PostProcess {
  52489. /** Weight of the bloom to be added to the original input. */
  52490. weight: number;
  52491. /**
  52492. * Creates a new instance of @see BloomMergePostProcess
  52493. * @param name The name of the effect.
  52494. * @param originalFromInput Post process which's input will be used for the merge.
  52495. * @param blurred Blurred highlights post process which's output will be used.
  52496. * @param weight Weight of the bloom to be added to the original input.
  52497. * @param options The required width/height ratio to downsize to before computing the render pass.
  52498. * @param camera The camera to apply the render pass to.
  52499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52500. * @param engine The engine which the post process will be applied. (default: current engine)
  52501. * @param reusable If the post process can be reused on the same frame. (default: false)
  52502. * @param textureType Type of textures used when performing the post process. (default: 0)
  52503. * @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)
  52504. */
  52505. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52506. /** Weight of the bloom to be added to the original input. */
  52507. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52508. }
  52509. }
  52510. declare module BABYLON {
  52511. /**
  52512. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52513. */
  52514. export class BloomEffect extends PostProcessRenderEffect {
  52515. private bloomScale;
  52516. /**
  52517. * @hidden Internal
  52518. */
  52519. _effects: Array<PostProcess>;
  52520. /**
  52521. * @hidden Internal
  52522. */
  52523. _downscale: ExtractHighlightsPostProcess;
  52524. private _blurX;
  52525. private _blurY;
  52526. private _merge;
  52527. /**
  52528. * The luminance threshold to find bright areas of the image to bloom.
  52529. */
  52530. threshold: number;
  52531. /**
  52532. * The strength of the bloom.
  52533. */
  52534. weight: number;
  52535. /**
  52536. * Specifies the size of the bloom blur kernel, relative to the final output size
  52537. */
  52538. kernel: number;
  52539. /**
  52540. * Creates a new instance of @see BloomEffect
  52541. * @param scene The scene the effect belongs to.
  52542. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52543. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52544. * @param bloomWeight The the strength of bloom.
  52545. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52546. * @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)
  52547. */
  52548. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52549. /**
  52550. * Disposes each of the internal effects for a given camera.
  52551. * @param camera The camera to dispose the effect on.
  52552. */
  52553. disposeEffects(camera: Camera): void;
  52554. /**
  52555. * @hidden Internal
  52556. */
  52557. _updateEffects(): void;
  52558. /**
  52559. * Internal
  52560. * @returns if all the contained post processes are ready.
  52561. * @hidden
  52562. */
  52563. _isReady(): boolean;
  52564. }
  52565. }
  52566. declare module BABYLON {
  52567. /** @hidden */
  52568. export var chromaticAberrationPixelShader: {
  52569. name: string;
  52570. shader: string;
  52571. };
  52572. }
  52573. declare module BABYLON {
  52574. /**
  52575. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52576. */
  52577. export class ChromaticAberrationPostProcess extends PostProcess {
  52578. /**
  52579. * The amount of seperation of rgb channels (default: 30)
  52580. */
  52581. aberrationAmount: number;
  52582. /**
  52583. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52584. */
  52585. radialIntensity: number;
  52586. /**
  52587. * 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))
  52588. */
  52589. direction: Vector2;
  52590. /**
  52591. * 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))
  52592. */
  52593. centerPosition: Vector2;
  52594. /**
  52595. * Creates a new instance ChromaticAberrationPostProcess
  52596. * @param name The name of the effect.
  52597. * @param screenWidth The width of the screen to apply the effect on.
  52598. * @param screenHeight The height of the screen to apply the effect on.
  52599. * @param options The required width/height ratio to downsize to before computing the render pass.
  52600. * @param camera The camera to apply the render pass to.
  52601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52602. * @param engine The engine which the post process will be applied. (default: current engine)
  52603. * @param reusable If the post process can be reused on the same frame. (default: false)
  52604. * @param textureType Type of textures used when performing the post process. (default: 0)
  52605. * @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)
  52606. */
  52607. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52608. }
  52609. }
  52610. declare module BABYLON {
  52611. /** @hidden */
  52612. export var circleOfConfusionPixelShader: {
  52613. name: string;
  52614. shader: string;
  52615. };
  52616. }
  52617. declare module BABYLON {
  52618. /**
  52619. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52620. */
  52621. export class CircleOfConfusionPostProcess extends PostProcess {
  52622. /**
  52623. * 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.
  52624. */
  52625. lensSize: number;
  52626. /**
  52627. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52628. */
  52629. fStop: number;
  52630. /**
  52631. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52632. */
  52633. focusDistance: number;
  52634. /**
  52635. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52636. */
  52637. focalLength: number;
  52638. private _depthTexture;
  52639. /**
  52640. * Creates a new instance CircleOfConfusionPostProcess
  52641. * @param name The name of the effect.
  52642. * @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.
  52643. * @param options The required width/height ratio to downsize to before computing the render pass.
  52644. * @param camera The camera to apply the render pass to.
  52645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52646. * @param engine The engine which the post process will be applied. (default: current engine)
  52647. * @param reusable If the post process can be reused on the same frame. (default: false)
  52648. * @param textureType Type of textures used when performing the post process. (default: 0)
  52649. * @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)
  52650. */
  52651. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52652. /**
  52653. * 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.
  52654. */
  52655. depthTexture: RenderTargetTexture;
  52656. }
  52657. }
  52658. declare module BABYLON {
  52659. /** @hidden */
  52660. export var colorCorrectionPixelShader: {
  52661. name: string;
  52662. shader: string;
  52663. };
  52664. }
  52665. declare module BABYLON {
  52666. /**
  52667. *
  52668. * This post-process allows the modification of rendered colors by using
  52669. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52670. *
  52671. * The object needs to be provided an url to a texture containing the color
  52672. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52673. * Use an image editing software to tweak the LUT to match your needs.
  52674. *
  52675. * For an example of a color LUT, see here:
  52676. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52677. * For explanations on color grading, see here:
  52678. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52679. *
  52680. */
  52681. export class ColorCorrectionPostProcess extends PostProcess {
  52682. private _colorTableTexture;
  52683. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52684. }
  52685. }
  52686. declare module BABYLON {
  52687. /** @hidden */
  52688. export var convolutionPixelShader: {
  52689. name: string;
  52690. shader: string;
  52691. };
  52692. }
  52693. declare module BABYLON {
  52694. /**
  52695. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52696. * input texture to perform effects such as edge detection or sharpening
  52697. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52698. */
  52699. export class ConvolutionPostProcess extends PostProcess {
  52700. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52701. kernel: number[];
  52702. /**
  52703. * Creates a new instance ConvolutionPostProcess
  52704. * @param name The name of the effect.
  52705. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52706. * @param options The required width/height ratio to downsize to before computing the render pass.
  52707. * @param camera The camera to apply the render pass to.
  52708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52709. * @param engine The engine which the post process will be applied. (default: current engine)
  52710. * @param reusable If the post process can be reused on the same frame. (default: false)
  52711. * @param textureType Type of textures used when performing the post process. (default: 0)
  52712. */
  52713. constructor(name: string,
  52714. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52715. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52716. /**
  52717. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52718. */
  52719. static EdgeDetect0Kernel: number[];
  52720. /**
  52721. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52722. */
  52723. static EdgeDetect1Kernel: number[];
  52724. /**
  52725. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52726. */
  52727. static EdgeDetect2Kernel: number[];
  52728. /**
  52729. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52730. */
  52731. static SharpenKernel: number[];
  52732. /**
  52733. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52734. */
  52735. static EmbossKernel: number[];
  52736. /**
  52737. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52738. */
  52739. static GaussianKernel: number[];
  52740. }
  52741. }
  52742. declare module BABYLON {
  52743. /**
  52744. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52745. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52746. * based on samples that have a large difference in distance than the center pixel.
  52747. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52748. */
  52749. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52750. direction: Vector2;
  52751. /**
  52752. * Creates a new instance CircleOfConfusionPostProcess
  52753. * @param name The name of the effect.
  52754. * @param scene The scene the effect belongs to.
  52755. * @param direction The direction the blur should be applied.
  52756. * @param kernel The size of the kernel used to blur.
  52757. * @param options The required width/height ratio to downsize to before computing the render pass.
  52758. * @param camera The camera to apply the render pass to.
  52759. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52760. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52762. * @param engine The engine which the post process will be applied. (default: current engine)
  52763. * @param reusable If the post process can be reused on the same frame. (default: false)
  52764. * @param textureType Type of textures used when performing the post process. (default: 0)
  52765. * @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)
  52766. */
  52767. 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);
  52768. }
  52769. }
  52770. declare module BABYLON {
  52771. /** @hidden */
  52772. export var depthOfFieldMergePixelShader: {
  52773. name: string;
  52774. shader: string;
  52775. };
  52776. }
  52777. declare module BABYLON {
  52778. /**
  52779. * Options to be set when merging outputs from the default pipeline.
  52780. */
  52781. export class DepthOfFieldMergePostProcessOptions {
  52782. /**
  52783. * The original image to merge on top of
  52784. */
  52785. originalFromInput: PostProcess;
  52786. /**
  52787. * Parameters to perform the merge of the depth of field effect
  52788. */
  52789. depthOfField?: {
  52790. circleOfConfusion: PostProcess;
  52791. blurSteps: Array<PostProcess>;
  52792. };
  52793. /**
  52794. * Parameters to perform the merge of bloom effect
  52795. */
  52796. bloom?: {
  52797. blurred: PostProcess;
  52798. weight: number;
  52799. };
  52800. }
  52801. /**
  52802. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52803. */
  52804. export class DepthOfFieldMergePostProcess extends PostProcess {
  52805. private blurSteps;
  52806. /**
  52807. * Creates a new instance of DepthOfFieldMergePostProcess
  52808. * @param name The name of the effect.
  52809. * @param originalFromInput Post process which's input will be used for the merge.
  52810. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52811. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52812. * @param options The required width/height ratio to downsize to before computing the render pass.
  52813. * @param camera The camera to apply the render pass to.
  52814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52815. * @param engine The engine which the post process will be applied. (default: current engine)
  52816. * @param reusable If the post process can be reused on the same frame. (default: false)
  52817. * @param textureType Type of textures used when performing the post process. (default: 0)
  52818. * @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)
  52819. */
  52820. 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);
  52821. /**
  52822. * Updates the effect with the current post process compile time values and recompiles the shader.
  52823. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52824. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52825. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52826. * @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
  52827. * @param onCompiled Called when the shader has been compiled.
  52828. * @param onError Called if there is an error when compiling a shader.
  52829. */
  52830. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52831. }
  52832. }
  52833. declare module BABYLON {
  52834. /**
  52835. * Specifies the level of max blur that should be applied when using the depth of field effect
  52836. */
  52837. export enum DepthOfFieldEffectBlurLevel {
  52838. /**
  52839. * Subtle blur
  52840. */
  52841. Low = 0,
  52842. /**
  52843. * Medium blur
  52844. */
  52845. Medium = 1,
  52846. /**
  52847. * Large blur
  52848. */
  52849. High = 2
  52850. }
  52851. /**
  52852. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52853. */
  52854. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52855. private _circleOfConfusion;
  52856. /**
  52857. * @hidden Internal, blurs from high to low
  52858. */
  52859. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52860. private _depthOfFieldBlurY;
  52861. private _dofMerge;
  52862. /**
  52863. * @hidden Internal post processes in depth of field effect
  52864. */
  52865. _effects: Array<PostProcess>;
  52866. /**
  52867. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52868. */
  52869. focalLength: number;
  52870. /**
  52871. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52872. */
  52873. fStop: number;
  52874. /**
  52875. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52876. */
  52877. focusDistance: number;
  52878. /**
  52879. * 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.
  52880. */
  52881. lensSize: number;
  52882. /**
  52883. * Creates a new instance DepthOfFieldEffect
  52884. * @param scene The scene the effect belongs to.
  52885. * @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.
  52886. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52887. * @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)
  52888. */
  52889. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52890. /**
  52891. * Get the current class name of the current effet
  52892. * @returns "DepthOfFieldEffect"
  52893. */
  52894. getClassName(): string;
  52895. /**
  52896. * 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.
  52897. */
  52898. depthTexture: RenderTargetTexture;
  52899. /**
  52900. * Disposes each of the internal effects for a given camera.
  52901. * @param camera The camera to dispose the effect on.
  52902. */
  52903. disposeEffects(camera: Camera): void;
  52904. /**
  52905. * @hidden Internal
  52906. */
  52907. _updateEffects(): void;
  52908. /**
  52909. * Internal
  52910. * @returns if all the contained post processes are ready.
  52911. * @hidden
  52912. */
  52913. _isReady(): boolean;
  52914. }
  52915. }
  52916. declare module BABYLON {
  52917. /** @hidden */
  52918. export var displayPassPixelShader: {
  52919. name: string;
  52920. shader: string;
  52921. };
  52922. }
  52923. declare module BABYLON {
  52924. /**
  52925. * DisplayPassPostProcess which produces an output the same as it's input
  52926. */
  52927. export class DisplayPassPostProcess extends PostProcess {
  52928. /**
  52929. * Creates the DisplayPassPostProcess
  52930. * @param name The name of the effect.
  52931. * @param options The required width/height ratio to downsize to before computing the render pass.
  52932. * @param camera The camera to apply the render pass to.
  52933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52934. * @param engine The engine which the post process will be applied. (default: current engine)
  52935. * @param reusable If the post process can be reused on the same frame. (default: false)
  52936. */
  52937. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52938. }
  52939. }
  52940. declare module BABYLON {
  52941. /** @hidden */
  52942. export var filterPixelShader: {
  52943. name: string;
  52944. shader: string;
  52945. };
  52946. }
  52947. declare module BABYLON {
  52948. /**
  52949. * Applies a kernel filter to the image
  52950. */
  52951. export class FilterPostProcess extends PostProcess {
  52952. /** The matrix to be applied to the image */
  52953. kernelMatrix: Matrix;
  52954. /**
  52955. *
  52956. * @param name The name of the effect.
  52957. * @param kernelMatrix The matrix to be applied to the image
  52958. * @param options The required width/height ratio to downsize to before computing the render pass.
  52959. * @param camera The camera to apply the render pass to.
  52960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52961. * @param engine The engine which the post process will be applied. (default: current engine)
  52962. * @param reusable If the post process can be reused on the same frame. (default: false)
  52963. */
  52964. constructor(name: string,
  52965. /** The matrix to be applied to the image */
  52966. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52967. }
  52968. }
  52969. declare module BABYLON {
  52970. /** @hidden */
  52971. export var fxaaPixelShader: {
  52972. name: string;
  52973. shader: string;
  52974. };
  52975. }
  52976. declare module BABYLON {
  52977. /** @hidden */
  52978. export var fxaaVertexShader: {
  52979. name: string;
  52980. shader: string;
  52981. };
  52982. }
  52983. declare module BABYLON {
  52984. /**
  52985. * Fxaa post process
  52986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52987. */
  52988. export class FxaaPostProcess extends PostProcess {
  52989. /** @hidden */
  52990. texelWidth: number;
  52991. /** @hidden */
  52992. texelHeight: number;
  52993. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52994. private _getDefines;
  52995. }
  52996. }
  52997. declare module BABYLON {
  52998. /** @hidden */
  52999. export var grainPixelShader: {
  53000. name: string;
  53001. shader: string;
  53002. };
  53003. }
  53004. declare module BABYLON {
  53005. /**
  53006. * The GrainPostProcess adds noise to the image at mid luminance levels
  53007. */
  53008. export class GrainPostProcess extends PostProcess {
  53009. /**
  53010. * The intensity of the grain added (default: 30)
  53011. */
  53012. intensity: number;
  53013. /**
  53014. * If the grain should be randomized on every frame
  53015. */
  53016. animated: boolean;
  53017. /**
  53018. * Creates a new instance of @see GrainPostProcess
  53019. * @param name The name of the effect.
  53020. * @param options The required width/height ratio to downsize to before computing the render pass.
  53021. * @param camera The camera to apply the render pass to.
  53022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53023. * @param engine The engine which the post process will be applied. (default: current engine)
  53024. * @param reusable If the post process can be reused on the same frame. (default: false)
  53025. * @param textureType Type of textures used when performing the post process. (default: 0)
  53026. * @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)
  53027. */
  53028. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53029. }
  53030. }
  53031. declare module BABYLON {
  53032. /** @hidden */
  53033. export var highlightsPixelShader: {
  53034. name: string;
  53035. shader: string;
  53036. };
  53037. }
  53038. declare module BABYLON {
  53039. /**
  53040. * Extracts highlights from the image
  53041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53042. */
  53043. export class HighlightsPostProcess extends PostProcess {
  53044. /**
  53045. * Extracts highlights from the image
  53046. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53047. * @param name The name of the effect.
  53048. * @param options The required width/height ratio to downsize to before computing the render pass.
  53049. * @param camera The camera to apply the render pass to.
  53050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53051. * @param engine The engine which the post process will be applied. (default: current engine)
  53052. * @param reusable If the post process can be reused on the same frame. (default: false)
  53053. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53054. */
  53055. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53056. }
  53057. }
  53058. declare module BABYLON {
  53059. /** @hidden */
  53060. export var mrtFragmentDeclaration: {
  53061. name: string;
  53062. shader: string;
  53063. };
  53064. }
  53065. declare module BABYLON {
  53066. /** @hidden */
  53067. export var geometryPixelShader: {
  53068. name: string;
  53069. shader: string;
  53070. };
  53071. }
  53072. declare module BABYLON {
  53073. /** @hidden */
  53074. export var geometryVertexShader: {
  53075. name: string;
  53076. shader: string;
  53077. };
  53078. }
  53079. declare module BABYLON {
  53080. /** @hidden */
  53081. interface ISavedTransformationMatrix {
  53082. world: Matrix;
  53083. viewProjection: Matrix;
  53084. }
  53085. /**
  53086. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53087. */
  53088. export class GeometryBufferRenderer {
  53089. /**
  53090. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53091. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53092. */
  53093. static readonly POSITION_TEXTURE_TYPE: number;
  53094. /**
  53095. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53096. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53097. */
  53098. static readonly VELOCITY_TEXTURE_TYPE: number;
  53099. /**
  53100. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53101. * in order to compute objects velocities when enableVelocity is set to "true"
  53102. * @hidden
  53103. */
  53104. _previousTransformationMatrices: {
  53105. [index: number]: ISavedTransformationMatrix;
  53106. };
  53107. /**
  53108. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  53109. * in order to compute objects velocities when enableVelocity is set to "true"
  53110. * @hidden
  53111. */
  53112. _previousBonesTransformationMatrices: {
  53113. [index: number]: Float32Array;
  53114. };
  53115. /**
  53116. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  53117. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  53118. */
  53119. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  53120. private _scene;
  53121. private _multiRenderTarget;
  53122. private _ratio;
  53123. private _enablePosition;
  53124. private _enableVelocity;
  53125. private _positionIndex;
  53126. private _velocityIndex;
  53127. protected _effect: Effect;
  53128. protected _cachedDefines: string;
  53129. /**
  53130. * Set the render list (meshes to be rendered) used in the G buffer.
  53131. */
  53132. renderList: Mesh[];
  53133. /**
  53134. * Gets wether or not G buffer are supported by the running hardware.
  53135. * This requires draw buffer supports
  53136. */
  53137. readonly isSupported: boolean;
  53138. /**
  53139. * Returns the index of the given texture type in the G-Buffer textures array
  53140. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53141. * @returns the index of the given texture type in the G-Buffer textures array
  53142. */
  53143. getTextureIndex(textureType: number): number;
  53144. /**
  53145. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53146. */
  53147. /**
  53148. * Sets whether or not objects positions are enabled for the G buffer.
  53149. */
  53150. enablePosition: boolean;
  53151. /**
  53152. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53153. */
  53154. /**
  53155. * Sets wether or not objects velocities are enabled for the G buffer.
  53156. */
  53157. enableVelocity: boolean;
  53158. /**
  53159. * Gets the scene associated with the buffer.
  53160. */
  53161. readonly scene: Scene;
  53162. /**
  53163. * Gets the ratio used by the buffer during its creation.
  53164. * How big is the buffer related to the main canvas.
  53165. */
  53166. readonly ratio: number;
  53167. /** @hidden */
  53168. static _SceneComponentInitialization: (scene: Scene) => void;
  53169. /**
  53170. * Creates a new G Buffer for the scene
  53171. * @param scene The scene the buffer belongs to
  53172. * @param ratio How big is the buffer related to the main canvas.
  53173. */
  53174. constructor(scene: Scene, ratio?: number);
  53175. /**
  53176. * Checks wether everything is ready to render a submesh to the G buffer.
  53177. * @param subMesh the submesh to check readiness for
  53178. * @param useInstances is the mesh drawn using instance or not
  53179. * @returns true if ready otherwise false
  53180. */
  53181. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53182. /**
  53183. * Gets the current underlying G Buffer.
  53184. * @returns the buffer
  53185. */
  53186. getGBuffer(): MultiRenderTarget;
  53187. /**
  53188. * Gets the number of samples used to render the buffer (anti aliasing).
  53189. */
  53190. /**
  53191. * Sets the number of samples used to render the buffer (anti aliasing).
  53192. */
  53193. samples: number;
  53194. /**
  53195. * Disposes the renderer and frees up associated resources.
  53196. */
  53197. dispose(): void;
  53198. protected _createRenderTargets(): void;
  53199. private _copyBonesTransformationMatrices;
  53200. }
  53201. }
  53202. declare module BABYLON {
  53203. interface Scene {
  53204. /** @hidden (Backing field) */
  53205. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53206. /**
  53207. * Gets or Sets the current geometry buffer associated to the scene.
  53208. */
  53209. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53210. /**
  53211. * Enables a GeometryBufferRender and associates it with the scene
  53212. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53213. * @returns the GeometryBufferRenderer
  53214. */
  53215. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53216. /**
  53217. * Disables the GeometryBufferRender associated with the scene
  53218. */
  53219. disableGeometryBufferRenderer(): void;
  53220. }
  53221. /**
  53222. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53223. * in several rendering techniques.
  53224. */
  53225. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53226. /**
  53227. * The component name helpful to identify the component in the list of scene components.
  53228. */
  53229. readonly name: string;
  53230. /**
  53231. * The scene the component belongs to.
  53232. */
  53233. scene: Scene;
  53234. /**
  53235. * Creates a new instance of the component for the given scene
  53236. * @param scene Defines the scene to register the component in
  53237. */
  53238. constructor(scene: Scene);
  53239. /**
  53240. * Registers the component in a given scene
  53241. */
  53242. register(): void;
  53243. /**
  53244. * Rebuilds the elements related to this component in case of
  53245. * context lost for instance.
  53246. */
  53247. rebuild(): void;
  53248. /**
  53249. * Disposes the component and the associated ressources
  53250. */
  53251. dispose(): void;
  53252. private _gatherRenderTargets;
  53253. }
  53254. }
  53255. declare module BABYLON {
  53256. /** @hidden */
  53257. export var motionBlurPixelShader: {
  53258. name: string;
  53259. shader: string;
  53260. };
  53261. }
  53262. declare module BABYLON {
  53263. /**
  53264. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53265. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53266. * As an example, all you have to do is to create the post-process:
  53267. * var mb = new BABYLON.MotionBlurPostProcess(
  53268. * 'mb', // The name of the effect.
  53269. * scene, // The scene containing the objects to blur according to their velocity.
  53270. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53271. * camera // The camera to apply the render pass to.
  53272. * );
  53273. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53274. */
  53275. export class MotionBlurPostProcess extends PostProcess {
  53276. /**
  53277. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53278. */
  53279. motionStrength: number;
  53280. /**
  53281. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53282. */
  53283. /**
  53284. * Sets the number of iterations to be used for motion blur quality
  53285. */
  53286. motionBlurSamples: number;
  53287. private _motionBlurSamples;
  53288. private _geometryBufferRenderer;
  53289. /**
  53290. * Creates a new instance MotionBlurPostProcess
  53291. * @param name The name of the effect.
  53292. * @param scene The scene containing the objects to blur according to their velocity.
  53293. * @param options The required width/height ratio to downsize to before computing the render pass.
  53294. * @param camera The camera to apply the render pass to.
  53295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53296. * @param engine The engine which the post process will be applied. (default: current engine)
  53297. * @param reusable If the post process can be reused on the same frame. (default: false)
  53298. * @param textureType Type of textures used when performing the post process. (default: 0)
  53299. * @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)
  53300. */
  53301. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53302. /**
  53303. * Excludes the given skinned mesh from computing bones velocities.
  53304. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  53305. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  53306. */
  53307. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  53308. /**
  53309. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  53310. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  53311. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  53312. */
  53313. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  53314. /**
  53315. * Disposes the post process.
  53316. * @param camera The camera to dispose the post process on.
  53317. */
  53318. dispose(camera?: Camera): void;
  53319. }
  53320. }
  53321. declare module BABYLON {
  53322. /** @hidden */
  53323. export var refractionPixelShader: {
  53324. name: string;
  53325. shader: string;
  53326. };
  53327. }
  53328. declare module BABYLON {
  53329. /**
  53330. * Post process which applies a refractin texture
  53331. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53332. */
  53333. export class RefractionPostProcess extends PostProcess {
  53334. /** the base color of the refraction (used to taint the rendering) */
  53335. color: Color3;
  53336. /** simulated refraction depth */
  53337. depth: number;
  53338. /** the coefficient of the base color (0 to remove base color tainting) */
  53339. colorLevel: number;
  53340. private _refTexture;
  53341. private _ownRefractionTexture;
  53342. /**
  53343. * Gets or sets the refraction texture
  53344. * Please note that you are responsible for disposing the texture if you set it manually
  53345. */
  53346. refractionTexture: Texture;
  53347. /**
  53348. * Initializes the RefractionPostProcess
  53349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53350. * @param name The name of the effect.
  53351. * @param refractionTextureUrl Url of the refraction texture to use
  53352. * @param color the base color of the refraction (used to taint the rendering)
  53353. * @param depth simulated refraction depth
  53354. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53355. * @param camera The camera to apply the render pass to.
  53356. * @param options The required width/height ratio to downsize to before computing the render pass.
  53357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53358. * @param engine The engine which the post process will be applied. (default: current engine)
  53359. * @param reusable If the post process can be reused on the same frame. (default: false)
  53360. */
  53361. constructor(name: string, refractionTextureUrl: string,
  53362. /** the base color of the refraction (used to taint the rendering) */
  53363. color: Color3,
  53364. /** simulated refraction depth */
  53365. depth: number,
  53366. /** the coefficient of the base color (0 to remove base color tainting) */
  53367. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53368. /**
  53369. * Disposes of the post process
  53370. * @param camera Camera to dispose post process on
  53371. */
  53372. dispose(camera: Camera): void;
  53373. }
  53374. }
  53375. declare module BABYLON {
  53376. /** @hidden */
  53377. export var sharpenPixelShader: {
  53378. name: string;
  53379. shader: string;
  53380. };
  53381. }
  53382. declare module BABYLON {
  53383. /**
  53384. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53385. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53386. */
  53387. export class SharpenPostProcess extends PostProcess {
  53388. /**
  53389. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53390. */
  53391. colorAmount: number;
  53392. /**
  53393. * How much sharpness should be applied (default: 0.3)
  53394. */
  53395. edgeAmount: number;
  53396. /**
  53397. * Creates a new instance ConvolutionPostProcess
  53398. * @param name The name of the effect.
  53399. * @param options The required width/height ratio to downsize to before computing the render pass.
  53400. * @param camera The camera to apply the render pass to.
  53401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53402. * @param engine The engine which the post process will be applied. (default: current engine)
  53403. * @param reusable If the post process can be reused on the same frame. (default: false)
  53404. * @param textureType Type of textures used when performing the post process. (default: 0)
  53405. * @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)
  53406. */
  53407. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53408. }
  53409. }
  53410. declare module BABYLON {
  53411. /**
  53412. * PostProcessRenderPipeline
  53413. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53414. */
  53415. export class PostProcessRenderPipeline {
  53416. private engine;
  53417. private _renderEffects;
  53418. private _renderEffectsForIsolatedPass;
  53419. /**
  53420. * List of inspectable custom properties (used by the Inspector)
  53421. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  53422. */
  53423. inspectableCustomProperties: IInspectable[];
  53424. /**
  53425. * @hidden
  53426. */
  53427. protected _cameras: Camera[];
  53428. /** @hidden */
  53429. _name: string;
  53430. /**
  53431. * Gets pipeline name
  53432. */
  53433. readonly name: string;
  53434. /**
  53435. * Initializes a PostProcessRenderPipeline
  53436. * @param engine engine to add the pipeline to
  53437. * @param name name of the pipeline
  53438. */
  53439. constructor(engine: Engine, name: string);
  53440. /**
  53441. * Gets the class name
  53442. * @returns "PostProcessRenderPipeline"
  53443. */
  53444. getClassName(): string;
  53445. /**
  53446. * If all the render effects in the pipeline are supported
  53447. */
  53448. readonly isSupported: boolean;
  53449. /**
  53450. * Adds an effect to the pipeline
  53451. * @param renderEffect the effect to add
  53452. */
  53453. addEffect(renderEffect: PostProcessRenderEffect): void;
  53454. /** @hidden */
  53455. _rebuild(): void;
  53456. /** @hidden */
  53457. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53458. /** @hidden */
  53459. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53460. /** @hidden */
  53461. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53462. /** @hidden */
  53463. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53464. /** @hidden */
  53465. _attachCameras(cameras: Camera, unique: boolean): void;
  53466. /** @hidden */
  53467. _attachCameras(cameras: Camera[], unique: boolean): void;
  53468. /** @hidden */
  53469. _detachCameras(cameras: Camera): void;
  53470. /** @hidden */
  53471. _detachCameras(cameras: Nullable<Camera[]>): void;
  53472. /** @hidden */
  53473. _update(): void;
  53474. /** @hidden */
  53475. _reset(): void;
  53476. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53477. /**
  53478. * Disposes of the pipeline
  53479. */
  53480. dispose(): void;
  53481. }
  53482. }
  53483. declare module BABYLON {
  53484. /**
  53485. * PostProcessRenderPipelineManager class
  53486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53487. */
  53488. export class PostProcessRenderPipelineManager {
  53489. private _renderPipelines;
  53490. /**
  53491. * Initializes a PostProcessRenderPipelineManager
  53492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53493. */
  53494. constructor();
  53495. /**
  53496. * Gets the list of supported render pipelines
  53497. */
  53498. readonly supportedPipelines: PostProcessRenderPipeline[];
  53499. /**
  53500. * Adds a pipeline to the manager
  53501. * @param renderPipeline The pipeline to add
  53502. */
  53503. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53504. /**
  53505. * Attaches a camera to the pipeline
  53506. * @param renderPipelineName The name of the pipeline to attach to
  53507. * @param cameras the camera to attach
  53508. * @param unique if the camera can be attached multiple times to the pipeline
  53509. */
  53510. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53511. /**
  53512. * Detaches a camera from the pipeline
  53513. * @param renderPipelineName The name of the pipeline to detach from
  53514. * @param cameras the camera to detach
  53515. */
  53516. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53517. /**
  53518. * Enables an effect by name on a pipeline
  53519. * @param renderPipelineName the name of the pipeline to enable the effect in
  53520. * @param renderEffectName the name of the effect to enable
  53521. * @param cameras the cameras that the effect should be enabled on
  53522. */
  53523. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53524. /**
  53525. * Disables an effect by name on a pipeline
  53526. * @param renderPipelineName the name of the pipeline to disable the effect in
  53527. * @param renderEffectName the name of the effect to disable
  53528. * @param cameras the cameras that the effect should be disabled on
  53529. */
  53530. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53531. /**
  53532. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53533. */
  53534. update(): void;
  53535. /** @hidden */
  53536. _rebuild(): void;
  53537. /**
  53538. * Disposes of the manager and pipelines
  53539. */
  53540. dispose(): void;
  53541. }
  53542. }
  53543. declare module BABYLON {
  53544. interface Scene {
  53545. /** @hidden (Backing field) */
  53546. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53547. /**
  53548. * Gets the postprocess render pipeline manager
  53549. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53550. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53551. */
  53552. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53553. }
  53554. /**
  53555. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53556. */
  53557. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53558. /**
  53559. * The component name helpfull to identify the component in the list of scene components.
  53560. */
  53561. readonly name: string;
  53562. /**
  53563. * The scene the component belongs to.
  53564. */
  53565. scene: Scene;
  53566. /**
  53567. * Creates a new instance of the component for the given scene
  53568. * @param scene Defines the scene to register the component in
  53569. */
  53570. constructor(scene: Scene);
  53571. /**
  53572. * Registers the component in a given scene
  53573. */
  53574. register(): void;
  53575. /**
  53576. * Rebuilds the elements related to this component in case of
  53577. * context lost for instance.
  53578. */
  53579. rebuild(): void;
  53580. /**
  53581. * Disposes the component and the associated ressources
  53582. */
  53583. dispose(): void;
  53584. private _gatherRenderTargets;
  53585. }
  53586. }
  53587. declare module BABYLON {
  53588. /**
  53589. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53590. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53591. */
  53592. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53593. private _scene;
  53594. private _camerasToBeAttached;
  53595. /**
  53596. * ID of the sharpen post process,
  53597. */
  53598. private readonly SharpenPostProcessId;
  53599. /**
  53600. * @ignore
  53601. * ID of the image processing post process;
  53602. */
  53603. readonly ImageProcessingPostProcessId: string;
  53604. /**
  53605. * @ignore
  53606. * ID of the Fast Approximate Anti-Aliasing post process;
  53607. */
  53608. readonly FxaaPostProcessId: string;
  53609. /**
  53610. * ID of the chromatic aberration post process,
  53611. */
  53612. private readonly ChromaticAberrationPostProcessId;
  53613. /**
  53614. * ID of the grain post process
  53615. */
  53616. private readonly GrainPostProcessId;
  53617. /**
  53618. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53619. */
  53620. sharpen: SharpenPostProcess;
  53621. private _sharpenEffect;
  53622. private bloom;
  53623. /**
  53624. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53625. */
  53626. depthOfField: DepthOfFieldEffect;
  53627. /**
  53628. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53629. */
  53630. fxaa: FxaaPostProcess;
  53631. /**
  53632. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53633. */
  53634. imageProcessing: ImageProcessingPostProcess;
  53635. /**
  53636. * Chromatic aberration post process which will shift rgb colors in the image
  53637. */
  53638. chromaticAberration: ChromaticAberrationPostProcess;
  53639. private _chromaticAberrationEffect;
  53640. /**
  53641. * Grain post process which add noise to the image
  53642. */
  53643. grain: GrainPostProcess;
  53644. private _grainEffect;
  53645. /**
  53646. * Glow post process which adds a glow to emissive areas of the image
  53647. */
  53648. private _glowLayer;
  53649. /**
  53650. * Animations which can be used to tweak settings over a period of time
  53651. */
  53652. animations: Animation[];
  53653. private _imageProcessingConfigurationObserver;
  53654. private _sharpenEnabled;
  53655. private _bloomEnabled;
  53656. private _depthOfFieldEnabled;
  53657. private _depthOfFieldBlurLevel;
  53658. private _fxaaEnabled;
  53659. private _imageProcessingEnabled;
  53660. private _defaultPipelineTextureType;
  53661. private _bloomScale;
  53662. private _chromaticAberrationEnabled;
  53663. private _grainEnabled;
  53664. private _buildAllowed;
  53665. /**
  53666. * Gets active scene
  53667. */
  53668. readonly scene: Scene;
  53669. /**
  53670. * Enable or disable the sharpen process from the pipeline
  53671. */
  53672. sharpenEnabled: boolean;
  53673. private _resizeObserver;
  53674. private _hardwareScaleLevel;
  53675. private _bloomKernel;
  53676. /**
  53677. * Specifies the size of the bloom blur kernel, relative to the final output size
  53678. */
  53679. bloomKernel: number;
  53680. /**
  53681. * Specifies the weight of the bloom in the final rendering
  53682. */
  53683. private _bloomWeight;
  53684. /**
  53685. * Specifies the luma threshold for the area that will be blurred by the bloom
  53686. */
  53687. private _bloomThreshold;
  53688. private _hdr;
  53689. /**
  53690. * The strength of the bloom.
  53691. */
  53692. bloomWeight: number;
  53693. /**
  53694. * The strength of the bloom.
  53695. */
  53696. bloomThreshold: number;
  53697. /**
  53698. * The scale of the bloom, lower value will provide better performance.
  53699. */
  53700. bloomScale: number;
  53701. /**
  53702. * Enable or disable the bloom from the pipeline
  53703. */
  53704. bloomEnabled: boolean;
  53705. private _rebuildBloom;
  53706. /**
  53707. * If the depth of field is enabled.
  53708. */
  53709. depthOfFieldEnabled: boolean;
  53710. /**
  53711. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53712. */
  53713. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53714. /**
  53715. * If the anti aliasing is enabled.
  53716. */
  53717. fxaaEnabled: boolean;
  53718. private _samples;
  53719. /**
  53720. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53721. */
  53722. samples: number;
  53723. /**
  53724. * If image processing is enabled.
  53725. */
  53726. imageProcessingEnabled: boolean;
  53727. /**
  53728. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53729. */
  53730. glowLayerEnabled: boolean;
  53731. /**
  53732. * Gets the glow layer (or null if not defined)
  53733. */
  53734. readonly glowLayer: Nullable<GlowLayer>;
  53735. /**
  53736. * Enable or disable the chromaticAberration process from the pipeline
  53737. */
  53738. chromaticAberrationEnabled: boolean;
  53739. /**
  53740. * Enable or disable the grain process from the pipeline
  53741. */
  53742. grainEnabled: boolean;
  53743. /**
  53744. * @constructor
  53745. * @param name - The rendering pipeline name (default: "")
  53746. * @param hdr - If high dynamic range textures should be used (default: true)
  53747. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53748. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53749. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53750. */
  53751. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53752. /**
  53753. * Get the class name
  53754. * @returns "DefaultRenderingPipeline"
  53755. */
  53756. getClassName(): string;
  53757. /**
  53758. * Force the compilation of the entire pipeline.
  53759. */
  53760. prepare(): void;
  53761. private _hasCleared;
  53762. private _prevPostProcess;
  53763. private _prevPrevPostProcess;
  53764. private _setAutoClearAndTextureSharing;
  53765. private _depthOfFieldSceneObserver;
  53766. private _buildPipeline;
  53767. private _disposePostProcesses;
  53768. /**
  53769. * Adds a camera to the pipeline
  53770. * @param camera the camera to be added
  53771. */
  53772. addCamera(camera: Camera): void;
  53773. /**
  53774. * Removes a camera from the pipeline
  53775. * @param camera the camera to remove
  53776. */
  53777. removeCamera(camera: Camera): void;
  53778. /**
  53779. * Dispose of the pipeline and stop all post processes
  53780. */
  53781. dispose(): void;
  53782. /**
  53783. * Serialize the rendering pipeline (Used when exporting)
  53784. * @returns the serialized object
  53785. */
  53786. serialize(): any;
  53787. /**
  53788. * Parse the serialized pipeline
  53789. * @param source Source pipeline.
  53790. * @param scene The scene to load the pipeline to.
  53791. * @param rootUrl The URL of the serialized pipeline.
  53792. * @returns An instantiated pipeline from the serialized object.
  53793. */
  53794. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53795. }
  53796. }
  53797. declare module BABYLON {
  53798. /** @hidden */
  53799. export var lensHighlightsPixelShader: {
  53800. name: string;
  53801. shader: string;
  53802. };
  53803. }
  53804. declare module BABYLON {
  53805. /** @hidden */
  53806. export var depthOfFieldPixelShader: {
  53807. name: string;
  53808. shader: string;
  53809. };
  53810. }
  53811. declare module BABYLON {
  53812. /**
  53813. * BABYLON.JS Chromatic Aberration GLSL Shader
  53814. * Author: Olivier Guyot
  53815. * Separates very slightly R, G and B colors on the edges of the screen
  53816. * Inspired by Francois Tarlier & Martins Upitis
  53817. */
  53818. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53819. /**
  53820. * @ignore
  53821. * The chromatic aberration PostProcess id in the pipeline
  53822. */
  53823. LensChromaticAberrationEffect: string;
  53824. /**
  53825. * @ignore
  53826. * The highlights enhancing PostProcess id in the pipeline
  53827. */
  53828. HighlightsEnhancingEffect: string;
  53829. /**
  53830. * @ignore
  53831. * The depth-of-field PostProcess id in the pipeline
  53832. */
  53833. LensDepthOfFieldEffect: string;
  53834. private _scene;
  53835. private _depthTexture;
  53836. private _grainTexture;
  53837. private _chromaticAberrationPostProcess;
  53838. private _highlightsPostProcess;
  53839. private _depthOfFieldPostProcess;
  53840. private _edgeBlur;
  53841. private _grainAmount;
  53842. private _chromaticAberration;
  53843. private _distortion;
  53844. private _highlightsGain;
  53845. private _highlightsThreshold;
  53846. private _dofDistance;
  53847. private _dofAperture;
  53848. private _dofDarken;
  53849. private _dofPentagon;
  53850. private _blurNoise;
  53851. /**
  53852. * @constructor
  53853. *
  53854. * Effect parameters are as follow:
  53855. * {
  53856. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53857. * edge_blur: number; // from 0 to x (1 for realism)
  53858. * distortion: number; // from 0 to x (1 for realism)
  53859. * grain_amount: number; // from 0 to 1
  53860. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53861. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53862. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53863. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53864. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53865. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53866. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53867. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53868. * }
  53869. * Note: if an effect parameter is unset, effect is disabled
  53870. *
  53871. * @param name The rendering pipeline name
  53872. * @param parameters - An object containing all parameters (see above)
  53873. * @param scene The scene linked to this pipeline
  53874. * @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)
  53875. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53876. */
  53877. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53878. /**
  53879. * Get the class name
  53880. * @returns "LensRenderingPipeline"
  53881. */
  53882. getClassName(): string;
  53883. /**
  53884. * Gets associated scene
  53885. */
  53886. readonly scene: Scene;
  53887. /**
  53888. * Gets or sets the edge blur
  53889. */
  53890. edgeBlur: number;
  53891. /**
  53892. * Gets or sets the grain amount
  53893. */
  53894. grainAmount: number;
  53895. /**
  53896. * Gets or sets the chromatic aberration amount
  53897. */
  53898. chromaticAberration: number;
  53899. /**
  53900. * Gets or sets the depth of field aperture
  53901. */
  53902. dofAperture: number;
  53903. /**
  53904. * Gets or sets the edge distortion
  53905. */
  53906. edgeDistortion: number;
  53907. /**
  53908. * Gets or sets the depth of field distortion
  53909. */
  53910. dofDistortion: number;
  53911. /**
  53912. * Gets or sets the darken out of focus amount
  53913. */
  53914. darkenOutOfFocus: number;
  53915. /**
  53916. * Gets or sets a boolean indicating if blur noise is enabled
  53917. */
  53918. blurNoise: boolean;
  53919. /**
  53920. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53921. */
  53922. pentagonBokeh: boolean;
  53923. /**
  53924. * Gets or sets the highlight grain amount
  53925. */
  53926. highlightsGain: number;
  53927. /**
  53928. * Gets or sets the highlight threshold
  53929. */
  53930. highlightsThreshold: number;
  53931. /**
  53932. * Sets the amount of blur at the edges
  53933. * @param amount blur amount
  53934. */
  53935. setEdgeBlur(amount: number): void;
  53936. /**
  53937. * Sets edge blur to 0
  53938. */
  53939. disableEdgeBlur(): void;
  53940. /**
  53941. * Sets the amout of grain
  53942. * @param amount Amount of grain
  53943. */
  53944. setGrainAmount(amount: number): void;
  53945. /**
  53946. * Set grain amount to 0
  53947. */
  53948. disableGrain(): void;
  53949. /**
  53950. * Sets the chromatic aberration amount
  53951. * @param amount amount of chromatic aberration
  53952. */
  53953. setChromaticAberration(amount: number): void;
  53954. /**
  53955. * Sets chromatic aberration amount to 0
  53956. */
  53957. disableChromaticAberration(): void;
  53958. /**
  53959. * Sets the EdgeDistortion amount
  53960. * @param amount amount of EdgeDistortion
  53961. */
  53962. setEdgeDistortion(amount: number): void;
  53963. /**
  53964. * Sets edge distortion to 0
  53965. */
  53966. disableEdgeDistortion(): void;
  53967. /**
  53968. * Sets the FocusDistance amount
  53969. * @param amount amount of FocusDistance
  53970. */
  53971. setFocusDistance(amount: number): void;
  53972. /**
  53973. * Disables depth of field
  53974. */
  53975. disableDepthOfField(): void;
  53976. /**
  53977. * Sets the Aperture amount
  53978. * @param amount amount of Aperture
  53979. */
  53980. setAperture(amount: number): void;
  53981. /**
  53982. * Sets the DarkenOutOfFocus amount
  53983. * @param amount amount of DarkenOutOfFocus
  53984. */
  53985. setDarkenOutOfFocus(amount: number): void;
  53986. private _pentagonBokehIsEnabled;
  53987. /**
  53988. * Creates a pentagon bokeh effect
  53989. */
  53990. enablePentagonBokeh(): void;
  53991. /**
  53992. * Disables the pentagon bokeh effect
  53993. */
  53994. disablePentagonBokeh(): void;
  53995. /**
  53996. * Enables noise blur
  53997. */
  53998. enableNoiseBlur(): void;
  53999. /**
  54000. * Disables noise blur
  54001. */
  54002. disableNoiseBlur(): void;
  54003. /**
  54004. * Sets the HighlightsGain amount
  54005. * @param amount amount of HighlightsGain
  54006. */
  54007. setHighlightsGain(amount: number): void;
  54008. /**
  54009. * Sets the HighlightsThreshold amount
  54010. * @param amount amount of HighlightsThreshold
  54011. */
  54012. setHighlightsThreshold(amount: number): void;
  54013. /**
  54014. * Disables highlights
  54015. */
  54016. disableHighlights(): void;
  54017. /**
  54018. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54019. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54020. */
  54021. dispose(disableDepthRender?: boolean): void;
  54022. private _createChromaticAberrationPostProcess;
  54023. private _createHighlightsPostProcess;
  54024. private _createDepthOfFieldPostProcess;
  54025. private _createGrainTexture;
  54026. }
  54027. }
  54028. declare module BABYLON {
  54029. /** @hidden */
  54030. export var ssao2PixelShader: {
  54031. name: string;
  54032. shader: string;
  54033. };
  54034. }
  54035. declare module BABYLON {
  54036. /** @hidden */
  54037. export var ssaoCombinePixelShader: {
  54038. name: string;
  54039. shader: string;
  54040. };
  54041. }
  54042. declare module BABYLON {
  54043. /**
  54044. * Render pipeline to produce ssao effect
  54045. */
  54046. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54047. /**
  54048. * @ignore
  54049. * The PassPostProcess id in the pipeline that contains the original scene color
  54050. */
  54051. SSAOOriginalSceneColorEffect: string;
  54052. /**
  54053. * @ignore
  54054. * The SSAO PostProcess id in the pipeline
  54055. */
  54056. SSAORenderEffect: string;
  54057. /**
  54058. * @ignore
  54059. * The horizontal blur PostProcess id in the pipeline
  54060. */
  54061. SSAOBlurHRenderEffect: string;
  54062. /**
  54063. * @ignore
  54064. * The vertical blur PostProcess id in the pipeline
  54065. */
  54066. SSAOBlurVRenderEffect: string;
  54067. /**
  54068. * @ignore
  54069. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54070. */
  54071. SSAOCombineRenderEffect: string;
  54072. /**
  54073. * The output strength of the SSAO post-process. Default value is 1.0.
  54074. */
  54075. totalStrength: number;
  54076. /**
  54077. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54078. */
  54079. maxZ: number;
  54080. /**
  54081. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54082. */
  54083. minZAspect: number;
  54084. private _samples;
  54085. /**
  54086. * Number of samples used for the SSAO calculations. Default value is 8
  54087. */
  54088. samples: number;
  54089. private _textureSamples;
  54090. /**
  54091. * Number of samples to use for antialiasing
  54092. */
  54093. textureSamples: number;
  54094. /**
  54095. * Ratio object used for SSAO ratio and blur ratio
  54096. */
  54097. private _ratio;
  54098. /**
  54099. * Dynamically generated sphere sampler.
  54100. */
  54101. private _sampleSphere;
  54102. /**
  54103. * Blur filter offsets
  54104. */
  54105. private _samplerOffsets;
  54106. private _expensiveBlur;
  54107. /**
  54108. * If bilateral blur should be used
  54109. */
  54110. expensiveBlur: boolean;
  54111. /**
  54112. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54113. */
  54114. radius: number;
  54115. /**
  54116. * The base color of the SSAO post-process
  54117. * The final result is "base + ssao" between [0, 1]
  54118. */
  54119. base: number;
  54120. /**
  54121. * Support test.
  54122. */
  54123. static readonly IsSupported: boolean;
  54124. private _scene;
  54125. private _depthTexture;
  54126. private _normalTexture;
  54127. private _randomTexture;
  54128. private _originalColorPostProcess;
  54129. private _ssaoPostProcess;
  54130. private _blurHPostProcess;
  54131. private _blurVPostProcess;
  54132. private _ssaoCombinePostProcess;
  54133. private _firstUpdate;
  54134. /**
  54135. * Gets active scene
  54136. */
  54137. readonly scene: Scene;
  54138. /**
  54139. * @constructor
  54140. * @param name The rendering pipeline name
  54141. * @param scene The scene linked to this pipeline
  54142. * @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 }
  54143. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54144. */
  54145. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54146. /**
  54147. * Get the class name
  54148. * @returns "SSAO2RenderingPipeline"
  54149. */
  54150. getClassName(): string;
  54151. /**
  54152. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54153. */
  54154. dispose(disableGeometryBufferRenderer?: boolean): void;
  54155. private _createBlurPostProcess;
  54156. /** @hidden */
  54157. _rebuild(): void;
  54158. private _bits;
  54159. private _radicalInverse_VdC;
  54160. private _hammersley;
  54161. private _hemisphereSample_uniform;
  54162. private _generateHemisphere;
  54163. private _createSSAOPostProcess;
  54164. private _createSSAOCombinePostProcess;
  54165. private _createRandomTexture;
  54166. /**
  54167. * Serialize the rendering pipeline (Used when exporting)
  54168. * @returns the serialized object
  54169. */
  54170. serialize(): any;
  54171. /**
  54172. * Parse the serialized pipeline
  54173. * @param source Source pipeline.
  54174. * @param scene The scene to load the pipeline to.
  54175. * @param rootUrl The URL of the serialized pipeline.
  54176. * @returns An instantiated pipeline from the serialized object.
  54177. */
  54178. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54179. }
  54180. }
  54181. declare module BABYLON {
  54182. /** @hidden */
  54183. export var ssaoPixelShader: {
  54184. name: string;
  54185. shader: string;
  54186. };
  54187. }
  54188. declare module BABYLON {
  54189. /**
  54190. * Render pipeline to produce ssao effect
  54191. */
  54192. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54193. /**
  54194. * @ignore
  54195. * The PassPostProcess id in the pipeline that contains the original scene color
  54196. */
  54197. SSAOOriginalSceneColorEffect: string;
  54198. /**
  54199. * @ignore
  54200. * The SSAO PostProcess id in the pipeline
  54201. */
  54202. SSAORenderEffect: string;
  54203. /**
  54204. * @ignore
  54205. * The horizontal blur PostProcess id in the pipeline
  54206. */
  54207. SSAOBlurHRenderEffect: string;
  54208. /**
  54209. * @ignore
  54210. * The vertical blur PostProcess id in the pipeline
  54211. */
  54212. SSAOBlurVRenderEffect: string;
  54213. /**
  54214. * @ignore
  54215. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54216. */
  54217. SSAOCombineRenderEffect: string;
  54218. /**
  54219. * The output strength of the SSAO post-process. Default value is 1.0.
  54220. */
  54221. totalStrength: number;
  54222. /**
  54223. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54224. */
  54225. radius: number;
  54226. /**
  54227. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54228. * Must not be equal to fallOff and superior to fallOff.
  54229. * Default value is 0.0075
  54230. */
  54231. area: number;
  54232. /**
  54233. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54234. * Must not be equal to area and inferior to area.
  54235. * Default value is 0.000001
  54236. */
  54237. fallOff: number;
  54238. /**
  54239. * The base color of the SSAO post-process
  54240. * The final result is "base + ssao" between [0, 1]
  54241. */
  54242. base: number;
  54243. private _scene;
  54244. private _depthTexture;
  54245. private _randomTexture;
  54246. private _originalColorPostProcess;
  54247. private _ssaoPostProcess;
  54248. private _blurHPostProcess;
  54249. private _blurVPostProcess;
  54250. private _ssaoCombinePostProcess;
  54251. private _firstUpdate;
  54252. /**
  54253. * Gets active scene
  54254. */
  54255. readonly scene: Scene;
  54256. /**
  54257. * @constructor
  54258. * @param name - The rendering pipeline name
  54259. * @param scene - The scene linked to this pipeline
  54260. * @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 }
  54261. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54262. */
  54263. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54264. /**
  54265. * Get the class name
  54266. * @returns "SSAORenderingPipeline"
  54267. */
  54268. getClassName(): string;
  54269. /**
  54270. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54271. */
  54272. dispose(disableDepthRender?: boolean): void;
  54273. private _createBlurPostProcess;
  54274. /** @hidden */
  54275. _rebuild(): void;
  54276. private _createSSAOPostProcess;
  54277. private _createSSAOCombinePostProcess;
  54278. private _createRandomTexture;
  54279. }
  54280. }
  54281. declare module BABYLON {
  54282. /** @hidden */
  54283. export var standardPixelShader: {
  54284. name: string;
  54285. shader: string;
  54286. };
  54287. }
  54288. declare module BABYLON {
  54289. /**
  54290. * Standard rendering pipeline
  54291. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54292. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54293. */
  54294. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54295. /**
  54296. * Public members
  54297. */
  54298. /**
  54299. * Post-process which contains the original scene color before the pipeline applies all the effects
  54300. */
  54301. originalPostProcess: Nullable<PostProcess>;
  54302. /**
  54303. * Post-process used to down scale an image x4
  54304. */
  54305. downSampleX4PostProcess: Nullable<PostProcess>;
  54306. /**
  54307. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54308. */
  54309. brightPassPostProcess: Nullable<PostProcess>;
  54310. /**
  54311. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54312. */
  54313. blurHPostProcesses: PostProcess[];
  54314. /**
  54315. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54316. */
  54317. blurVPostProcesses: PostProcess[];
  54318. /**
  54319. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54320. */
  54321. textureAdderPostProcess: Nullable<PostProcess>;
  54322. /**
  54323. * Post-process used to create volumetric lighting effect
  54324. */
  54325. volumetricLightPostProcess: Nullable<PostProcess>;
  54326. /**
  54327. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54328. */
  54329. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54330. /**
  54331. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54332. */
  54333. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54334. /**
  54335. * Post-process used to merge the volumetric light effect and the real scene color
  54336. */
  54337. volumetricLightMergePostProces: Nullable<PostProcess>;
  54338. /**
  54339. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54340. */
  54341. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54342. /**
  54343. * Base post-process used to calculate the average luminance of the final image for HDR
  54344. */
  54345. luminancePostProcess: Nullable<PostProcess>;
  54346. /**
  54347. * Post-processes used to create down sample post-processes in order to get
  54348. * the average luminance of the final image for HDR
  54349. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54350. */
  54351. luminanceDownSamplePostProcesses: PostProcess[];
  54352. /**
  54353. * Post-process used to create a HDR effect (light adaptation)
  54354. */
  54355. hdrPostProcess: Nullable<PostProcess>;
  54356. /**
  54357. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54358. */
  54359. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54360. /**
  54361. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54362. */
  54363. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54364. /**
  54365. * Post-process used to merge the final HDR post-process and the real scene color
  54366. */
  54367. hdrFinalPostProcess: Nullable<PostProcess>;
  54368. /**
  54369. * Post-process used to create a lens flare effect
  54370. */
  54371. lensFlarePostProcess: Nullable<PostProcess>;
  54372. /**
  54373. * Post-process that merges the result of the lens flare post-process and the real scene color
  54374. */
  54375. lensFlareComposePostProcess: Nullable<PostProcess>;
  54376. /**
  54377. * Post-process used to create a motion blur effect
  54378. */
  54379. motionBlurPostProcess: Nullable<PostProcess>;
  54380. /**
  54381. * Post-process used to create a depth of field effect
  54382. */
  54383. depthOfFieldPostProcess: Nullable<PostProcess>;
  54384. /**
  54385. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54386. */
  54387. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54388. /**
  54389. * Represents the brightness threshold in order to configure the illuminated surfaces
  54390. */
  54391. brightThreshold: number;
  54392. /**
  54393. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54394. */
  54395. blurWidth: number;
  54396. /**
  54397. * Sets if the blur for highlighted surfaces must be only horizontal
  54398. */
  54399. horizontalBlur: boolean;
  54400. /**
  54401. * Gets the overall exposure used by the pipeline
  54402. */
  54403. /**
  54404. * Sets the overall exposure used by the pipeline
  54405. */
  54406. exposure: number;
  54407. /**
  54408. * Texture used typically to simulate "dirty" on camera lens
  54409. */
  54410. lensTexture: Nullable<Texture>;
  54411. /**
  54412. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54413. */
  54414. volumetricLightCoefficient: number;
  54415. /**
  54416. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54417. */
  54418. volumetricLightPower: number;
  54419. /**
  54420. * Used the set the blur intensity to smooth the volumetric lights
  54421. */
  54422. volumetricLightBlurScale: number;
  54423. /**
  54424. * Light (spot or directional) used to generate the volumetric lights rays
  54425. * The source light must have a shadow generate so the pipeline can get its
  54426. * depth map
  54427. */
  54428. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54429. /**
  54430. * For eye adaptation, represents the minimum luminance the eye can see
  54431. */
  54432. hdrMinimumLuminance: number;
  54433. /**
  54434. * For eye adaptation, represents the decrease luminance speed
  54435. */
  54436. hdrDecreaseRate: number;
  54437. /**
  54438. * For eye adaptation, represents the increase luminance speed
  54439. */
  54440. hdrIncreaseRate: number;
  54441. /**
  54442. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54443. */
  54444. /**
  54445. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54446. */
  54447. hdrAutoExposure: boolean;
  54448. /**
  54449. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54450. */
  54451. lensColorTexture: Nullable<Texture>;
  54452. /**
  54453. * The overall strengh for the lens flare effect
  54454. */
  54455. lensFlareStrength: number;
  54456. /**
  54457. * Dispersion coefficient for lens flare ghosts
  54458. */
  54459. lensFlareGhostDispersal: number;
  54460. /**
  54461. * Main lens flare halo width
  54462. */
  54463. lensFlareHaloWidth: number;
  54464. /**
  54465. * Based on the lens distortion effect, defines how much the lens flare result
  54466. * is distorted
  54467. */
  54468. lensFlareDistortionStrength: number;
  54469. /**
  54470. * Lens star texture must be used to simulate rays on the flares and is available
  54471. * in the documentation
  54472. */
  54473. lensStarTexture: Nullable<Texture>;
  54474. /**
  54475. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54476. * flare effect by taking account of the dirt texture
  54477. */
  54478. lensFlareDirtTexture: Nullable<Texture>;
  54479. /**
  54480. * Represents the focal length for the depth of field effect
  54481. */
  54482. depthOfFieldDistance: number;
  54483. /**
  54484. * Represents the blur intensity for the blurred part of the depth of field effect
  54485. */
  54486. depthOfFieldBlurWidth: number;
  54487. /**
  54488. * For motion blur, defines how much the image is blurred by the movement
  54489. */
  54490. motionStrength: number;
  54491. /**
  54492. * List of animations for the pipeline (IAnimatable implementation)
  54493. */
  54494. animations: Animation[];
  54495. /**
  54496. * Private members
  54497. */
  54498. private _scene;
  54499. private _currentDepthOfFieldSource;
  54500. private _basePostProcess;
  54501. private _fixedExposure;
  54502. private _currentExposure;
  54503. private _hdrAutoExposure;
  54504. private _hdrCurrentLuminance;
  54505. private _floatTextureType;
  54506. private _ratio;
  54507. private _bloomEnabled;
  54508. private _depthOfFieldEnabled;
  54509. private _vlsEnabled;
  54510. private _lensFlareEnabled;
  54511. private _hdrEnabled;
  54512. private _motionBlurEnabled;
  54513. private _fxaaEnabled;
  54514. private _motionBlurSamples;
  54515. private _volumetricLightStepsCount;
  54516. private _samples;
  54517. /**
  54518. * @ignore
  54519. * Specifies if the bloom pipeline is enabled
  54520. */
  54521. BloomEnabled: boolean;
  54522. /**
  54523. * @ignore
  54524. * Specifies if the depth of field pipeline is enabed
  54525. */
  54526. DepthOfFieldEnabled: boolean;
  54527. /**
  54528. * @ignore
  54529. * Specifies if the lens flare pipeline is enabed
  54530. */
  54531. LensFlareEnabled: boolean;
  54532. /**
  54533. * @ignore
  54534. * Specifies if the HDR pipeline is enabled
  54535. */
  54536. HDREnabled: boolean;
  54537. /**
  54538. * @ignore
  54539. * Specifies if the volumetric lights scattering effect is enabled
  54540. */
  54541. VLSEnabled: boolean;
  54542. /**
  54543. * @ignore
  54544. * Specifies if the motion blur effect is enabled
  54545. */
  54546. MotionBlurEnabled: boolean;
  54547. /**
  54548. * Specifies if anti-aliasing is enabled
  54549. */
  54550. fxaaEnabled: boolean;
  54551. /**
  54552. * Specifies the number of steps used to calculate the volumetric lights
  54553. * Typically in interval [50, 200]
  54554. */
  54555. volumetricLightStepsCount: number;
  54556. /**
  54557. * Specifies the number of samples used for the motion blur effect
  54558. * Typically in interval [16, 64]
  54559. */
  54560. motionBlurSamples: number;
  54561. /**
  54562. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54563. */
  54564. samples: number;
  54565. /**
  54566. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54567. * @constructor
  54568. * @param name The rendering pipeline name
  54569. * @param scene The scene linked to this pipeline
  54570. * @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)
  54571. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54572. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54573. */
  54574. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54575. private _buildPipeline;
  54576. private _createDownSampleX4PostProcess;
  54577. private _createBrightPassPostProcess;
  54578. private _createBlurPostProcesses;
  54579. private _createTextureAdderPostProcess;
  54580. private _createVolumetricLightPostProcess;
  54581. private _createLuminancePostProcesses;
  54582. private _createHdrPostProcess;
  54583. private _createLensFlarePostProcess;
  54584. private _createDepthOfFieldPostProcess;
  54585. private _createMotionBlurPostProcess;
  54586. private _getDepthTexture;
  54587. private _disposePostProcesses;
  54588. /**
  54589. * Dispose of the pipeline and stop all post processes
  54590. */
  54591. dispose(): void;
  54592. /**
  54593. * Serialize the rendering pipeline (Used when exporting)
  54594. * @returns the serialized object
  54595. */
  54596. serialize(): any;
  54597. /**
  54598. * Parse the serialized pipeline
  54599. * @param source Source pipeline.
  54600. * @param scene The scene to load the pipeline to.
  54601. * @param rootUrl The URL of the serialized pipeline.
  54602. * @returns An instantiated pipeline from the serialized object.
  54603. */
  54604. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54605. /**
  54606. * Luminance steps
  54607. */
  54608. static LuminanceSteps: number;
  54609. }
  54610. }
  54611. declare module BABYLON {
  54612. /** @hidden */
  54613. export var tonemapPixelShader: {
  54614. name: string;
  54615. shader: string;
  54616. };
  54617. }
  54618. declare module BABYLON {
  54619. /** Defines operator used for tonemapping */
  54620. export enum TonemappingOperator {
  54621. /** Hable */
  54622. Hable = 0,
  54623. /** Reinhard */
  54624. Reinhard = 1,
  54625. /** HejiDawson */
  54626. HejiDawson = 2,
  54627. /** Photographic */
  54628. Photographic = 3
  54629. }
  54630. /**
  54631. * Defines a post process to apply tone mapping
  54632. */
  54633. export class TonemapPostProcess extends PostProcess {
  54634. private _operator;
  54635. /** Defines the required exposure adjustement */
  54636. exposureAdjustment: number;
  54637. /**
  54638. * Creates a new TonemapPostProcess
  54639. * @param name defines the name of the postprocess
  54640. * @param _operator defines the operator to use
  54641. * @param exposureAdjustment defines the required exposure adjustement
  54642. * @param camera defines the camera to use (can be null)
  54643. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54644. * @param engine defines the hosting engine (can be ignore if camera is set)
  54645. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54646. */
  54647. constructor(name: string, _operator: TonemappingOperator,
  54648. /** Defines the required exposure adjustement */
  54649. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54650. }
  54651. }
  54652. declare module BABYLON {
  54653. /** @hidden */
  54654. export var depthVertexShader: {
  54655. name: string;
  54656. shader: string;
  54657. };
  54658. }
  54659. declare module BABYLON {
  54660. /** @hidden */
  54661. export var volumetricLightScatteringPixelShader: {
  54662. name: string;
  54663. shader: string;
  54664. };
  54665. }
  54666. declare module BABYLON {
  54667. /** @hidden */
  54668. export var volumetricLightScatteringPassPixelShader: {
  54669. name: string;
  54670. shader: string;
  54671. };
  54672. }
  54673. declare module BABYLON {
  54674. /**
  54675. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54676. */
  54677. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54678. private _volumetricLightScatteringPass;
  54679. private _volumetricLightScatteringRTT;
  54680. private _viewPort;
  54681. private _screenCoordinates;
  54682. private _cachedDefines;
  54683. /**
  54684. * If not undefined, the mesh position is computed from the attached node position
  54685. */
  54686. attachedNode: {
  54687. position: Vector3;
  54688. };
  54689. /**
  54690. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54691. */
  54692. customMeshPosition: Vector3;
  54693. /**
  54694. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54695. */
  54696. useCustomMeshPosition: boolean;
  54697. /**
  54698. * If the post-process should inverse the light scattering direction
  54699. */
  54700. invert: boolean;
  54701. /**
  54702. * The internal mesh used by the post-process
  54703. */
  54704. mesh: Mesh;
  54705. /**
  54706. * @hidden
  54707. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54708. */
  54709. useDiffuseColor: boolean;
  54710. /**
  54711. * Array containing the excluded meshes not rendered in the internal pass
  54712. */
  54713. excludedMeshes: AbstractMesh[];
  54714. /**
  54715. * Controls the overall intensity of the post-process
  54716. */
  54717. exposure: number;
  54718. /**
  54719. * Dissipates each sample's contribution in range [0, 1]
  54720. */
  54721. decay: number;
  54722. /**
  54723. * Controls the overall intensity of each sample
  54724. */
  54725. weight: number;
  54726. /**
  54727. * Controls the density of each sample
  54728. */
  54729. density: number;
  54730. /**
  54731. * @constructor
  54732. * @param name The post-process name
  54733. * @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)
  54734. * @param camera The camera that the post-process will be attached to
  54735. * @param mesh The mesh used to create the light scattering
  54736. * @param samples The post-process quality, default 100
  54737. * @param samplingModeThe post-process filtering mode
  54738. * @param engine The babylon engine
  54739. * @param reusable If the post-process is reusable
  54740. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54741. */
  54742. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54743. /**
  54744. * Returns the string "VolumetricLightScatteringPostProcess"
  54745. * @returns "VolumetricLightScatteringPostProcess"
  54746. */
  54747. getClassName(): string;
  54748. private _isReady;
  54749. /**
  54750. * Sets the new light position for light scattering effect
  54751. * @param position The new custom light position
  54752. */
  54753. setCustomMeshPosition(position: Vector3): void;
  54754. /**
  54755. * Returns the light position for light scattering effect
  54756. * @return Vector3 The custom light position
  54757. */
  54758. getCustomMeshPosition(): Vector3;
  54759. /**
  54760. * Disposes the internal assets and detaches the post-process from the camera
  54761. */
  54762. dispose(camera: Camera): void;
  54763. /**
  54764. * Returns the render target texture used by the post-process
  54765. * @return the render target texture used by the post-process
  54766. */
  54767. getPass(): RenderTargetTexture;
  54768. private _meshExcluded;
  54769. private _createPass;
  54770. private _updateMeshScreenCoordinates;
  54771. /**
  54772. * Creates a default mesh for the Volumeric Light Scattering post-process
  54773. * @param name The mesh name
  54774. * @param scene The scene where to create the mesh
  54775. * @return the default mesh
  54776. */
  54777. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54778. }
  54779. }
  54780. declare module BABYLON {
  54781. interface Scene {
  54782. /** @hidden (Backing field) */
  54783. _boundingBoxRenderer: BoundingBoxRenderer;
  54784. /** @hidden (Backing field) */
  54785. _forceShowBoundingBoxes: boolean;
  54786. /**
  54787. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54788. */
  54789. forceShowBoundingBoxes: boolean;
  54790. /**
  54791. * Gets the bounding box renderer associated with the scene
  54792. * @returns a BoundingBoxRenderer
  54793. */
  54794. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54795. }
  54796. interface AbstractMesh {
  54797. /** @hidden (Backing field) */
  54798. _showBoundingBox: boolean;
  54799. /**
  54800. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54801. */
  54802. showBoundingBox: boolean;
  54803. }
  54804. /**
  54805. * Component responsible of rendering the bounding box of the meshes in a scene.
  54806. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54807. */
  54808. export class BoundingBoxRenderer implements ISceneComponent {
  54809. /**
  54810. * The component name helpfull to identify the component in the list of scene components.
  54811. */
  54812. readonly name: string;
  54813. /**
  54814. * The scene the component belongs to.
  54815. */
  54816. scene: Scene;
  54817. /**
  54818. * Color of the bounding box lines placed in front of an object
  54819. */
  54820. frontColor: Color3;
  54821. /**
  54822. * Color of the bounding box lines placed behind an object
  54823. */
  54824. backColor: Color3;
  54825. /**
  54826. * Defines if the renderer should show the back lines or not
  54827. */
  54828. showBackLines: boolean;
  54829. /**
  54830. * @hidden
  54831. */
  54832. renderList: SmartArray<BoundingBox>;
  54833. private _colorShader;
  54834. private _vertexBuffers;
  54835. private _indexBuffer;
  54836. /**
  54837. * Instantiates a new bounding box renderer in a scene.
  54838. * @param scene the scene the renderer renders in
  54839. */
  54840. constructor(scene: Scene);
  54841. /**
  54842. * Registers the component in a given scene
  54843. */
  54844. register(): void;
  54845. private _evaluateSubMesh;
  54846. private _activeMesh;
  54847. private _prepareRessources;
  54848. private _createIndexBuffer;
  54849. /**
  54850. * Rebuilds the elements related to this component in case of
  54851. * context lost for instance.
  54852. */
  54853. rebuild(): void;
  54854. /**
  54855. * @hidden
  54856. */
  54857. reset(): void;
  54858. /**
  54859. * Render the bounding boxes of a specific rendering group
  54860. * @param renderingGroupId defines the rendering group to render
  54861. */
  54862. render(renderingGroupId: number): void;
  54863. /**
  54864. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54865. * @param mesh Define the mesh to render the occlusion bounding box for
  54866. */
  54867. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54868. /**
  54869. * Dispose and release the resources attached to this renderer.
  54870. */
  54871. dispose(): void;
  54872. }
  54873. }
  54874. declare module BABYLON {
  54875. /** @hidden */
  54876. export var depthPixelShader: {
  54877. name: string;
  54878. shader: string;
  54879. };
  54880. }
  54881. declare module BABYLON {
  54882. /**
  54883. * This represents a depth renderer in Babylon.
  54884. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54885. */
  54886. export class DepthRenderer {
  54887. private _scene;
  54888. private _depthMap;
  54889. private _effect;
  54890. private _cachedDefines;
  54891. private _camera;
  54892. /**
  54893. * Specifiess that the depth renderer will only be used within
  54894. * the camera it is created for.
  54895. * This can help forcing its rendering during the camera processing.
  54896. */
  54897. useOnlyInActiveCamera: boolean;
  54898. /** @hidden */
  54899. static _SceneComponentInitialization: (scene: Scene) => void;
  54900. /**
  54901. * Instantiates a depth renderer
  54902. * @param scene The scene the renderer belongs to
  54903. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54904. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54905. */
  54906. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54907. /**
  54908. * Creates the depth rendering effect and checks if the effect is ready.
  54909. * @param subMesh The submesh to be used to render the depth map of
  54910. * @param useInstances If multiple world instances should be used
  54911. * @returns if the depth renderer is ready to render the depth map
  54912. */
  54913. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54914. /**
  54915. * Gets the texture which the depth map will be written to.
  54916. * @returns The depth map texture
  54917. */
  54918. getDepthMap(): RenderTargetTexture;
  54919. /**
  54920. * Disposes of the depth renderer.
  54921. */
  54922. dispose(): void;
  54923. }
  54924. }
  54925. declare module BABYLON {
  54926. interface Scene {
  54927. /** @hidden (Backing field) */
  54928. _depthRenderer: {
  54929. [id: string]: DepthRenderer;
  54930. };
  54931. /**
  54932. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54933. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54934. * @returns the created depth renderer
  54935. */
  54936. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54937. /**
  54938. * Disables a depth renderer for a given camera
  54939. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54940. */
  54941. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54942. }
  54943. /**
  54944. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54945. * in several rendering techniques.
  54946. */
  54947. export class DepthRendererSceneComponent implements ISceneComponent {
  54948. /**
  54949. * The component name helpfull to identify the component in the list of scene components.
  54950. */
  54951. readonly name: string;
  54952. /**
  54953. * The scene the component belongs to.
  54954. */
  54955. scene: Scene;
  54956. /**
  54957. * Creates a new instance of the component for the given scene
  54958. * @param scene Defines the scene to register the component in
  54959. */
  54960. constructor(scene: Scene);
  54961. /**
  54962. * Registers the component in a given scene
  54963. */
  54964. register(): void;
  54965. /**
  54966. * Rebuilds the elements related to this component in case of
  54967. * context lost for instance.
  54968. */
  54969. rebuild(): void;
  54970. /**
  54971. * Disposes the component and the associated ressources
  54972. */
  54973. dispose(): void;
  54974. private _gatherRenderTargets;
  54975. private _gatherActiveCameraRenderTargets;
  54976. }
  54977. }
  54978. declare module BABYLON {
  54979. /** @hidden */
  54980. export var outlinePixelShader: {
  54981. name: string;
  54982. shader: string;
  54983. };
  54984. }
  54985. declare module BABYLON {
  54986. /** @hidden */
  54987. export var outlineVertexShader: {
  54988. name: string;
  54989. shader: string;
  54990. };
  54991. }
  54992. declare module BABYLON {
  54993. interface Scene {
  54994. /** @hidden */
  54995. _outlineRenderer: OutlineRenderer;
  54996. /**
  54997. * Gets the outline renderer associated with the scene
  54998. * @returns a OutlineRenderer
  54999. */
  55000. getOutlineRenderer(): OutlineRenderer;
  55001. }
  55002. interface AbstractMesh {
  55003. /** @hidden (Backing field) */
  55004. _renderOutline: boolean;
  55005. /**
  55006. * Gets or sets a boolean indicating if the outline must be rendered as well
  55007. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55008. */
  55009. renderOutline: boolean;
  55010. /** @hidden (Backing field) */
  55011. _renderOverlay: boolean;
  55012. /**
  55013. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55014. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55015. */
  55016. renderOverlay: boolean;
  55017. }
  55018. /**
  55019. * This class is responsible to draw bothe outline/overlay of meshes.
  55020. * It should not be used directly but through the available method on mesh.
  55021. */
  55022. export class OutlineRenderer implements ISceneComponent {
  55023. /**
  55024. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  55025. */
  55026. private static _StencilReference;
  55027. /**
  55028. * The name of the component. Each component must have a unique name.
  55029. */
  55030. name: string;
  55031. /**
  55032. * The scene the component belongs to.
  55033. */
  55034. scene: Scene;
  55035. /**
  55036. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55037. */
  55038. zOffset: number;
  55039. private _engine;
  55040. private _effect;
  55041. private _cachedDefines;
  55042. private _savedDepthWrite;
  55043. /**
  55044. * Instantiates a new outline renderer. (There could be only one per scene).
  55045. * @param scene Defines the scene it belongs to
  55046. */
  55047. constructor(scene: Scene);
  55048. /**
  55049. * Register the component to one instance of a scene.
  55050. */
  55051. register(): void;
  55052. /**
  55053. * Rebuilds the elements related to this component in case of
  55054. * context lost for instance.
  55055. */
  55056. rebuild(): void;
  55057. /**
  55058. * Disposes the component and the associated ressources.
  55059. */
  55060. dispose(): void;
  55061. /**
  55062. * Renders the outline in the canvas.
  55063. * @param subMesh Defines the sumesh to render
  55064. * @param batch Defines the batch of meshes in case of instances
  55065. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55066. */
  55067. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55068. /**
  55069. * Returns whether or not the outline renderer is ready for a given submesh.
  55070. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55071. * @param subMesh Defines the submesh to check readyness for
  55072. * @param useInstances Defines wheter wee are trying to render instances or not
  55073. * @returns true if ready otherwise false
  55074. */
  55075. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55076. private _beforeRenderingMesh;
  55077. private _afterRenderingMesh;
  55078. }
  55079. }
  55080. declare module BABYLON {
  55081. /**
  55082. * Defines the list of states available for a task inside a AssetsManager
  55083. */
  55084. export enum AssetTaskState {
  55085. /**
  55086. * Initialization
  55087. */
  55088. INIT = 0,
  55089. /**
  55090. * Running
  55091. */
  55092. RUNNING = 1,
  55093. /**
  55094. * Done
  55095. */
  55096. DONE = 2,
  55097. /**
  55098. * Error
  55099. */
  55100. ERROR = 3
  55101. }
  55102. /**
  55103. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55104. */
  55105. export abstract class AbstractAssetTask {
  55106. /**
  55107. * Task name
  55108. */ name: string;
  55109. /**
  55110. * Callback called when the task is successful
  55111. */
  55112. onSuccess: (task: any) => void;
  55113. /**
  55114. * Callback called when the task is not successful
  55115. */
  55116. onError: (task: any, message?: string, exception?: any) => void;
  55117. /**
  55118. * Creates a new AssetsManager
  55119. * @param name defines the name of the task
  55120. */
  55121. constructor(
  55122. /**
  55123. * Task name
  55124. */ name: string);
  55125. private _isCompleted;
  55126. private _taskState;
  55127. private _errorObject;
  55128. /**
  55129. * Get if the task is completed
  55130. */
  55131. readonly isCompleted: boolean;
  55132. /**
  55133. * Gets the current state of the task
  55134. */
  55135. readonly taskState: AssetTaskState;
  55136. /**
  55137. * Gets the current error object (if task is in error)
  55138. */
  55139. readonly errorObject: {
  55140. message?: string;
  55141. exception?: any;
  55142. };
  55143. /**
  55144. * Internal only
  55145. * @hidden
  55146. */
  55147. _setErrorObject(message?: string, exception?: any): void;
  55148. /**
  55149. * Execute the current task
  55150. * @param scene defines the scene where you want your assets to be loaded
  55151. * @param onSuccess is a callback called when the task is successfully executed
  55152. * @param onError is a callback called if an error occurs
  55153. */
  55154. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55155. /**
  55156. * Execute the current task
  55157. * @param scene defines the scene where you want your assets to be loaded
  55158. * @param onSuccess is a callback called when the task is successfully executed
  55159. * @param onError is a callback called if an error occurs
  55160. */
  55161. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55162. /**
  55163. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55164. * This can be used with failed tasks that have the reason for failure fixed.
  55165. */
  55166. reset(): void;
  55167. private onErrorCallback;
  55168. private onDoneCallback;
  55169. }
  55170. /**
  55171. * Define the interface used by progress events raised during assets loading
  55172. */
  55173. export interface IAssetsProgressEvent {
  55174. /**
  55175. * Defines the number of remaining tasks to process
  55176. */
  55177. remainingCount: number;
  55178. /**
  55179. * Defines the total number of tasks
  55180. */
  55181. totalCount: number;
  55182. /**
  55183. * Defines the task that was just processed
  55184. */
  55185. task: AbstractAssetTask;
  55186. }
  55187. /**
  55188. * Class used to share progress information about assets loading
  55189. */
  55190. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55191. /**
  55192. * Defines the number of remaining tasks to process
  55193. */
  55194. remainingCount: number;
  55195. /**
  55196. * Defines the total number of tasks
  55197. */
  55198. totalCount: number;
  55199. /**
  55200. * Defines the task that was just processed
  55201. */
  55202. task: AbstractAssetTask;
  55203. /**
  55204. * Creates a AssetsProgressEvent
  55205. * @param remainingCount defines the number of remaining tasks to process
  55206. * @param totalCount defines the total number of tasks
  55207. * @param task defines the task that was just processed
  55208. */
  55209. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55210. }
  55211. /**
  55212. * Define a task used by AssetsManager to load meshes
  55213. */
  55214. export class MeshAssetTask extends AbstractAssetTask {
  55215. /**
  55216. * Defines the name of the task
  55217. */
  55218. name: string;
  55219. /**
  55220. * Defines the list of mesh's names you want to load
  55221. */
  55222. meshesNames: any;
  55223. /**
  55224. * Defines the root url to use as a base to load your meshes and associated resources
  55225. */
  55226. rootUrl: string;
  55227. /**
  55228. * Defines the filename of the scene to load from
  55229. */
  55230. sceneFilename: string;
  55231. /**
  55232. * Gets the list of loaded meshes
  55233. */
  55234. loadedMeshes: Array<AbstractMesh>;
  55235. /**
  55236. * Gets the list of loaded particle systems
  55237. */
  55238. loadedParticleSystems: Array<IParticleSystem>;
  55239. /**
  55240. * Gets the list of loaded skeletons
  55241. */
  55242. loadedSkeletons: Array<Skeleton>;
  55243. /**
  55244. * Gets the list of loaded animation groups
  55245. */
  55246. loadedAnimationGroups: Array<AnimationGroup>;
  55247. /**
  55248. * Callback called when the task is successful
  55249. */
  55250. onSuccess: (task: MeshAssetTask) => void;
  55251. /**
  55252. * Callback called when the task is successful
  55253. */
  55254. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55255. /**
  55256. * Creates a new MeshAssetTask
  55257. * @param name defines the name of the task
  55258. * @param meshesNames defines the list of mesh's names you want to load
  55259. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55260. * @param sceneFilename defines the filename of the scene to load from
  55261. */
  55262. constructor(
  55263. /**
  55264. * Defines the name of the task
  55265. */
  55266. name: string,
  55267. /**
  55268. * Defines the list of mesh's names you want to load
  55269. */
  55270. meshesNames: any,
  55271. /**
  55272. * Defines the root url to use as a base to load your meshes and associated resources
  55273. */
  55274. rootUrl: string,
  55275. /**
  55276. * Defines the filename of the scene to load from
  55277. */
  55278. sceneFilename: string);
  55279. /**
  55280. * Execute the current task
  55281. * @param scene defines the scene where you want your assets to be loaded
  55282. * @param onSuccess is a callback called when the task is successfully executed
  55283. * @param onError is a callback called if an error occurs
  55284. */
  55285. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55286. }
  55287. /**
  55288. * Define a task used by AssetsManager to load text content
  55289. */
  55290. export class TextFileAssetTask extends AbstractAssetTask {
  55291. /**
  55292. * Defines the name of the task
  55293. */
  55294. name: string;
  55295. /**
  55296. * Defines the location of the file to load
  55297. */
  55298. url: string;
  55299. /**
  55300. * Gets the loaded text string
  55301. */
  55302. text: string;
  55303. /**
  55304. * Callback called when the task is successful
  55305. */
  55306. onSuccess: (task: TextFileAssetTask) => void;
  55307. /**
  55308. * Callback called when the task is successful
  55309. */
  55310. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55311. /**
  55312. * Creates a new TextFileAssetTask object
  55313. * @param name defines the name of the task
  55314. * @param url defines the location of the file to load
  55315. */
  55316. constructor(
  55317. /**
  55318. * Defines the name of the task
  55319. */
  55320. name: string,
  55321. /**
  55322. * Defines the location of the file to load
  55323. */
  55324. url: string);
  55325. /**
  55326. * Execute the current task
  55327. * @param scene defines the scene where you want your assets to be loaded
  55328. * @param onSuccess is a callback called when the task is successfully executed
  55329. * @param onError is a callback called if an error occurs
  55330. */
  55331. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55332. }
  55333. /**
  55334. * Define a task used by AssetsManager to load binary data
  55335. */
  55336. export class BinaryFileAssetTask extends AbstractAssetTask {
  55337. /**
  55338. * Defines the name of the task
  55339. */
  55340. name: string;
  55341. /**
  55342. * Defines the location of the file to load
  55343. */
  55344. url: string;
  55345. /**
  55346. * Gets the lodaded data (as an array buffer)
  55347. */
  55348. data: ArrayBuffer;
  55349. /**
  55350. * Callback called when the task is successful
  55351. */
  55352. onSuccess: (task: BinaryFileAssetTask) => void;
  55353. /**
  55354. * Callback called when the task is successful
  55355. */
  55356. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55357. /**
  55358. * Creates a new BinaryFileAssetTask object
  55359. * @param name defines the name of the new task
  55360. * @param url defines the location of the file to load
  55361. */
  55362. constructor(
  55363. /**
  55364. * Defines the name of the task
  55365. */
  55366. name: string,
  55367. /**
  55368. * Defines the location of the file to load
  55369. */
  55370. url: string);
  55371. /**
  55372. * Execute the current task
  55373. * @param scene defines the scene where you want your assets to be loaded
  55374. * @param onSuccess is a callback called when the task is successfully executed
  55375. * @param onError is a callback called if an error occurs
  55376. */
  55377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55378. }
  55379. /**
  55380. * Define a task used by AssetsManager to load images
  55381. */
  55382. export class ImageAssetTask extends AbstractAssetTask {
  55383. /**
  55384. * Defines the name of the task
  55385. */
  55386. name: string;
  55387. /**
  55388. * Defines the location of the image to load
  55389. */
  55390. url: string;
  55391. /**
  55392. * Gets the loaded images
  55393. */
  55394. image: HTMLImageElement;
  55395. /**
  55396. * Callback called when the task is successful
  55397. */
  55398. onSuccess: (task: ImageAssetTask) => void;
  55399. /**
  55400. * Callback called when the task is successful
  55401. */
  55402. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55403. /**
  55404. * Creates a new ImageAssetTask
  55405. * @param name defines the name of the task
  55406. * @param url defines the location of the image to load
  55407. */
  55408. constructor(
  55409. /**
  55410. * Defines the name of the task
  55411. */
  55412. name: string,
  55413. /**
  55414. * Defines the location of the image to load
  55415. */
  55416. url: string);
  55417. /**
  55418. * Execute the current task
  55419. * @param scene defines the scene where you want your assets to be loaded
  55420. * @param onSuccess is a callback called when the task is successfully executed
  55421. * @param onError is a callback called if an error occurs
  55422. */
  55423. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55424. }
  55425. /**
  55426. * Defines the interface used by texture loading tasks
  55427. */
  55428. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55429. /**
  55430. * Gets the loaded texture
  55431. */
  55432. texture: TEX;
  55433. }
  55434. /**
  55435. * Define a task used by AssetsManager to load 2D textures
  55436. */
  55437. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55438. /**
  55439. * Defines the name of the task
  55440. */
  55441. name: string;
  55442. /**
  55443. * Defines the location of the file to load
  55444. */
  55445. url: string;
  55446. /**
  55447. * Defines if mipmap should not be generated (default is false)
  55448. */
  55449. noMipmap?: boolean | undefined;
  55450. /**
  55451. * Defines if texture must be inverted on Y axis (default is false)
  55452. */
  55453. invertY?: boolean | undefined;
  55454. /**
  55455. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55456. */
  55457. samplingMode: number;
  55458. /**
  55459. * Gets the loaded texture
  55460. */
  55461. texture: Texture;
  55462. /**
  55463. * Callback called when the task is successful
  55464. */
  55465. onSuccess: (task: TextureAssetTask) => void;
  55466. /**
  55467. * Callback called when the task is successful
  55468. */
  55469. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55470. /**
  55471. * Creates a new TextureAssetTask object
  55472. * @param name defines the name of the task
  55473. * @param url defines the location of the file to load
  55474. * @param noMipmap defines if mipmap should not be generated (default is false)
  55475. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55476. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55477. */
  55478. constructor(
  55479. /**
  55480. * Defines the name of the task
  55481. */
  55482. name: string,
  55483. /**
  55484. * Defines the location of the file to load
  55485. */
  55486. url: string,
  55487. /**
  55488. * Defines if mipmap should not be generated (default is false)
  55489. */
  55490. noMipmap?: boolean | undefined,
  55491. /**
  55492. * Defines if texture must be inverted on Y axis (default is false)
  55493. */
  55494. invertY?: boolean | undefined,
  55495. /**
  55496. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55497. */
  55498. samplingMode?: number);
  55499. /**
  55500. * Execute the current task
  55501. * @param scene defines the scene where you want your assets to be loaded
  55502. * @param onSuccess is a callback called when the task is successfully executed
  55503. * @param onError is a callback called if an error occurs
  55504. */
  55505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55506. }
  55507. /**
  55508. * Define a task used by AssetsManager to load cube textures
  55509. */
  55510. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55511. /**
  55512. * Defines the name of the task
  55513. */
  55514. name: string;
  55515. /**
  55516. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55517. */
  55518. url: string;
  55519. /**
  55520. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55521. */
  55522. extensions?: string[] | undefined;
  55523. /**
  55524. * Defines if mipmaps should not be generated (default is false)
  55525. */
  55526. noMipmap?: boolean | undefined;
  55527. /**
  55528. * Defines the explicit list of files (undefined by default)
  55529. */
  55530. files?: string[] | undefined;
  55531. /**
  55532. * Gets the loaded texture
  55533. */
  55534. texture: CubeTexture;
  55535. /**
  55536. * Callback called when the task is successful
  55537. */
  55538. onSuccess: (task: CubeTextureAssetTask) => void;
  55539. /**
  55540. * Callback called when the task is successful
  55541. */
  55542. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55543. /**
  55544. * Creates a new CubeTextureAssetTask
  55545. * @param name defines the name of the task
  55546. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55547. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55548. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55549. * @param files defines the explicit list of files (undefined by default)
  55550. */
  55551. constructor(
  55552. /**
  55553. * Defines the name of the task
  55554. */
  55555. name: string,
  55556. /**
  55557. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55558. */
  55559. url: string,
  55560. /**
  55561. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55562. */
  55563. extensions?: string[] | undefined,
  55564. /**
  55565. * Defines if mipmaps should not be generated (default is false)
  55566. */
  55567. noMipmap?: boolean | undefined,
  55568. /**
  55569. * Defines the explicit list of files (undefined by default)
  55570. */
  55571. files?: string[] | undefined);
  55572. /**
  55573. * Execute the current task
  55574. * @param scene defines the scene where you want your assets to be loaded
  55575. * @param onSuccess is a callback called when the task is successfully executed
  55576. * @param onError is a callback called if an error occurs
  55577. */
  55578. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55579. }
  55580. /**
  55581. * Define a task used by AssetsManager to load HDR cube textures
  55582. */
  55583. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55584. /**
  55585. * Defines the name of the task
  55586. */
  55587. name: string;
  55588. /**
  55589. * Defines the location of the file to load
  55590. */
  55591. url: string;
  55592. /**
  55593. * Defines the desired size (the more it increases the longer the generation will be)
  55594. */
  55595. size: number;
  55596. /**
  55597. * Defines if mipmaps should not be generated (default is false)
  55598. */
  55599. noMipmap: boolean;
  55600. /**
  55601. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55602. */
  55603. generateHarmonics: boolean;
  55604. /**
  55605. * 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)
  55606. */
  55607. gammaSpace: boolean;
  55608. /**
  55609. * Internal Use Only
  55610. */
  55611. reserved: boolean;
  55612. /**
  55613. * Gets the loaded texture
  55614. */
  55615. texture: HDRCubeTexture;
  55616. /**
  55617. * Callback called when the task is successful
  55618. */
  55619. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55620. /**
  55621. * Callback called when the task is successful
  55622. */
  55623. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55624. /**
  55625. * Creates a new HDRCubeTextureAssetTask object
  55626. * @param name defines the name of the task
  55627. * @param url defines the location of the file to load
  55628. * @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.
  55629. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55630. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55631. * @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)
  55632. * @param reserved Internal use only
  55633. */
  55634. constructor(
  55635. /**
  55636. * Defines the name of the task
  55637. */
  55638. name: string,
  55639. /**
  55640. * Defines the location of the file to load
  55641. */
  55642. url: string,
  55643. /**
  55644. * Defines the desired size (the more it increases the longer the generation will be)
  55645. */
  55646. size: number,
  55647. /**
  55648. * Defines if mipmaps should not be generated (default is false)
  55649. */
  55650. noMipmap?: boolean,
  55651. /**
  55652. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55653. */
  55654. generateHarmonics?: boolean,
  55655. /**
  55656. * 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)
  55657. */
  55658. gammaSpace?: boolean,
  55659. /**
  55660. * Internal Use Only
  55661. */
  55662. reserved?: boolean);
  55663. /**
  55664. * Execute the current task
  55665. * @param scene defines the scene where you want your assets to be loaded
  55666. * @param onSuccess is a callback called when the task is successfully executed
  55667. * @param onError is a callback called if an error occurs
  55668. */
  55669. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55670. }
  55671. /**
  55672. * Define a task used by AssetsManager to load Equirectangular cube textures
  55673. */
  55674. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55675. /**
  55676. * Defines the name of the task
  55677. */
  55678. name: string;
  55679. /**
  55680. * Defines the location of the file to load
  55681. */
  55682. url: string;
  55683. /**
  55684. * Defines the desired size (the more it increases the longer the generation will be)
  55685. */
  55686. size: number;
  55687. /**
  55688. * Defines if mipmaps should not be generated (default is false)
  55689. */
  55690. noMipmap: boolean;
  55691. /**
  55692. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55693. * but the standard material would require them in Gamma space) (default is true)
  55694. */
  55695. gammaSpace: boolean;
  55696. /**
  55697. * Gets the loaded texture
  55698. */
  55699. texture: EquiRectangularCubeTexture;
  55700. /**
  55701. * Callback called when the task is successful
  55702. */
  55703. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55704. /**
  55705. * Callback called when the task is successful
  55706. */
  55707. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55708. /**
  55709. * Creates a new EquiRectangularCubeTextureAssetTask object
  55710. * @param name defines the name of the task
  55711. * @param url defines the location of the file to load
  55712. * @param size defines the desired size (the more it increases the longer the generation will be)
  55713. * If the size is omitted this implies you are using a preprocessed cubemap.
  55714. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55715. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55716. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55717. * (default is true)
  55718. */
  55719. constructor(
  55720. /**
  55721. * Defines the name of the task
  55722. */
  55723. name: string,
  55724. /**
  55725. * Defines the location of the file to load
  55726. */
  55727. url: string,
  55728. /**
  55729. * Defines the desired size (the more it increases the longer the generation will be)
  55730. */
  55731. size: number,
  55732. /**
  55733. * Defines if mipmaps should not be generated (default is false)
  55734. */
  55735. noMipmap?: boolean,
  55736. /**
  55737. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55738. * but the standard material would require them in Gamma space) (default is true)
  55739. */
  55740. gammaSpace?: boolean);
  55741. /**
  55742. * Execute the current task
  55743. * @param scene defines the scene where you want your assets to be loaded
  55744. * @param onSuccess is a callback called when the task is successfully executed
  55745. * @param onError is a callback called if an error occurs
  55746. */
  55747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55748. }
  55749. /**
  55750. * This class can be used to easily import assets into a scene
  55751. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55752. */
  55753. export class AssetsManager {
  55754. private _scene;
  55755. private _isLoading;
  55756. protected _tasks: AbstractAssetTask[];
  55757. protected _waitingTasksCount: number;
  55758. protected _totalTasksCount: number;
  55759. /**
  55760. * Callback called when all tasks are processed
  55761. */
  55762. onFinish: (tasks: AbstractAssetTask[]) => void;
  55763. /**
  55764. * Callback called when a task is successful
  55765. */
  55766. onTaskSuccess: (task: AbstractAssetTask) => void;
  55767. /**
  55768. * Callback called when a task had an error
  55769. */
  55770. onTaskError: (task: AbstractAssetTask) => void;
  55771. /**
  55772. * Callback called when a task is done (whatever the result is)
  55773. */
  55774. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55775. /**
  55776. * Observable called when all tasks are processed
  55777. */
  55778. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55779. /**
  55780. * Observable called when a task had an error
  55781. */
  55782. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55783. /**
  55784. * Observable called when all tasks were executed
  55785. */
  55786. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55787. /**
  55788. * Observable called when a task is done (whatever the result is)
  55789. */
  55790. onProgressObservable: Observable<IAssetsProgressEvent>;
  55791. /**
  55792. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55793. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55794. */
  55795. useDefaultLoadingScreen: boolean;
  55796. /**
  55797. * Creates a new AssetsManager
  55798. * @param scene defines the scene to work on
  55799. */
  55800. constructor(scene: Scene);
  55801. /**
  55802. * Add a MeshAssetTask to the list of active tasks
  55803. * @param taskName defines the name of the new task
  55804. * @param meshesNames defines the name of meshes to load
  55805. * @param rootUrl defines the root url to use to locate files
  55806. * @param sceneFilename defines the filename of the scene file
  55807. * @returns a new MeshAssetTask object
  55808. */
  55809. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55810. /**
  55811. * Add a TextFileAssetTask to the list of active tasks
  55812. * @param taskName defines the name of the new task
  55813. * @param url defines the url of the file to load
  55814. * @returns a new TextFileAssetTask object
  55815. */
  55816. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55817. /**
  55818. * Add a BinaryFileAssetTask to the list of active tasks
  55819. * @param taskName defines the name of the new task
  55820. * @param url defines the url of the file to load
  55821. * @returns a new BinaryFileAssetTask object
  55822. */
  55823. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55824. /**
  55825. * Add a ImageAssetTask to the list of active tasks
  55826. * @param taskName defines the name of the new task
  55827. * @param url defines the url of the file to load
  55828. * @returns a new ImageAssetTask object
  55829. */
  55830. addImageTask(taskName: string, url: string): ImageAssetTask;
  55831. /**
  55832. * Add a TextureAssetTask to the list of active tasks
  55833. * @param taskName defines the name of the new task
  55834. * @param url defines the url of the file to load
  55835. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55836. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55837. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55838. * @returns a new TextureAssetTask object
  55839. */
  55840. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55841. /**
  55842. * Add a CubeTextureAssetTask to the list of active tasks
  55843. * @param taskName defines the name of the new task
  55844. * @param url defines the url of the file to load
  55845. * @param extensions defines the extension to use to load the cube map (can be null)
  55846. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55847. * @param files defines the list of files to load (can be null)
  55848. * @returns a new CubeTextureAssetTask object
  55849. */
  55850. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55851. /**
  55852. *
  55853. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55854. * @param taskName defines the name of the new task
  55855. * @param url defines the url of the file to load
  55856. * @param size defines the size you want for the cubemap (can be null)
  55857. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55858. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55859. * @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)
  55860. * @param reserved Internal use only
  55861. * @returns a new HDRCubeTextureAssetTask object
  55862. */
  55863. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55864. /**
  55865. *
  55866. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55867. * @param taskName defines the name of the new task
  55868. * @param url defines the url of the file to load
  55869. * @param size defines the size you want for the cubemap (can be null)
  55870. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55871. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55872. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55873. * @returns a new EquiRectangularCubeTextureAssetTask object
  55874. */
  55875. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55876. /**
  55877. * Remove a task from the assets manager.
  55878. * @param task the task to remove
  55879. */
  55880. removeTask(task: AbstractAssetTask): void;
  55881. private _decreaseWaitingTasksCount;
  55882. private _runTask;
  55883. /**
  55884. * Reset the AssetsManager and remove all tasks
  55885. * @return the current instance of the AssetsManager
  55886. */
  55887. reset(): AssetsManager;
  55888. /**
  55889. * Start the loading process
  55890. * @return the current instance of the AssetsManager
  55891. */
  55892. load(): AssetsManager;
  55893. /**
  55894. * Start the loading process as an async operation
  55895. * @return a promise returning the list of failed tasks
  55896. */
  55897. loadAsync(): Promise<void>;
  55898. }
  55899. }
  55900. declare module BABYLON {
  55901. /**
  55902. * Wrapper class for promise with external resolve and reject.
  55903. */
  55904. export class Deferred<T> {
  55905. /**
  55906. * The promise associated with this deferred object.
  55907. */
  55908. readonly promise: Promise<T>;
  55909. private _resolve;
  55910. private _reject;
  55911. /**
  55912. * The resolve method of the promise associated with this deferred object.
  55913. */
  55914. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55915. /**
  55916. * The reject method of the promise associated with this deferred object.
  55917. */
  55918. readonly reject: (reason?: any) => void;
  55919. /**
  55920. * Constructor for this deferred object.
  55921. */
  55922. constructor();
  55923. }
  55924. }
  55925. declare module BABYLON {
  55926. /**
  55927. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55928. */
  55929. export class MeshExploder {
  55930. private _centerMesh;
  55931. private _meshes;
  55932. private _meshesOrigins;
  55933. private _toCenterVectors;
  55934. private _scaledDirection;
  55935. private _newPosition;
  55936. private _centerPosition;
  55937. /**
  55938. * Explodes meshes from a center mesh.
  55939. * @param meshes The meshes to explode.
  55940. * @param centerMesh The mesh to be center of explosion.
  55941. */
  55942. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55943. private _setCenterMesh;
  55944. /**
  55945. * Get class name
  55946. * @returns "MeshExploder"
  55947. */
  55948. getClassName(): string;
  55949. /**
  55950. * "Exploded meshes"
  55951. * @returns Array of meshes with the centerMesh at index 0.
  55952. */
  55953. getMeshes(): Array<Mesh>;
  55954. /**
  55955. * Explodes meshes giving a specific direction
  55956. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55957. */
  55958. explode(direction?: number): void;
  55959. }
  55960. }
  55961. declare module BABYLON {
  55962. /**
  55963. * Class used to help managing file picking and drag'n'drop
  55964. */
  55965. export class FilesInput {
  55966. /**
  55967. * List of files ready to be loaded
  55968. */
  55969. static readonly FilesToLoad: {
  55970. [key: string]: File;
  55971. };
  55972. /**
  55973. * Callback called when a file is processed
  55974. */
  55975. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55976. private _engine;
  55977. private _currentScene;
  55978. private _sceneLoadedCallback;
  55979. private _progressCallback;
  55980. private _additionalRenderLoopLogicCallback;
  55981. private _textureLoadingCallback;
  55982. private _startingProcessingFilesCallback;
  55983. private _onReloadCallback;
  55984. private _errorCallback;
  55985. private _elementToMonitor;
  55986. private _sceneFileToLoad;
  55987. private _filesToLoad;
  55988. /**
  55989. * Creates a new FilesInput
  55990. * @param engine defines the rendering engine
  55991. * @param scene defines the hosting scene
  55992. * @param sceneLoadedCallback callback called when scene is loaded
  55993. * @param progressCallback callback called to track progress
  55994. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55995. * @param textureLoadingCallback callback called when a texture is loading
  55996. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55997. * @param onReloadCallback callback called when a reload is requested
  55998. * @param errorCallback callback call if an error occurs
  55999. */
  56000. 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);
  56001. private _dragEnterHandler;
  56002. private _dragOverHandler;
  56003. private _dropHandler;
  56004. /**
  56005. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56006. * @param elementToMonitor defines the DOM element to track
  56007. */
  56008. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56009. /**
  56010. * Release all associated resources
  56011. */
  56012. dispose(): void;
  56013. private renderFunction;
  56014. private drag;
  56015. private drop;
  56016. private _traverseFolder;
  56017. private _processFiles;
  56018. /**
  56019. * Load files from a drop event
  56020. * @param event defines the drop event to use as source
  56021. */
  56022. loadFiles(event: any): void;
  56023. private _processReload;
  56024. /**
  56025. * Reload the current scene from the loaded files
  56026. */
  56027. reload(): void;
  56028. }
  56029. }
  56030. declare module BABYLON {
  56031. /**
  56032. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56034. */
  56035. export class SceneOptimization {
  56036. /**
  56037. * Defines the priority of this optimization (0 by default which means first in the list)
  56038. */
  56039. priority: number;
  56040. /**
  56041. * Gets a string describing the action executed by the current optimization
  56042. * @returns description string
  56043. */
  56044. getDescription(): string;
  56045. /**
  56046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56047. * @param scene defines the current scene where to apply this optimization
  56048. * @param optimizer defines the current optimizer
  56049. * @returns true if everything that can be done was applied
  56050. */
  56051. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56052. /**
  56053. * Creates the SceneOptimization object
  56054. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56055. * @param desc defines the description associated with the optimization
  56056. */
  56057. constructor(
  56058. /**
  56059. * Defines the priority of this optimization (0 by default which means first in the list)
  56060. */
  56061. priority?: number);
  56062. }
  56063. /**
  56064. * Defines an optimization used to reduce the size of render target textures
  56065. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56066. */
  56067. export class TextureOptimization extends SceneOptimization {
  56068. /**
  56069. * Defines the priority of this optimization (0 by default which means first in the list)
  56070. */
  56071. priority: number;
  56072. /**
  56073. * 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
  56074. */
  56075. maximumSize: number;
  56076. /**
  56077. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56078. */
  56079. step: number;
  56080. /**
  56081. * Gets a string describing the action executed by the current optimization
  56082. * @returns description string
  56083. */
  56084. getDescription(): string;
  56085. /**
  56086. * Creates the TextureOptimization object
  56087. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56088. * @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
  56089. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56090. */
  56091. constructor(
  56092. /**
  56093. * Defines the priority of this optimization (0 by default which means first in the list)
  56094. */
  56095. priority?: number,
  56096. /**
  56097. * 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
  56098. */
  56099. maximumSize?: number,
  56100. /**
  56101. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56102. */
  56103. step?: number);
  56104. /**
  56105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56106. * @param scene defines the current scene where to apply this optimization
  56107. * @param optimizer defines the current optimizer
  56108. * @returns true if everything that can be done was applied
  56109. */
  56110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56111. }
  56112. /**
  56113. * Defines an optimization used to increase or decrease the rendering resolution
  56114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56115. */
  56116. export class HardwareScalingOptimization extends SceneOptimization {
  56117. /**
  56118. * Defines the priority of this optimization (0 by default which means first in the list)
  56119. */
  56120. priority: number;
  56121. /**
  56122. * Defines the maximum scale to use (2 by default)
  56123. */
  56124. maximumScale: number;
  56125. /**
  56126. * Defines the step to use between two passes (0.5 by default)
  56127. */
  56128. step: number;
  56129. private _currentScale;
  56130. private _directionOffset;
  56131. /**
  56132. * Gets a string describing the action executed by the current optimization
  56133. * @return description string
  56134. */
  56135. getDescription(): string;
  56136. /**
  56137. * Creates the HardwareScalingOptimization object
  56138. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56139. * @param maximumScale defines the maximum scale to use (2 by default)
  56140. * @param step defines the step to use between two passes (0.5 by default)
  56141. */
  56142. constructor(
  56143. /**
  56144. * Defines the priority of this optimization (0 by default which means first in the list)
  56145. */
  56146. priority?: number,
  56147. /**
  56148. * Defines the maximum scale to use (2 by default)
  56149. */
  56150. maximumScale?: number,
  56151. /**
  56152. * Defines the step to use between two passes (0.5 by default)
  56153. */
  56154. step?: number);
  56155. /**
  56156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56157. * @param scene defines the current scene where to apply this optimization
  56158. * @param optimizer defines the current optimizer
  56159. * @returns true if everything that can be done was applied
  56160. */
  56161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56162. }
  56163. /**
  56164. * Defines an optimization used to remove shadows
  56165. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56166. */
  56167. export class ShadowsOptimization extends SceneOptimization {
  56168. /**
  56169. * Gets a string describing the action executed by the current optimization
  56170. * @return description string
  56171. */
  56172. getDescription(): string;
  56173. /**
  56174. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56175. * @param scene defines the current scene where to apply this optimization
  56176. * @param optimizer defines the current optimizer
  56177. * @returns true if everything that can be done was applied
  56178. */
  56179. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56180. }
  56181. /**
  56182. * Defines an optimization used to turn post-processes off
  56183. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56184. */
  56185. export class PostProcessesOptimization extends SceneOptimization {
  56186. /**
  56187. * Gets a string describing the action executed by the current optimization
  56188. * @return description string
  56189. */
  56190. getDescription(): string;
  56191. /**
  56192. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56193. * @param scene defines the current scene where to apply this optimization
  56194. * @param optimizer defines the current optimizer
  56195. * @returns true if everything that can be done was applied
  56196. */
  56197. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56198. }
  56199. /**
  56200. * Defines an optimization used to turn lens flares off
  56201. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56202. */
  56203. export class LensFlaresOptimization extends SceneOptimization {
  56204. /**
  56205. * Gets a string describing the action executed by the current optimization
  56206. * @return description string
  56207. */
  56208. getDescription(): string;
  56209. /**
  56210. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56211. * @param scene defines the current scene where to apply this optimization
  56212. * @param optimizer defines the current optimizer
  56213. * @returns true if everything that can be done was applied
  56214. */
  56215. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56216. }
  56217. /**
  56218. * Defines an optimization based on user defined callback.
  56219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56220. */
  56221. export class CustomOptimization extends SceneOptimization {
  56222. /**
  56223. * Callback called to apply the custom optimization.
  56224. */
  56225. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56226. /**
  56227. * Callback called to get custom description
  56228. */
  56229. onGetDescription: () => string;
  56230. /**
  56231. * Gets a string describing the action executed by the current optimization
  56232. * @returns description string
  56233. */
  56234. getDescription(): string;
  56235. /**
  56236. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56237. * @param scene defines the current scene where to apply this optimization
  56238. * @param optimizer defines the current optimizer
  56239. * @returns true if everything that can be done was applied
  56240. */
  56241. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56242. }
  56243. /**
  56244. * Defines an optimization used to turn particles off
  56245. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56246. */
  56247. export class ParticlesOptimization extends SceneOptimization {
  56248. /**
  56249. * Gets a string describing the action executed by the current optimization
  56250. * @return description string
  56251. */
  56252. getDescription(): string;
  56253. /**
  56254. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56255. * @param scene defines the current scene where to apply this optimization
  56256. * @param optimizer defines the current optimizer
  56257. * @returns true if everything that can be done was applied
  56258. */
  56259. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56260. }
  56261. /**
  56262. * Defines an optimization used to turn render targets off
  56263. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56264. */
  56265. export class RenderTargetsOptimization extends SceneOptimization {
  56266. /**
  56267. * Gets a string describing the action executed by the current optimization
  56268. * @return description string
  56269. */
  56270. getDescription(): string;
  56271. /**
  56272. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56273. * @param scene defines the current scene where to apply this optimization
  56274. * @param optimizer defines the current optimizer
  56275. * @returns true if everything that can be done was applied
  56276. */
  56277. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56278. }
  56279. /**
  56280. * Defines an optimization used to merge meshes with compatible materials
  56281. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56282. */
  56283. export class MergeMeshesOptimization extends SceneOptimization {
  56284. private static _UpdateSelectionTree;
  56285. /**
  56286. * Gets or sets a boolean which defines if optimization octree has to be updated
  56287. */
  56288. /**
  56289. * Gets or sets a boolean which defines if optimization octree has to be updated
  56290. */
  56291. static UpdateSelectionTree: boolean;
  56292. /**
  56293. * Gets a string describing the action executed by the current optimization
  56294. * @return description string
  56295. */
  56296. getDescription(): string;
  56297. private _canBeMerged;
  56298. /**
  56299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56300. * @param scene defines the current scene where to apply this optimization
  56301. * @param optimizer defines the current optimizer
  56302. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56303. * @returns true if everything that can be done was applied
  56304. */
  56305. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56306. }
  56307. /**
  56308. * Defines a list of options used by SceneOptimizer
  56309. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56310. */
  56311. export class SceneOptimizerOptions {
  56312. /**
  56313. * Defines the target frame rate to reach (60 by default)
  56314. */
  56315. targetFrameRate: number;
  56316. /**
  56317. * Defines the interval between two checkes (2000ms by default)
  56318. */
  56319. trackerDuration: number;
  56320. /**
  56321. * Gets the list of optimizations to apply
  56322. */
  56323. optimizations: SceneOptimization[];
  56324. /**
  56325. * Creates a new list of options used by SceneOptimizer
  56326. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56327. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56328. */
  56329. constructor(
  56330. /**
  56331. * Defines the target frame rate to reach (60 by default)
  56332. */
  56333. targetFrameRate?: number,
  56334. /**
  56335. * Defines the interval between two checkes (2000ms by default)
  56336. */
  56337. trackerDuration?: number);
  56338. /**
  56339. * Add a new optimization
  56340. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56341. * @returns the current SceneOptimizerOptions
  56342. */
  56343. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56344. /**
  56345. * Add a new custom optimization
  56346. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56347. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56348. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56349. * @returns the current SceneOptimizerOptions
  56350. */
  56351. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56352. /**
  56353. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56354. * @param targetFrameRate defines the target frame rate (60 by default)
  56355. * @returns a SceneOptimizerOptions object
  56356. */
  56357. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56358. /**
  56359. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56360. * @param targetFrameRate defines the target frame rate (60 by default)
  56361. * @returns a SceneOptimizerOptions object
  56362. */
  56363. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56364. /**
  56365. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56366. * @param targetFrameRate defines the target frame rate (60 by default)
  56367. * @returns a SceneOptimizerOptions object
  56368. */
  56369. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56370. }
  56371. /**
  56372. * Class used to run optimizations in order to reach a target frame rate
  56373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56374. */
  56375. export class SceneOptimizer implements IDisposable {
  56376. private _isRunning;
  56377. private _options;
  56378. private _scene;
  56379. private _currentPriorityLevel;
  56380. private _targetFrameRate;
  56381. private _trackerDuration;
  56382. private _currentFrameRate;
  56383. private _sceneDisposeObserver;
  56384. private _improvementMode;
  56385. /**
  56386. * Defines an observable called when the optimizer reaches the target frame rate
  56387. */
  56388. onSuccessObservable: Observable<SceneOptimizer>;
  56389. /**
  56390. * Defines an observable called when the optimizer enables an optimization
  56391. */
  56392. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56393. /**
  56394. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56395. */
  56396. onFailureObservable: Observable<SceneOptimizer>;
  56397. /**
  56398. * Gets a boolean indicating if the optimizer is in improvement mode
  56399. */
  56400. readonly isInImprovementMode: boolean;
  56401. /**
  56402. * Gets the current priority level (0 at start)
  56403. */
  56404. readonly currentPriorityLevel: number;
  56405. /**
  56406. * Gets the current frame rate checked by the SceneOptimizer
  56407. */
  56408. readonly currentFrameRate: number;
  56409. /**
  56410. * Gets or sets the current target frame rate (60 by default)
  56411. */
  56412. /**
  56413. * Gets or sets the current target frame rate (60 by default)
  56414. */
  56415. targetFrameRate: number;
  56416. /**
  56417. * Gets or sets the current interval between two checks (every 2000ms by default)
  56418. */
  56419. /**
  56420. * Gets or sets the current interval between two checks (every 2000ms by default)
  56421. */
  56422. trackerDuration: number;
  56423. /**
  56424. * Gets the list of active optimizations
  56425. */
  56426. readonly optimizations: SceneOptimization[];
  56427. /**
  56428. * Creates a new SceneOptimizer
  56429. * @param scene defines the scene to work on
  56430. * @param options defines the options to use with the SceneOptimizer
  56431. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56432. * @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)
  56433. */
  56434. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56435. /**
  56436. * Stops the current optimizer
  56437. */
  56438. stop(): void;
  56439. /**
  56440. * Reset the optimizer to initial step (current priority level = 0)
  56441. */
  56442. reset(): void;
  56443. /**
  56444. * Start the optimizer. By default it will try to reach a specific framerate
  56445. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56446. */
  56447. start(): void;
  56448. private _checkCurrentState;
  56449. /**
  56450. * Release all resources
  56451. */
  56452. dispose(): void;
  56453. /**
  56454. * Helper function to create a SceneOptimizer with one single line of code
  56455. * @param scene defines the scene to work on
  56456. * @param options defines the options to use with the SceneOptimizer
  56457. * @param onSuccess defines a callback to call on success
  56458. * @param onFailure defines a callback to call on failure
  56459. * @returns the new SceneOptimizer object
  56460. */
  56461. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56462. }
  56463. }
  56464. declare module BABYLON {
  56465. /**
  56466. * Class used to serialize a scene into a string
  56467. */
  56468. export class SceneSerializer {
  56469. /**
  56470. * Clear cache used by a previous serialization
  56471. */
  56472. static ClearCache(): void;
  56473. /**
  56474. * Serialize a scene into a JSON compatible object
  56475. * @param scene defines the scene to serialize
  56476. * @returns a JSON compatible object
  56477. */
  56478. static Serialize(scene: Scene): any;
  56479. /**
  56480. * Serialize a mesh into a JSON compatible object
  56481. * @param toSerialize defines the mesh to serialize
  56482. * @param withParents defines if parents must be serialized as well
  56483. * @param withChildren defines if children must be serialized as well
  56484. * @returns a JSON compatible object
  56485. */
  56486. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56487. }
  56488. }
  56489. declare module BABYLON {
  56490. /**
  56491. * Class used to host texture specific utilities
  56492. */
  56493. export class TextureTools {
  56494. /**
  56495. * Uses the GPU to create a copy texture rescaled at a given size
  56496. * @param texture Texture to copy from
  56497. * @param width defines the desired width
  56498. * @param height defines the desired height
  56499. * @param useBilinearMode defines if bilinear mode has to be used
  56500. * @return the generated texture
  56501. */
  56502. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  56503. }
  56504. }
  56505. declare module BABYLON {
  56506. /**
  56507. * This represents the different options avilable for the video capture.
  56508. */
  56509. export interface VideoRecorderOptions {
  56510. /** Defines the mime type of the video */
  56511. mimeType: string;
  56512. /** Defines the video the video should be recorded at */
  56513. fps: number;
  56514. /** Defines the chunk size for the recording data */
  56515. recordChunckSize: number;
  56516. /** The audio tracks to attach to the record */
  56517. audioTracks?: MediaStreamTrack[];
  56518. }
  56519. /**
  56520. * This can helps recording videos from BabylonJS.
  56521. * This is based on the available WebRTC functionalities of the browser.
  56522. *
  56523. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56524. */
  56525. export class VideoRecorder {
  56526. private static readonly _defaultOptions;
  56527. /**
  56528. * Returns wehther or not the VideoRecorder is available in your browser.
  56529. * @param engine Defines the Babylon Engine to check the support for
  56530. * @returns true if supported otherwise false
  56531. */
  56532. static IsSupported(engine: Engine): boolean;
  56533. private readonly _options;
  56534. private _canvas;
  56535. private _mediaRecorder;
  56536. private _recordedChunks;
  56537. private _fileName;
  56538. private _resolve;
  56539. private _reject;
  56540. /**
  56541. * True wether a recording is already in progress.
  56542. */
  56543. readonly isRecording: boolean;
  56544. /**
  56545. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56546. * a video file.
  56547. * @param engine Defines the BabylonJS Engine you wish to record
  56548. * @param options Defines options that can be used to customized the capture
  56549. */
  56550. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56551. /**
  56552. * Stops the current recording before the default capture timeout passed in the startRecording
  56553. * functions.
  56554. */
  56555. stopRecording(): void;
  56556. /**
  56557. * Starts recording the canvas for a max duration specified in parameters.
  56558. * @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.
  56559. * @param maxDuration Defines the maximum recording time in seconds.
  56560. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56561. * @return a promise callback at the end of the recording with the video data in Blob.
  56562. */
  56563. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56564. /**
  56565. * Releases internal resources used during the recording.
  56566. */
  56567. dispose(): void;
  56568. private _handleDataAvailable;
  56569. private _handleError;
  56570. private _handleStop;
  56571. }
  56572. }
  56573. declare module BABYLON {
  56574. /**
  56575. * Class containing a set of static utilities functions for screenshots
  56576. */
  56577. export class ScreenshotTools {
  56578. /**
  56579. * Captures a screenshot of the current rendering
  56580. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56581. * @param engine defines the rendering engine
  56582. * @param camera defines the source camera
  56583. * @param size This parameter can be set to a single number or to an object with the
  56584. * following (optional) properties: precision, width, height. If a single number is passed,
  56585. * it will be used for both width and height. If an object is passed, the screenshot size
  56586. * will be derived from the parameters. The precision property is a multiplier allowing
  56587. * rendering at a higher or lower resolution
  56588. * @param successCallback defines the callback receives a single parameter which contains the
  56589. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56590. * src parameter of an <img> to display it
  56591. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56592. * Check your browser for supported MIME types
  56593. */
  56594. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56595. /**
  56596. * Generates an image screenshot from the specified camera.
  56597. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56598. * @param engine The engine to use for rendering
  56599. * @param camera The camera to use for rendering
  56600. * @param size This parameter can be set to a single number or to an object with the
  56601. * following (optional) properties: precision, width, height. If a single number is passed,
  56602. * it will be used for both width and height. If an object is passed, the screenshot size
  56603. * will be derived from the parameters. The precision property is a multiplier allowing
  56604. * rendering at a higher or lower resolution
  56605. * @param successCallback The callback receives a single parameter which contains the
  56606. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56607. * src parameter of an <img> to display it
  56608. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56609. * Check your browser for supported MIME types
  56610. * @param samples Texture samples (default: 1)
  56611. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56612. * @param fileName A name for for the downloaded file.
  56613. */
  56614. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56615. }
  56616. }
  56617. declare module BABYLON {
  56618. /**
  56619. * A cursor which tracks a point on a path
  56620. */
  56621. export class PathCursor {
  56622. private path;
  56623. /**
  56624. * Stores path cursor callbacks for when an onchange event is triggered
  56625. */
  56626. private _onchange;
  56627. /**
  56628. * The value of the path cursor
  56629. */
  56630. value: number;
  56631. /**
  56632. * The animation array of the path cursor
  56633. */
  56634. animations: Animation[];
  56635. /**
  56636. * Initializes the path cursor
  56637. * @param path The path to track
  56638. */
  56639. constructor(path: Path2);
  56640. /**
  56641. * Gets the cursor point on the path
  56642. * @returns A point on the path cursor at the cursor location
  56643. */
  56644. getPoint(): Vector3;
  56645. /**
  56646. * Moves the cursor ahead by the step amount
  56647. * @param step The amount to move the cursor forward
  56648. * @returns This path cursor
  56649. */
  56650. moveAhead(step?: number): PathCursor;
  56651. /**
  56652. * Moves the cursor behind by the step amount
  56653. * @param step The amount to move the cursor back
  56654. * @returns This path cursor
  56655. */
  56656. moveBack(step?: number): PathCursor;
  56657. /**
  56658. * Moves the cursor by the step amount
  56659. * If the step amount is greater than one, an exception is thrown
  56660. * @param step The amount to move the cursor
  56661. * @returns This path cursor
  56662. */
  56663. move(step: number): PathCursor;
  56664. /**
  56665. * Ensures that the value is limited between zero and one
  56666. * @returns This path cursor
  56667. */
  56668. private ensureLimits;
  56669. /**
  56670. * Runs onchange callbacks on change (used by the animation engine)
  56671. * @returns This path cursor
  56672. */
  56673. private raiseOnChange;
  56674. /**
  56675. * Executes a function on change
  56676. * @param f A path cursor onchange callback
  56677. * @returns This path cursor
  56678. */
  56679. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56680. }
  56681. }
  56682. declare module BABYLON {
  56683. /** @hidden */
  56684. export var blurPixelShader: {
  56685. name: string;
  56686. shader: string;
  56687. };
  56688. }
  56689. declare module BABYLON {
  56690. /** @hidden */
  56691. export var bones300Declaration: {
  56692. name: string;
  56693. shader: string;
  56694. };
  56695. }
  56696. declare module BABYLON {
  56697. /** @hidden */
  56698. export var instances300Declaration: {
  56699. name: string;
  56700. shader: string;
  56701. };
  56702. }
  56703. declare module BABYLON {
  56704. /** @hidden */
  56705. export var pointCloudVertexDeclaration: {
  56706. name: string;
  56707. shader: string;
  56708. };
  56709. }
  56710. // Mixins
  56711. interface Window {
  56712. mozIndexedDB: IDBFactory;
  56713. webkitIndexedDB: IDBFactory;
  56714. msIndexedDB: IDBFactory;
  56715. webkitURL: typeof URL;
  56716. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56717. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56718. WebGLRenderingContext: WebGLRenderingContext;
  56719. MSGesture: MSGesture;
  56720. CANNON: any;
  56721. AudioContext: AudioContext;
  56722. webkitAudioContext: AudioContext;
  56723. PointerEvent: any;
  56724. Math: Math;
  56725. Uint8Array: Uint8ArrayConstructor;
  56726. Float32Array: Float32ArrayConstructor;
  56727. mozURL: typeof URL;
  56728. msURL: typeof URL;
  56729. VRFrameData: any; // WebVR, from specs 1.1
  56730. DracoDecoderModule: any;
  56731. setImmediate(handler: (...args: any[]) => void): number;
  56732. }
  56733. interface HTMLCanvasElement {
  56734. requestPointerLock(): void;
  56735. msRequestPointerLock?(): void;
  56736. mozRequestPointerLock?(): void;
  56737. webkitRequestPointerLock?(): void;
  56738. /** Track wether a record is in progress */
  56739. isRecording: boolean;
  56740. /** Capture Stream method defined by some browsers */
  56741. captureStream(fps?: number): MediaStream;
  56742. }
  56743. interface CanvasRenderingContext2D {
  56744. msImageSmoothingEnabled: boolean;
  56745. }
  56746. interface MouseEvent {
  56747. mozMovementX: number;
  56748. mozMovementY: number;
  56749. webkitMovementX: number;
  56750. webkitMovementY: number;
  56751. msMovementX: number;
  56752. msMovementY: number;
  56753. }
  56754. interface Navigator {
  56755. mozGetVRDevices: (any: any) => any;
  56756. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56757. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56758. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56759. webkitGetGamepads(): Gamepad[];
  56760. msGetGamepads(): Gamepad[];
  56761. webkitGamepads(): Gamepad[];
  56762. }
  56763. interface HTMLVideoElement {
  56764. mozSrcObject: any;
  56765. }
  56766. interface Math {
  56767. fround(x: number): number;
  56768. imul(a: number, b: number): number;
  56769. }
  56770. interface WebGLRenderingContext {
  56771. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56772. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56773. vertexAttribDivisor(index: number, divisor: number): void;
  56774. createVertexArray(): any;
  56775. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56776. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56777. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56778. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56779. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56780. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56781. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56782. // Queries
  56783. createQuery(): WebGLQuery;
  56784. deleteQuery(query: WebGLQuery): void;
  56785. beginQuery(target: number, query: WebGLQuery): void;
  56786. endQuery(target: number): void;
  56787. getQueryParameter(query: WebGLQuery, pname: number): any;
  56788. getQuery(target: number, pname: number): any;
  56789. MAX_SAMPLES: number;
  56790. RGBA8: number;
  56791. READ_FRAMEBUFFER: number;
  56792. DRAW_FRAMEBUFFER: number;
  56793. UNIFORM_BUFFER: number;
  56794. HALF_FLOAT_OES: number;
  56795. RGBA16F: number;
  56796. RGBA32F: number;
  56797. R32F: number;
  56798. RG32F: number;
  56799. RGB32F: number;
  56800. R16F: number;
  56801. RG16F: number;
  56802. RGB16F: number;
  56803. RED: number;
  56804. RG: number;
  56805. R8: number;
  56806. RG8: number;
  56807. UNSIGNED_INT_24_8: number;
  56808. DEPTH24_STENCIL8: number;
  56809. /* Multiple Render Targets */
  56810. drawBuffers(buffers: number[]): void;
  56811. readBuffer(src: number): void;
  56812. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56813. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56814. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56815. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56816. // Occlusion Query
  56817. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56818. ANY_SAMPLES_PASSED: number;
  56819. QUERY_RESULT_AVAILABLE: number;
  56820. QUERY_RESULT: number;
  56821. }
  56822. interface WebGLProgram {
  56823. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56824. }
  56825. interface EXT_disjoint_timer_query {
  56826. QUERY_COUNTER_BITS_EXT: number;
  56827. TIME_ELAPSED_EXT: number;
  56828. TIMESTAMP_EXT: number;
  56829. GPU_DISJOINT_EXT: number;
  56830. QUERY_RESULT_EXT: number;
  56831. QUERY_RESULT_AVAILABLE_EXT: number;
  56832. queryCounterEXT(query: WebGLQuery, target: number): void;
  56833. createQueryEXT(): WebGLQuery;
  56834. beginQueryEXT(target: number, query: WebGLQuery): void;
  56835. endQueryEXT(target: number): void;
  56836. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56837. deleteQueryEXT(query: WebGLQuery): void;
  56838. }
  56839. interface WebGLUniformLocation {
  56840. _currentState: any;
  56841. }
  56842. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56843. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56844. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56845. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56846. interface WebGLRenderingContext {
  56847. readonly RASTERIZER_DISCARD: number;
  56848. readonly DEPTH_COMPONENT24: number;
  56849. readonly TEXTURE_3D: number;
  56850. readonly TEXTURE_2D_ARRAY: number;
  56851. readonly TEXTURE_COMPARE_FUNC: number;
  56852. readonly TEXTURE_COMPARE_MODE: number;
  56853. readonly COMPARE_REF_TO_TEXTURE: number;
  56854. readonly TEXTURE_WRAP_R: number;
  56855. readonly HALF_FLOAT: number;
  56856. readonly RGB8: number;
  56857. readonly RED_INTEGER: number;
  56858. readonly RG_INTEGER: number;
  56859. readonly RGB_INTEGER: number;
  56860. readonly RGBA_INTEGER: number;
  56861. readonly R8_SNORM: number;
  56862. readonly RG8_SNORM: number;
  56863. readonly RGB8_SNORM: number;
  56864. readonly RGBA8_SNORM: number;
  56865. readonly R8I: number;
  56866. readonly RG8I: number;
  56867. readonly RGB8I: number;
  56868. readonly RGBA8I: number;
  56869. readonly R8UI: number;
  56870. readonly RG8UI: number;
  56871. readonly RGB8UI: number;
  56872. readonly RGBA8UI: number;
  56873. readonly R16I: number;
  56874. readonly RG16I: number;
  56875. readonly RGB16I: number;
  56876. readonly RGBA16I: number;
  56877. readonly R16UI: number;
  56878. readonly RG16UI: number;
  56879. readonly RGB16UI: number;
  56880. readonly RGBA16UI: number;
  56881. readonly R32I: number;
  56882. readonly RG32I: number;
  56883. readonly RGB32I: number;
  56884. readonly RGBA32I: number;
  56885. readonly R32UI: number;
  56886. readonly RG32UI: number;
  56887. readonly RGB32UI: number;
  56888. readonly RGBA32UI: number;
  56889. readonly RGB10_A2UI: number;
  56890. readonly R11F_G11F_B10F: number;
  56891. readonly RGB9_E5: number;
  56892. readonly RGB10_A2: number;
  56893. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56894. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56895. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56896. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56897. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56898. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56899. 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;
  56900. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56901. readonly TRANSFORM_FEEDBACK: number;
  56902. readonly INTERLEAVED_ATTRIBS: number;
  56903. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56904. createTransformFeedback(): WebGLTransformFeedback;
  56905. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56906. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56907. beginTransformFeedback(primitiveMode: number): void;
  56908. endTransformFeedback(): void;
  56909. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56910. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56911. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56912. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56913. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56914. }
  56915. interface ImageBitmap {
  56916. readonly width: number;
  56917. readonly height: number;
  56918. close(): void;
  56919. }
  56920. interface WebGLQuery extends WebGLObject {
  56921. }
  56922. declare var WebGLQuery: {
  56923. prototype: WebGLQuery;
  56924. new(): WebGLQuery;
  56925. };
  56926. interface WebGLSampler extends WebGLObject {
  56927. }
  56928. declare var WebGLSampler: {
  56929. prototype: WebGLSampler;
  56930. new(): WebGLSampler;
  56931. };
  56932. interface WebGLSync extends WebGLObject {
  56933. }
  56934. declare var WebGLSync: {
  56935. prototype: WebGLSync;
  56936. new(): WebGLSync;
  56937. };
  56938. interface WebGLTransformFeedback extends WebGLObject {
  56939. }
  56940. declare var WebGLTransformFeedback: {
  56941. prototype: WebGLTransformFeedback;
  56942. new(): WebGLTransformFeedback;
  56943. };
  56944. interface WebGLVertexArrayObject extends WebGLObject {
  56945. }
  56946. declare var WebGLVertexArrayObject: {
  56947. prototype: WebGLVertexArrayObject;
  56948. new(): WebGLVertexArrayObject;
  56949. };
  56950. // Type definitions for WebVR API
  56951. // Project: https://w3c.github.io/webvr/
  56952. // Definitions by: six a <https://github.com/lostfictions>
  56953. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56954. interface VRDisplay extends EventTarget {
  56955. /**
  56956. * Dictionary of capabilities describing the VRDisplay.
  56957. */
  56958. readonly capabilities: VRDisplayCapabilities;
  56959. /**
  56960. * z-depth defining the far plane of the eye view frustum
  56961. * enables mapping of values in the render target depth
  56962. * attachment to scene coordinates. Initially set to 10000.0.
  56963. */
  56964. depthFar: number;
  56965. /**
  56966. * z-depth defining the near plane of the eye view frustum
  56967. * enables mapping of values in the render target depth
  56968. * attachment to scene coordinates. Initially set to 0.01.
  56969. */
  56970. depthNear: number;
  56971. /**
  56972. * An identifier for this distinct VRDisplay. Used as an
  56973. * association point in the Gamepad API.
  56974. */
  56975. readonly displayId: number;
  56976. /**
  56977. * A display name, a user-readable name identifying it.
  56978. */
  56979. readonly displayName: string;
  56980. readonly isConnected: boolean;
  56981. readonly isPresenting: boolean;
  56982. /**
  56983. * If this VRDisplay supports room-scale experiences, the optional
  56984. * stage attribute contains details on the room-scale parameters.
  56985. */
  56986. readonly stageParameters: VRStageParameters | null;
  56987. /**
  56988. * Passing the value returned by `requestAnimationFrame` to
  56989. * `cancelAnimationFrame` will unregister the callback.
  56990. * @param handle Define the hanle of the request to cancel
  56991. */
  56992. cancelAnimationFrame(handle: number): void;
  56993. /**
  56994. * Stops presenting to the VRDisplay.
  56995. * @returns a promise to know when it stopped
  56996. */
  56997. exitPresent(): Promise<void>;
  56998. /**
  56999. * Return the current VREyeParameters for the given eye.
  57000. * @param whichEye Define the eye we want the parameter for
  57001. * @returns the eye parameters
  57002. */
  57003. getEyeParameters(whichEye: string): VREyeParameters;
  57004. /**
  57005. * Populates the passed VRFrameData with the information required to render
  57006. * the current frame.
  57007. * @param frameData Define the data structure to populate
  57008. * @returns true if ok otherwise false
  57009. */
  57010. getFrameData(frameData: VRFrameData): boolean;
  57011. /**
  57012. * Get the layers currently being presented.
  57013. * @returns the list of VR layers
  57014. */
  57015. getLayers(): VRLayer[];
  57016. /**
  57017. * Return a VRPose containing the future predicted pose of the VRDisplay
  57018. * when the current frame will be presented. The value returned will not
  57019. * change until JavaScript has returned control to the browser.
  57020. *
  57021. * The VRPose will contain the position, orientation, velocity,
  57022. * and acceleration of each of these properties.
  57023. * @returns the pose object
  57024. */
  57025. getPose(): VRPose;
  57026. /**
  57027. * Return the current instantaneous pose of the VRDisplay, with no
  57028. * prediction applied.
  57029. * @returns the current instantaneous pose
  57030. */
  57031. getImmediatePose(): VRPose;
  57032. /**
  57033. * The callback passed to `requestAnimationFrame` will be called
  57034. * any time a new frame should be rendered. When the VRDisplay is
  57035. * presenting the callback will be called at the native refresh
  57036. * rate of the HMD. When not presenting this function acts
  57037. * identically to how window.requestAnimationFrame acts. Content should
  57038. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57039. * asynchronously from other displays and at differing refresh rates.
  57040. * @param callback Define the eaction to run next frame
  57041. * @returns the request handle it
  57042. */
  57043. requestAnimationFrame(callback: FrameRequestCallback): number;
  57044. /**
  57045. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57046. * Repeat calls while already presenting will update the VRLayers being displayed.
  57047. * @param layers Define the list of layer to present
  57048. * @returns a promise to know when the request has been fulfilled
  57049. */
  57050. requestPresent(layers: VRLayer[]): Promise<void>;
  57051. /**
  57052. * Reset the pose for this display, treating its current position and
  57053. * orientation as the "origin/zero" values. VRPose.position,
  57054. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57055. * updated when calling resetPose(). This should be called in only
  57056. * sitting-space experiences.
  57057. */
  57058. resetPose(): void;
  57059. /**
  57060. * The VRLayer provided to the VRDisplay will be captured and presented
  57061. * in the HMD. Calling this function has the same effect on the source
  57062. * canvas as any other operation that uses its source image, and canvases
  57063. * created without preserveDrawingBuffer set to true will be cleared.
  57064. * @param pose Define the pose to submit
  57065. */
  57066. submitFrame(pose?: VRPose): void;
  57067. }
  57068. declare var VRDisplay: {
  57069. prototype: VRDisplay;
  57070. new(): VRDisplay;
  57071. };
  57072. interface VRLayer {
  57073. leftBounds?: number[] | Float32Array | null;
  57074. rightBounds?: number[] | Float32Array | null;
  57075. source?: HTMLCanvasElement | null;
  57076. }
  57077. interface VRDisplayCapabilities {
  57078. readonly canPresent: boolean;
  57079. readonly hasExternalDisplay: boolean;
  57080. readonly hasOrientation: boolean;
  57081. readonly hasPosition: boolean;
  57082. readonly maxLayers: number;
  57083. }
  57084. interface VREyeParameters {
  57085. /** @deprecated */
  57086. readonly fieldOfView: VRFieldOfView;
  57087. readonly offset: Float32Array;
  57088. readonly renderHeight: number;
  57089. readonly renderWidth: number;
  57090. }
  57091. interface VRFieldOfView {
  57092. readonly downDegrees: number;
  57093. readonly leftDegrees: number;
  57094. readonly rightDegrees: number;
  57095. readonly upDegrees: number;
  57096. }
  57097. interface VRFrameData {
  57098. readonly leftProjectionMatrix: Float32Array;
  57099. readonly leftViewMatrix: Float32Array;
  57100. readonly pose: VRPose;
  57101. readonly rightProjectionMatrix: Float32Array;
  57102. readonly rightViewMatrix: Float32Array;
  57103. readonly timestamp: number;
  57104. }
  57105. interface VRPose {
  57106. readonly angularAcceleration: Float32Array | null;
  57107. readonly angularVelocity: Float32Array | null;
  57108. readonly linearAcceleration: Float32Array | null;
  57109. readonly linearVelocity: Float32Array | null;
  57110. readonly orientation: Float32Array | null;
  57111. readonly position: Float32Array | null;
  57112. readonly timestamp: number;
  57113. }
  57114. interface VRStageParameters {
  57115. sittingToStandingTransform?: Float32Array;
  57116. sizeX?: number;
  57117. sizeY?: number;
  57118. }
  57119. interface Navigator {
  57120. getVRDisplays(): Promise<VRDisplay[]>;
  57121. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57122. }
  57123. interface Window {
  57124. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57125. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57126. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57127. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57128. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57129. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57130. }
  57131. interface Gamepad {
  57132. readonly displayId: number;
  57133. }
  57134. interface XRDevice {
  57135. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57136. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57137. }
  57138. interface XRSession {
  57139. getInputSources(): Array<any>;
  57140. baseLayer: XRWebGLLayer;
  57141. requestFrameOfReference(type: string): Promise<void>;
  57142. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57143. end(): Promise<void>;
  57144. requestAnimationFrame: Function;
  57145. addEventListener: Function;
  57146. }
  57147. interface XRSessionCreationOptions {
  57148. outputContext?: WebGLRenderingContext | null;
  57149. immersive?: boolean;
  57150. environmentIntegration?: boolean;
  57151. }
  57152. interface XRLayer {
  57153. getViewport: Function;
  57154. framebufferWidth: number;
  57155. framebufferHeight: number;
  57156. }
  57157. interface XRView {
  57158. projectionMatrix: Float32Array;
  57159. }
  57160. interface XRFrame {
  57161. getDevicePose: Function;
  57162. getInputPose: Function;
  57163. views: Array<XRView>;
  57164. baseLayer: XRLayer;
  57165. }
  57166. interface XRFrameOfReference {
  57167. }
  57168. interface XRWebGLLayer extends XRLayer {
  57169. framebuffer: WebGLFramebuffer;
  57170. }
  57171. declare var XRWebGLLayer: {
  57172. prototype: XRWebGLLayer;
  57173. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57174. };