babylon.d.ts 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** 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 */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** 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 */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** 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 */
  684. static readonly GEQUAL: number;
  685. /** 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 */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * 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.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * 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.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeTestNode extends ShaderCodeNode {
  1191. testExpression: ShaderDefineExpression;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1200. define: string;
  1201. not: boolean;
  1202. constructor(define: string, not?: boolean);
  1203. isTrue(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1211. leftOperand: ShaderDefineExpression;
  1212. rightOperand: ShaderDefineExpression;
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module BABYLON {
  1219. /** @hidden */
  1220. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1221. leftOperand: ShaderDefineExpression;
  1222. rightOperand: ShaderDefineExpression;
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module BABYLON {
  1229. /** @hidden */
  1230. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. operand: string;
  1233. testValue: string;
  1234. constructor(define: string, operand: string, testValue: string);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module BABYLON {
  1241. /**
  1242. * Class used to enable access to offline support
  1243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1244. */
  1245. export interface IOfflineProvider {
  1246. /**
  1247. * Gets a boolean indicating if scene must be saved in the database
  1248. */
  1249. enableSceneOffline: boolean;
  1250. /**
  1251. * Gets a boolean indicating if textures must be saved in the database
  1252. */
  1253. enableTexturesOffline: boolean;
  1254. /**
  1255. * Open the offline support and make it available
  1256. * @param successCallback defines the callback to call on success
  1257. * @param errorCallback defines the callback to call on error
  1258. */
  1259. open(successCallback: () => void, errorCallback: () => void): void;
  1260. /**
  1261. * Loads an image from the offline support
  1262. * @param url defines the url to load from
  1263. * @param image defines the target DOM image
  1264. */
  1265. loadImage(url: string, image: HTMLImageElement): void;
  1266. /**
  1267. * Loads a file from offline support
  1268. * @param url defines the URL to load from
  1269. * @param sceneLoaded defines a callback to call on success
  1270. * @param progressCallBack defines a callback to call when progress changed
  1271. * @param errorCallback defines a callback to call on error
  1272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1273. */
  1274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1275. }
  1276. }
  1277. declare module BABYLON {
  1278. /**
  1279. * Class used to help managing file picking and drag'n'drop
  1280. * File Storage
  1281. */
  1282. export class FilesInputStore {
  1283. /**
  1284. * List of files ready to be loaded
  1285. */
  1286. static FilesToLoad: {
  1287. [key: string]: File;
  1288. };
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /**
  1293. * Class used to define a retry strategy when error happens while loading assets
  1294. */
  1295. export class RetryStrategy {
  1296. /**
  1297. * Function used to defines an exponential back off strategy
  1298. * @param maxRetries defines the maximum number of retries (3 by default)
  1299. * @param baseInterval defines the interval between retries
  1300. * @returns the strategy function to use
  1301. */
  1302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * @ignore
  1308. * Application error to support additional information when loading a file
  1309. */
  1310. export abstract class BaseError extends Error {
  1311. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /** @ignore */
  1316. export class LoadFileError extends BaseError {
  1317. request?: WebRequest;
  1318. file?: File;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. * @param file defines the optional file
  1324. */
  1325. constructor(message: string, object?: WebRequest | File);
  1326. }
  1327. /** @ignore */
  1328. export class RequestFileError extends BaseError {
  1329. request: WebRequest;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. */
  1335. constructor(message: string, request: WebRequest);
  1336. }
  1337. /** @ignore */
  1338. export class ReadFileError extends BaseError {
  1339. file: File;
  1340. /**
  1341. * Creates a new ReadFileError
  1342. * @param message defines the message of the error
  1343. * @param file defines the optional file
  1344. */
  1345. constructor(message: string, file: File);
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export class FileTools {
  1351. /**
  1352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1353. */
  1354. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1355. /**
  1356. * Gets or sets the base URL to use to load assets
  1357. */
  1358. static BaseUrl: string;
  1359. /**
  1360. * Default behaviour for cors in the application.
  1361. * It can be a string if the expected behavior is identical in the entire app.
  1362. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1363. */
  1364. static CorsBehavior: string | ((url: string | string[]) => string);
  1365. /**
  1366. * Gets or sets a function used to pre-process url before using them to load assets
  1367. */
  1368. static PreprocessUrl: (url: string) => string;
  1369. /**
  1370. * Removes unwanted characters from an url
  1371. * @param url defines the url to clean
  1372. * @returns the cleaned url
  1373. */
  1374. private static _CleanUrl;
  1375. /**
  1376. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1377. * @param url define the url we are trying
  1378. * @param element define the dom element where to configure the cors policy
  1379. */
  1380. static SetCorsBehavior(url: string | string[], element: {
  1381. crossOrigin: string | null;
  1382. }): void;
  1383. /**
  1384. * Loads an image as an HTMLImageElement.
  1385. * @param input url string, ArrayBuffer, or Blob to load
  1386. * @param onLoad callback called when the image successfully loads
  1387. * @param onError callback called when the image fails to load
  1388. * @param offlineProvider offline provider for caching
  1389. * @param mimeType optional mime type
  1390. * @returns the HTMLImageElement of the loaded image
  1391. */
  1392. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1393. /**
  1394. * Reads a file from a File object
  1395. * @param file defines the file to load
  1396. * @param onSuccess defines the callback to call when data is loaded
  1397. * @param onProgress defines the callback to call during loading process
  1398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1399. * @param onError defines the callback to call when an error occurs
  1400. * @returns a file request object
  1401. */
  1402. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1403. /**
  1404. * Loads a file from a url
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param offlineProvider defines the offline provider for caching
  1409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1410. * @param onError callback called when the file fails to load
  1411. * @returns a file request object
  1412. */
  1413. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1420. * @param onError callback called when the file fails to load
  1421. * @param onOpened callback called when the web request is opened
  1422. * @returns a file request object
  1423. */
  1424. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1425. /**
  1426. * Checks if the loaded document was accessed via `file:`-Protocol.
  1427. * @returns boolean
  1428. */
  1429. static IsFileURL(): boolean;
  1430. }
  1431. }
  1432. declare module BABYLON {
  1433. /** @hidden */
  1434. export class ShaderProcessor {
  1435. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1436. private static _ProcessPrecision;
  1437. private static _ExtractOperation;
  1438. private static _BuildSubExpression;
  1439. private static _BuildExpression;
  1440. private static _MoveCursorWithinIf;
  1441. private static _MoveCursor;
  1442. private static _EvaluatePreProcessors;
  1443. private static _PreparePreProcessors;
  1444. private static _ProcessShaderConversion;
  1445. private static _ProcessIncludes;
  1446. /**
  1447. * Loads a file from a url
  1448. * @param url url to load
  1449. * @param onSuccess callback called when the file successfully loads
  1450. * @param onProgress callback called while file is loading (if the server supports this mode)
  1451. * @param offlineProvider defines the offline provider for caching
  1452. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1453. * @param onError callback called when the file fails to load
  1454. * @returns a file request object
  1455. * @hidden
  1456. */
  1457. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1458. }
  1459. }
  1460. declare module BABYLON {
  1461. /**
  1462. * @hidden
  1463. */
  1464. export interface IColor4Like {
  1465. r: float;
  1466. g: float;
  1467. b: float;
  1468. a: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor3Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. }
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IVector4Like {
  1482. x: float;
  1483. y: float;
  1484. z: float;
  1485. w: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector3Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector2Like {
  1499. x: float;
  1500. y: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IMatrixLike {
  1506. toArray(): DeepImmutable<Float32Array>;
  1507. updateFlag: int;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IViewportLike {
  1513. x: float;
  1514. y: float;
  1515. width: float;
  1516. height: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IPlaneLike {
  1522. normal: IVector3Like;
  1523. d: float;
  1524. normalize(): void;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /**
  1529. * Interface used to define common properties for effect fallbacks
  1530. */
  1531. export interface IEffectFallbacks {
  1532. /**
  1533. * Removes the defines that should be removed when falling back.
  1534. * @param currentDefines defines the current define statements for the shader.
  1535. * @param effect defines the current effect we try to compile
  1536. * @returns The resulting defines with defines of the current rank removed.
  1537. */
  1538. reduce(currentDefines: string, effect: Effect): string;
  1539. /**
  1540. * Removes the fallback from the bound mesh.
  1541. */
  1542. unBindMesh(): void;
  1543. /**
  1544. * Checks to see if more fallbacks are still availible.
  1545. */
  1546. hasMoreFallbacks: boolean;
  1547. }
  1548. }
  1549. declare module BABYLON {
  1550. /**
  1551. * Class used to evalaute queries containing `and` and `or` operators
  1552. */
  1553. export class AndOrNotEvaluator {
  1554. /**
  1555. * Evaluate a query
  1556. * @param query defines the query to evaluate
  1557. * @param evaluateCallback defines the callback used to filter result
  1558. * @returns true if the query matches
  1559. */
  1560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1561. private static _HandleParenthesisContent;
  1562. private static _SimplifyNegation;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /**
  1567. * Class used to store custom tags
  1568. */
  1569. export class Tags {
  1570. /**
  1571. * Adds support for tags on the given object
  1572. * @param obj defines the object to use
  1573. */
  1574. static EnableFor(obj: any): void;
  1575. /**
  1576. * Removes tags support
  1577. * @param obj defines the object to use
  1578. */
  1579. static DisableFor(obj: any): void;
  1580. /**
  1581. * Gets a boolean indicating if the given object has tags
  1582. * @param obj defines the object to use
  1583. * @returns a boolean
  1584. */
  1585. static HasTags(obj: any): boolean;
  1586. /**
  1587. * Gets the tags available on a given object
  1588. * @param obj defines the object to use
  1589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1590. * @returns the tags
  1591. */
  1592. static GetTags(obj: any, asString?: boolean): any;
  1593. /**
  1594. * Adds tags to an object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1598. */
  1599. static AddTagsTo(obj: any, tagsString: string): void;
  1600. /**
  1601. * @hidden
  1602. */
  1603. static _AddTagTo(obj: any, tag: string): void;
  1604. /**
  1605. * Removes specific tags from a specific object
  1606. * @param obj defines the object to use
  1607. * @param tagsString defines the tags to remove
  1608. */
  1609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1610. /**
  1611. * @hidden
  1612. */
  1613. static _RemoveTagFrom(obj: any, tag: string): void;
  1614. /**
  1615. * Defines if tags hosted on an object match a given query
  1616. * @param obj defines the object to use
  1617. * @param tagsQuery defines the tag query
  1618. * @returns a boolean
  1619. */
  1620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1621. }
  1622. }
  1623. declare module BABYLON {
  1624. /**
  1625. * Scalar computation library
  1626. */
  1627. export class Scalar {
  1628. /**
  1629. * Two pi constants convenient for computation.
  1630. */
  1631. static TwoPi: number;
  1632. /**
  1633. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1634. * @param a number
  1635. * @param b number
  1636. * @param epsilon (default = 1.401298E-45)
  1637. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. */
  1639. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1640. /**
  1641. * Returns a string : the upper case translation of the number i to hexadecimal.
  1642. * @param i number
  1643. * @returns the upper case translation of the number i to hexadecimal.
  1644. */
  1645. static ToHex(i: number): string;
  1646. /**
  1647. * Returns -1 if value is negative and +1 is value is positive.
  1648. * @param value the value
  1649. * @returns the value itself if it's equal to zero.
  1650. */
  1651. static Sign(value: number): number;
  1652. /**
  1653. * Returns the value itself if it's between min and max.
  1654. * Returns min if the value is lower than min.
  1655. * Returns max if the value is greater than max.
  1656. * @param value the value to clmap
  1657. * @param min the min value to clamp to (default: 0)
  1658. * @param max the max value to clamp to (default: 1)
  1659. * @returns the clamped value
  1660. */
  1661. static Clamp(value: number, min?: number, max?: number): number;
  1662. /**
  1663. * the log2 of value.
  1664. * @param value the value to compute log2 of
  1665. * @returns the log2 of value.
  1666. */
  1667. static Log2(value: number): number;
  1668. /**
  1669. * Loops the value, so that it is never larger than length and never smaller than 0.
  1670. *
  1671. * This is similar to the modulo operator but it works with floating point numbers.
  1672. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1673. * With t = 5 and length = 2.5, the result would be 0.0.
  1674. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1675. * @param value the value
  1676. * @param length the length
  1677. * @returns the looped value
  1678. */
  1679. static Repeat(value: number, length: number): number;
  1680. /**
  1681. * Normalize the value between 0.0 and 1.0 using min and max values
  1682. * @param value value to normalize
  1683. * @param min max to normalize between
  1684. * @param max min to normalize between
  1685. * @returns the normalized value
  1686. */
  1687. static Normalize(value: number, min: number, max: number): number;
  1688. /**
  1689. * Denormalize the value from 0.0 and 1.0 using min and max values
  1690. * @param normalized value to denormalize
  1691. * @param min max to denormalize between
  1692. * @param max min to denormalize between
  1693. * @returns the denormalized value
  1694. */
  1695. static Denormalize(normalized: number, min: number, max: number): number;
  1696. /**
  1697. * Calculates the shortest difference between two given angles given in degrees.
  1698. * @param current current angle in degrees
  1699. * @param target target angle in degrees
  1700. * @returns the delta
  1701. */
  1702. static DeltaAngle(current: number, target: number): number;
  1703. /**
  1704. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1705. * @param tx value
  1706. * @param length length
  1707. * @returns The returned value will move back and forth between 0 and length
  1708. */
  1709. static PingPong(tx: number, length: number): number;
  1710. /**
  1711. * Interpolates between min and max with smoothing at the limits.
  1712. *
  1713. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1714. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1715. * @param from from
  1716. * @param to to
  1717. * @param tx value
  1718. * @returns the smooth stepped value
  1719. */
  1720. static SmoothStep(from: number, to: number, tx: number): number;
  1721. /**
  1722. * Moves a value current towards target.
  1723. *
  1724. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1725. * Negative values of maxDelta pushes the value away from target.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting value
  1730. */
  1731. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1734. *
  1735. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1736. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1737. * @param current current value
  1738. * @param target target value
  1739. * @param maxDelta max distance to move
  1740. * @returns resulting angle
  1741. */
  1742. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1743. /**
  1744. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static Lerp(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1753. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static LerpAngle(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1762. * @param a start value
  1763. * @param b target value
  1764. * @param value value between a and b
  1765. * @returns the inverseLerp value
  1766. */
  1767. static InverseLerp(a: number, b: number, value: number): number;
  1768. /**
  1769. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1770. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1771. * @param value1 spline value
  1772. * @param tangent1 spline value
  1773. * @param value2 spline value
  1774. * @param tangent2 spline value
  1775. * @param amount input value
  1776. * @returns hermite result
  1777. */
  1778. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1779. /**
  1780. * Returns a random float number between and min and max values
  1781. * @param min min value of random
  1782. * @param max max value of random
  1783. * @returns random value
  1784. */
  1785. static RandomRange(min: number, max: number): number;
  1786. /**
  1787. * This function returns percentage of a number in a given range.
  1788. *
  1789. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1790. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1791. * @param number to convert to percentage
  1792. * @param min min range
  1793. * @param max max range
  1794. * @returns the percentage
  1795. */
  1796. static RangeToPercent(number: number, min: number, max: number): number;
  1797. /**
  1798. * This function returns number that corresponds to the percentage in a given range.
  1799. *
  1800. * PercentToRange(0.34,0,100) will return 34.
  1801. * @param percent to convert to number
  1802. * @param min min range
  1803. * @param max max range
  1804. * @returns the number
  1805. */
  1806. static PercentToRange(percent: number, min: number, max: number): number;
  1807. /**
  1808. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1809. * @param angle The angle to normalize in radian.
  1810. * @return The converted angle.
  1811. */
  1812. static NormalizeRadians(angle: number): number;
  1813. }
  1814. }
  1815. declare module BABYLON {
  1816. /**
  1817. * Constant used to convert a value to gamma space
  1818. * @ignorenaming
  1819. */
  1820. export const ToGammaSpace: number;
  1821. /**
  1822. * Constant used to convert a value to linear space
  1823. * @ignorenaming
  1824. */
  1825. export const ToLinearSpace = 2.2;
  1826. /**
  1827. * Constant used to define the minimal number value in Babylon.js
  1828. * @ignorenaming
  1829. */
  1830. let Epsilon: number;
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Class used to represent a viewport on screen
  1835. */
  1836. export class Viewport {
  1837. /** viewport left coordinate */
  1838. x: number;
  1839. /** viewport top coordinate */
  1840. y: number;
  1841. /**viewport width */
  1842. width: number;
  1843. /** viewport height */
  1844. height: number;
  1845. /**
  1846. * Creates a Viewport object located at (x, y) and sized (width, height)
  1847. * @param x defines viewport left coordinate
  1848. * @param y defines viewport top coordinate
  1849. * @param width defines the viewport width
  1850. * @param height defines the viewport height
  1851. */
  1852. constructor(
  1853. /** viewport left coordinate */
  1854. x: number,
  1855. /** viewport top coordinate */
  1856. y: number,
  1857. /**viewport width */
  1858. width: number,
  1859. /** viewport height */
  1860. height: number);
  1861. /**
  1862. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @returns a new Viewport
  1866. */
  1867. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1868. /**
  1869. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @param ref defines the target viewport
  1873. * @returns the current viewport
  1874. */
  1875. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1876. /**
  1877. * Returns a new Viewport copied from the current one
  1878. * @returns a new Viewport
  1879. */
  1880. clone(): Viewport;
  1881. }
  1882. }
  1883. declare module BABYLON {
  1884. /**
  1885. * Class containing a set of static utilities functions for arrays.
  1886. */
  1887. export class ArrayTools {
  1888. /**
  1889. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1890. * @param size the number of element to construct and put in the array
  1891. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1892. * @returns a new array filled with new objects
  1893. */
  1894. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1895. }
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class representing a vector containing 2 coordinates
  1900. */
  1901. export class Vector2 {
  1902. /** defines the first coordinate */
  1903. x: number;
  1904. /** defines the second coordinate */
  1905. y: number;
  1906. /**
  1907. * Creates a new Vector2 from the given x and y coordinates
  1908. * @param x defines the first coordinate
  1909. * @param y defines the second coordinate
  1910. */
  1911. constructor(
  1912. /** defines the first coordinate */
  1913. x?: number,
  1914. /** defines the second coordinate */
  1915. y?: number);
  1916. /**
  1917. * Gets a string with the Vector2 coordinates
  1918. * @returns a string with the Vector2 coordinates
  1919. */
  1920. toString(): string;
  1921. /**
  1922. * Gets class name
  1923. * @returns the string "Vector2"
  1924. */
  1925. getClassName(): string;
  1926. /**
  1927. * Gets current vector hash code
  1928. * @returns the Vector2 hash code as a number
  1929. */
  1930. getHashCode(): number;
  1931. /**
  1932. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1933. * @param array defines the source array
  1934. * @param index defines the offset in source array
  1935. * @returns the current Vector2
  1936. */
  1937. toArray(array: FloatArray, index?: number): Vector2;
  1938. /**
  1939. * Copy the current vector to an array
  1940. * @returns a new array with 2 elements: the Vector2 coordinates.
  1941. */
  1942. asArray(): number[];
  1943. /**
  1944. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1945. * @param source defines the source Vector2
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFromFloats(x: number, y: number): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. set(x: number, y: number): Vector2;
  1963. /**
  1964. * Add another vector with the current one
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1967. */
  1968. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns a new Vector2
  1986. */
  1987. addVector3(otherVector: Vector3): Vector2;
  1988. /**
  1989. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. subtract(otherVector: Vector2): Vector2;
  1994. /**
  1995. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2003. * @param otherVector defines the other vector
  2004. * @returns the current updated Vector2
  2005. */
  2006. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2007. /**
  2008. * Multiplies in place the current Vector2 coordinates by the given ones
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns a new Vector2
  2017. */
  2018. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @param result defines the target vector
  2023. * @returns the unmodified current Vector2
  2024. */
  2025. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2026. /**
  2027. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2028. * @param x defines the first coordinate
  2029. * @param y defines the second coordinate
  2030. * @returns a new Vector2
  2031. */
  2032. multiplyByFloats(x: number, y: number): Vector2;
  2033. /**
  2034. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2035. * @param otherVector defines the other vector
  2036. * @returns a new Vector2
  2037. */
  2038. divide(otherVector: Vector2): Vector2;
  2039. /**
  2040. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @param result defines the target vector
  2043. * @returns the unmodified current Vector2
  2044. */
  2045. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2046. /**
  2047. * Divides the current Vector2 coordinates by the given ones
  2048. * @param otherVector defines the other vector
  2049. * @returns the current updated Vector2
  2050. */
  2051. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Gets a new Vector2 with current Vector2 negated coordinates
  2054. * @returns a new Vector2
  2055. */
  2056. negate(): Vector2;
  2057. /**
  2058. * Negate this vector in place
  2059. * @returns this
  2060. */
  2061. negateInPlace(): Vector2;
  2062. /**
  2063. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2064. * @param result defines the Vector3 object where to store the result
  2065. * @returns the current Vector2
  2066. */
  2067. negateToRef(result: Vector2): Vector2;
  2068. /**
  2069. * Multiply the Vector2 coordinates by scale
  2070. * @param scale defines the scaling factor
  2071. * @returns the current updated Vector2
  2072. */
  2073. scaleInPlace(scale: number): Vector2;
  2074. /**
  2075. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2076. * @param scale defines the scaling factor
  2077. * @returns a new Vector2
  2078. */
  2079. scale(scale: number): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Gets a boolean if two vectors are equals
  2096. * @param otherVector defines the other vector
  2097. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2098. */
  2099. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2100. /**
  2101. * Gets a boolean if two vectors are equals (using an epsilon value)
  2102. * @param otherVector defines the other vector
  2103. * @param epsilon defines the minimal distance to consider equality
  2104. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2105. */
  2106. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. floor(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 from current Vector2 floored values
  2114. * @returns a new Vector2
  2115. */
  2116. fract(): Vector2;
  2117. /**
  2118. * Gets the length of the vector
  2119. * @returns the vector length (float)
  2120. */
  2121. length(): number;
  2122. /**
  2123. * Gets the vector squared length
  2124. * @returns the vector squared length (float)
  2125. */
  2126. lengthSquared(): number;
  2127. /**
  2128. * Normalize the vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. normalize(): Vector2;
  2132. /**
  2133. * Gets a new Vector2 copied from the Vector2
  2134. * @returns a new Vector2
  2135. */
  2136. clone(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(0, 0)
  2139. * @returns a new Vector2
  2140. */
  2141. static Zero(): Vector2;
  2142. /**
  2143. * Gets a new Vector2(1, 1)
  2144. * @returns a new Vector2
  2145. */
  2146. static One(): Vector2;
  2147. /**
  2148. * Gets a new Vector2 set from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @returns a new Vector2
  2152. */
  2153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2154. /**
  2155. * Sets "result" from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @param result defines the target vector
  2159. */
  2160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2161. /**
  2162. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2163. * @param value1 defines 1st point of control
  2164. * @param value2 defines 2nd point of control
  2165. * @param value3 defines 3rd point of control
  2166. * @param value4 defines 4th point of control
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * 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".
  2173. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2174. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2175. * @param value defines the value to clamp
  2176. * @param min defines the lower limit
  2177. * @param max defines the upper limit
  2178. * @returns a new Vector2
  2179. */
  2180. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2183. * @param value1 defines the 1st control point
  2184. * @param tangent1 defines the outgoing tangent
  2185. * @param value2 defines the 2nd control point
  2186. * @param tangent2 defines the incoming tangent
  2187. * @param amount defines the interpolation factor
  2188. * @returns a new Vector2
  2189. */
  2190. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2193. * @param start defines the start vector
  2194. * @param end defines the end vector
  2195. * @param amount defines the interpolation factor
  2196. * @returns a new Vector2
  2197. */
  2198. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2199. /**
  2200. * Gets the dot product of the vector "left" and the vector "right"
  2201. * @param left defines first vector
  2202. * @param right defines second vector
  2203. * @returns the dot product (float)
  2204. */
  2205. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2206. /**
  2207. * Returns a new Vector2 equal to the normalized given vector
  2208. * @param vector defines the vector to normalize
  2209. * @returns a new Vector2
  2210. */
  2211. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @returns a new Vector2
  2231. */
  2232. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2233. /**
  2234. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @param result defines the target vector
  2238. */
  2239. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2240. /**
  2241. * Determines if a given vector is included in a triangle
  2242. * @param p defines the vector to test
  2243. * @param p0 defines 1st triangle point
  2244. * @param p1 defines 2nd triangle point
  2245. * @param p2 defines 3rd triangle point
  2246. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2247. */
  2248. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2249. /**
  2250. * Gets the distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the distance between vectors
  2254. */
  2255. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Returns the squared distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the squared distance between vectors
  2261. */
  2262. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns a new Vector2
  2268. */
  2269. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2270. /**
  2271. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2272. * @param p defines the middle point
  2273. * @param segA defines one point of the segment
  2274. * @param segB defines the other point of the segment
  2275. * @returns the shortest distance
  2276. */
  2277. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2278. }
  2279. /**
  2280. * Class used to store (x,y,z) vector representation
  2281. * A Vector3 is the main object used in 3D geometry
  2282. * It can represent etiher the coordinates of a point the space, either a direction
  2283. * Reminder: js uses a left handed forward facing system
  2284. */
  2285. export class Vector3 {
  2286. /**
  2287. * Defines the first coordinates (on X axis)
  2288. */
  2289. x: number;
  2290. /**
  2291. * Defines the second coordinates (on Y axis)
  2292. */
  2293. y: number;
  2294. /**
  2295. * Defines the third coordinates (on Z axis)
  2296. */
  2297. z: number;
  2298. private static _UpReadOnly;
  2299. private static _ZeroReadOnly;
  2300. /**
  2301. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2302. * @param x defines the first coordinates (on X axis)
  2303. * @param y defines the second coordinates (on Y axis)
  2304. * @param z defines the third coordinates (on Z axis)
  2305. */
  2306. constructor(
  2307. /**
  2308. * Defines the first coordinates (on X axis)
  2309. */
  2310. x?: number,
  2311. /**
  2312. * Defines the second coordinates (on Y axis)
  2313. */
  2314. y?: number,
  2315. /**
  2316. * Defines the third coordinates (on Z axis)
  2317. */
  2318. z?: number);
  2319. /**
  2320. * Creates a string representation of the Vector3
  2321. * @returns a string with the Vector3 coordinates.
  2322. */
  2323. toString(): string;
  2324. /**
  2325. * Gets the class name
  2326. * @returns the string "Vector3"
  2327. */
  2328. getClassName(): string;
  2329. /**
  2330. * Creates the Vector3 hash code
  2331. * @returns a number which tends to be unique between Vector3 instances
  2332. */
  2333. getHashCode(): number;
  2334. /**
  2335. * Creates an array containing three elements : the coordinates of the Vector3
  2336. * @returns a new array of numbers
  2337. */
  2338. asArray(): number[];
  2339. /**
  2340. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2341. * @param array defines the destination array
  2342. * @param index defines the offset in the destination array
  2343. * @returns the current Vector3
  2344. */
  2345. toArray(array: FloatArray, index?: number): Vector3;
  2346. /**
  2347. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2348. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2349. */
  2350. toQuaternion(): Quaternion;
  2351. /**
  2352. * Adds the given vector to the current Vector3
  2353. * @param otherVector defines the second operand
  2354. * @returns the current updated Vector3
  2355. */
  2356. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2357. /**
  2358. * Adds the given coordinates to the current Vector3
  2359. * @param x defines the x coordinate of the operand
  2360. * @param y defines the y coordinate of the operand
  2361. * @param z defines the z coordinate of the operand
  2362. * @returns the current updated Vector3
  2363. */
  2364. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2365. /**
  2366. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2367. * @param otherVector defines the second operand
  2368. * @returns the resulting Vector3
  2369. */
  2370. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2373. * @param otherVector defines the second operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2378. /**
  2379. * Subtract the given vector from the current Vector3
  2380. * @param otherVector defines the second operand
  2381. * @returns the current updated Vector3
  2382. */
  2383. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2384. /**
  2385. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the resulting Vector3
  2388. */
  2389. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2392. * @param otherVector defines the second operand
  2393. * @param result defines the Vector3 object where to store the result
  2394. * @returns the current Vector3
  2395. */
  2396. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2397. /**
  2398. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the resulting Vector3
  2403. */
  2404. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2407. * @param x defines the x coordinate of the operand
  2408. * @param y defines the y coordinate of the operand
  2409. * @param z defines the z coordinate of the operand
  2410. * @param result defines the Vector3 object where to store the result
  2411. * @returns the current Vector3
  2412. */
  2413. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2414. /**
  2415. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2416. * @returns a new Vector3
  2417. */
  2418. negate(): Vector3;
  2419. /**
  2420. * Negate this vector in place
  2421. * @returns this
  2422. */
  2423. negateInPlace(): Vector3;
  2424. /**
  2425. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. negateToRef(result: Vector3): Vector3;
  2430. /**
  2431. * Multiplies the Vector3 coordinates by the float "scale"
  2432. * @param scale defines the multiplier factor
  2433. * @returns the current updated Vector3
  2434. */
  2435. scaleInPlace(scale: number): Vector3;
  2436. /**
  2437. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2438. * @param scale defines the multiplier factor
  2439. * @returns a new Vector3
  2440. */
  2441. scale(scale: number): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2444. * @param scale defines the multiplier factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. scaleToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2451. * @param scale defines the scale factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the unmodified current Vector3
  2454. */
  2455. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2458. * @param otherVector defines the second operand
  2459. * @returns true if both vectors are equals
  2460. */
  2461. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2464. * @param otherVector defines the second operand
  2465. * @param epsilon defines the minimal distance to define values as equals
  2466. * @returns true if both vectors are distant less than epsilon
  2467. */
  2468. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 coordinates equals the given floats
  2471. * @param x defines the x coordinate of the operand
  2472. * @param y defines the y coordinate of the operand
  2473. * @param z defines the z coordinate of the operand
  2474. * @returns true if both vectors are equals
  2475. */
  2476. equalsToFloats(x: number, y: number, z: number): boolean;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the given ones
  2479. * @param otherVector defines the second operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the new Vector3
  2487. */
  2488. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the new Vector3
  2502. */
  2503. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2506. * @param otherVector defines the second operand
  2507. * @returns the new Vector3
  2508. */
  2509. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2512. * @param otherVector defines the second operand
  2513. * @param result defines the Vector3 object where to store the result
  2514. * @returns the current Vector3
  2515. */
  2516. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones.
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. divideInPlace(otherVector: Vector3): Vector3;
  2523. /**
  2524. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2525. * @param other defines the second operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2531. * @param other defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2537. * @param x defines the x coordinate of the operand
  2538. * @param y defines the y coordinate of the operand
  2539. * @param z defines the z coordinate of the operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2553. * Check if is non uniform within a certain amount of decimal places to account for this
  2554. * @param epsilon the amount the values can differ
  2555. * @returns if the the vector is non uniform to a certain number of decimal places
  2556. */
  2557. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2558. /**
  2559. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2560. */
  2561. get isNonUniform(): boolean;
  2562. /**
  2563. * Gets a new Vector3 from current Vector3 floored values
  2564. * @returns a new Vector3
  2565. */
  2566. floor(): Vector3;
  2567. /**
  2568. * Gets a new Vector3 from current Vector3 floored values
  2569. * @returns a new Vector3
  2570. */
  2571. fract(): Vector3;
  2572. /**
  2573. * Gets the length of the Vector3
  2574. * @returns the length of the Vector3
  2575. */
  2576. length(): number;
  2577. /**
  2578. * Gets the squared length of the Vector3
  2579. * @returns squared length of the Vector3
  2580. */
  2581. lengthSquared(): number;
  2582. /**
  2583. * Normalize the current Vector3.
  2584. * Please note that this is an in place operation.
  2585. * @returns the current updated Vector3
  2586. */
  2587. normalize(): Vector3;
  2588. /**
  2589. * Reorders the x y z properties of the vector in place
  2590. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2591. * @returns the current updated vector
  2592. */
  2593. reorderInPlace(order: string): this;
  2594. /**
  2595. * Rotates the vector around 0,0,0 by a quaternion
  2596. * @param quaternion the rotation quaternion
  2597. * @param result vector to store the result
  2598. * @returns the resulting vector
  2599. */
  2600. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2601. /**
  2602. * Rotates a vector around a given point
  2603. * @param quaternion the rotation quaternion
  2604. * @param point the point to rotate around
  2605. * @param result vector to store the result
  2606. * @returns the resulting vector
  2607. */
  2608. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2609. /**
  2610. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2611. * The cross product is then orthogonal to both current and "other"
  2612. * @param other defines the right operand
  2613. * @returns the cross product
  2614. */
  2615. cross(other: Vector3): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 with the given input length.
  2618. * Please note that this is an in place operation.
  2619. * @param len the length of the vector
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalizeFromLength(len: number): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 to a new vector
  2625. * @returns the new Vector3
  2626. */
  2627. normalizeToNew(): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 to the reference
  2630. * @param reference define the Vector3 to update
  2631. * @returns the updated Vector3
  2632. */
  2633. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Creates a new Vector3 copied from the current Vector3
  2636. * @returns the new Vector3
  2637. */
  2638. clone(): Vector3;
  2639. /**
  2640. * Copies the given vector coordinates to the current Vector3 ones
  2641. * @param source defines the source Vector3
  2642. * @returns the current updated Vector3
  2643. */
  2644. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2645. /**
  2646. * Copies the given floats to the current Vector3 coordinates
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the current updated Vector3
  2651. */
  2652. copyFromFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Copies the given floats to the current Vector3 coordinates
  2655. * @param x defines the x coordinate of the operand
  2656. * @param y defines the y coordinate of the operand
  2657. * @param z defines the z coordinate of the operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. set(x: number, y: number, z: number): Vector3;
  2661. /**
  2662. * Copies the given float to the current Vector3 coordinates
  2663. * @param v defines the x, y and z coordinates of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. setAll(v: number): Vector3;
  2667. /**
  2668. * Get the clip factor between two vectors
  2669. * @param vector0 defines the first operand
  2670. * @param vector1 defines the second operand
  2671. * @param axis defines the axis to use
  2672. * @param size defines the size along the axis
  2673. * @returns the clip factor
  2674. */
  2675. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2676. /**
  2677. * Get angle between two vectors
  2678. * @param vector0 angle between vector0 and vector1
  2679. * @param vector1 angle between vector0 and vector1
  2680. * @param normal direction of the normal
  2681. * @return the angle between vector0 and vector1
  2682. */
  2683. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. */
  2690. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. * @deprecated Please use FromArray instead.
  2697. */
  2698. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. * @deprecated Please use FromArrayToRef instead.
  2712. */
  2713. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2714. /**
  2715. * Sets the given vector "result" with the given floats.
  2716. * @param x defines the x coordinate of the source
  2717. * @param y defines the y coordinate of the source
  2718. * @param z defines the z coordinate of the source
  2719. * @param result defines the Vector3 where to store the result
  2720. */
  2721. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2724. * @returns a new empty Vector3
  2725. */
  2726. static Zero(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2729. * @returns a new unit Vector3
  2730. */
  2731. static One(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2734. * @returns a new up Vector3
  2735. */
  2736. static Up(): Vector3;
  2737. /**
  2738. * Gets a up Vector3 that must not be updated
  2739. */
  2740. static get UpReadOnly(): DeepImmutable<Vector3>;
  2741. /**
  2742. * Gets a zero Vector3 that must not be updated
  2743. */
  2744. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2747. * @returns a new down Vector3
  2748. */
  2749. static Down(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2752. * @returns a new forward Vector3
  2753. */
  2754. static Forward(): Vector3;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2757. * @returns a new forward Vector3
  2758. */
  2759. static Backward(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2762. * @returns a new right Vector3
  2763. */
  2764. static Right(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2767. * @returns a new left Vector3
  2768. */
  2769. static Left(): Vector3;
  2770. /**
  2771. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2772. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2773. * @param vector defines the Vector3 to transform
  2774. * @param transformation defines the transformation matrix
  2775. * @returns the transformed Vector3
  2776. */
  2777. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2778. /**
  2779. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2780. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @param result defines the Vector3 where to store the result
  2784. */
  2785. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2786. /**
  2787. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2788. * This method computes tranformed coordinates only, not transformed direction vectors
  2789. * @param x define the x coordinate of the source vector
  2790. * @param y define the y coordinate of the source vector
  2791. * @param z define the z coordinate of the source vector
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the new Vector3
  2802. */
  2803. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2806. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2814. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2824. * @param value1 defines the first control point
  2825. * @param value2 defines the second control point
  2826. * @param value3 defines the third control point
  2827. * @param value4 defines the fourth control point
  2828. * @param amount defines the amount on the spline to use
  2829. * @returns the new Vector3
  2830. */
  2831. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2832. /**
  2833. * 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"
  2834. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2835. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2836. * @param value defines the current value
  2837. * @param min defines the lower range value
  2838. * @param max defines the upper range value
  2839. * @returns the new Vector3
  2840. */
  2841. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * 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"
  2844. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2845. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2846. * @param value defines the current value
  2847. * @param min defines the lower range value
  2848. * @param max defines the upper range value
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2852. /**
  2853. * Checks if a given vector is inside a specific range
  2854. * @param v defines the vector to test
  2855. * @param min defines the minimum range
  2856. * @param max defines the maximum range
  2857. */
  2858. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2861. * @param value1 defines the first control point
  2862. * @param tangent1 defines the first tangent vector
  2863. * @param value2 defines the second control point
  2864. * @param tangent2 defines the second tangent vector
  2865. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2866. * @returns the new Vector3
  2867. */
  2868. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2871. * @param start defines the start value
  2872. * @param end defines the end value
  2873. * @param amount max defines amount between both (between 0 and 1)
  2874. * @returns the new Vector3
  2875. */
  2876. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2879. * @param start defines the start value
  2880. * @param end defines the end value
  2881. * @param amount max defines amount between both (between 0 and 1)
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2885. /**
  2886. * Returns the dot product (float) between the vectors "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @returns the dot product
  2890. */
  2891. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2892. /**
  2893. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2894. * The cross product is then orthogonal to both "left" and "right"
  2895. * @param left defines the left operand
  2896. * @param right defines the right operand
  2897. * @returns the cross product
  2898. */
  2899. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the cross product of "left" and "right"
  2902. * The cross product is then orthogonal to both "left" and "right"
  2903. * @param left defines the left operand
  2904. * @param right defines the right operand
  2905. * @param result defines the Vector3 where to store the result
  2906. */
  2907. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2908. /**
  2909. * Returns a new Vector3 as the normalization of the given vector
  2910. * @param vector defines the Vector3 to normalize
  2911. * @returns the new Vector3
  2912. */
  2913. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the normalization of the given first vector
  2916. * @param vector defines the Vector3 to normalize
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2920. /**
  2921. * Project a Vector3 onto screen space
  2922. * @param vector defines the Vector3 to project
  2923. * @param world defines the world matrix to use
  2924. * @param transform defines the transform (view x projection) matrix to use
  2925. * @param viewport defines the screen viewport to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2929. /** @hidden */
  2930. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param source defines the screen space Vector3 to use
  2934. * @param viewportWidth defines the current width of the viewport
  2935. * @param viewportHeight defines the current height of the viewport
  2936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2937. * @param transform defines the transform (view x projection) matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param source defines the screen space Vector3 to use
  2955. * @param viewportWidth defines the current width of the viewport
  2956. * @param viewportHeight defines the current height of the viewport
  2957. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2958. * @param view defines the view matrix to use
  2959. * @param projection defines the projection matrix to use
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param sourceX defines the screen space x coordinate to use
  2966. * @param sourceY defines the screen space y coordinate to use
  2967. * @param sourceZ defines the screen space z coordinate to use
  2968. * @param viewportWidth defines the current width of the viewport
  2969. * @param viewportHeight defines the current height of the viewport
  2970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2971. * @param view defines the view matrix to use
  2972. * @param projection defines the projection matrix to use
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Gets the minimal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Gets the maximal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Returns the distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the distance
  2995. */
  2996. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns the squared distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the squared distance
  3002. */
  3003. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns a new Vector3 located at the center between "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the new Vector3
  3009. */
  3010. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3013. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3014. * to something in order to rotate it from its local system to the given target system
  3015. * Note: axis1, axis2 and axis3 are normalized during this operation
  3016. * @param axis1 defines the first axis
  3017. * @param axis2 defines the second axis
  3018. * @param axis3 defines the third axis
  3019. * @returns a new Vector3
  3020. */
  3021. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3024. * @param axis1 defines the first axis
  3025. * @param axis2 defines the second axis
  3026. * @param axis3 defines the third axis
  3027. * @param ref defines the Vector3 where to store the result
  3028. */
  3029. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3030. }
  3031. /**
  3032. * Vector4 class created for EulerAngle class conversion to Quaternion
  3033. */
  3034. export class Vector4 {
  3035. /** x value of the vector */
  3036. x: number;
  3037. /** y value of the vector */
  3038. y: number;
  3039. /** z value of the vector */
  3040. z: number;
  3041. /** w value of the vector */
  3042. w: number;
  3043. /**
  3044. * Creates a Vector4 object from the given floats.
  3045. * @param x x value of the vector
  3046. * @param y y value of the vector
  3047. * @param z z value of the vector
  3048. * @param w w value of the vector
  3049. */
  3050. constructor(
  3051. /** x value of the vector */
  3052. x: number,
  3053. /** y value of the vector */
  3054. y: number,
  3055. /** z value of the vector */
  3056. z: number,
  3057. /** w value of the vector */
  3058. w: number);
  3059. /**
  3060. * Returns the string with the Vector4 coordinates.
  3061. * @returns a string containing all the vector values
  3062. */
  3063. toString(): string;
  3064. /**
  3065. * Returns the string "Vector4".
  3066. * @returns "Vector4"
  3067. */
  3068. getClassName(): string;
  3069. /**
  3070. * Returns the Vector4 hash code.
  3071. * @returns a unique hash code
  3072. */
  3073. getHashCode(): number;
  3074. /**
  3075. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3076. * @returns the resulting array
  3077. */
  3078. asArray(): number[];
  3079. /**
  3080. * Populates the given array from the given index with the Vector4 coordinates.
  3081. * @param array array to populate
  3082. * @param index index of the array to start at (default: 0)
  3083. * @returns the Vector4.
  3084. */
  3085. toArray(array: FloatArray, index?: number): Vector4;
  3086. /**
  3087. * Adds the given vector to the current Vector4.
  3088. * @param otherVector the vector to add
  3089. * @returns the updated Vector4.
  3090. */
  3091. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3092. /**
  3093. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3094. * @param otherVector the vector to add
  3095. * @returns the resulting vector
  3096. */
  3097. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3098. /**
  3099. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3100. * @param otherVector the vector to add
  3101. * @param result the vector to store the result
  3102. * @returns the current Vector4.
  3103. */
  3104. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3105. /**
  3106. * Subtract in place the given vector from the current Vector4.
  3107. * @param otherVector the vector to subtract
  3108. * @returns the updated Vector4.
  3109. */
  3110. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3111. /**
  3112. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3113. * @param otherVector the vector to add
  3114. * @returns the new vector with the result
  3115. */
  3116. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3117. /**
  3118. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @param result the vector to store the result
  3121. * @returns the current Vector4.
  3122. */
  3123. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3124. /**
  3125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3126. */
  3127. /**
  3128. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3129. * @param x value to subtract
  3130. * @param y value to subtract
  3131. * @param z value to subtract
  3132. * @param w value to subtract
  3133. * @returns new vector containing the result
  3134. */
  3135. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3136. /**
  3137. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @param result the vector to store the result in
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3148. * @returns a new vector with the negated values
  3149. */
  3150. negate(): Vector4;
  3151. /**
  3152. * Negate this vector in place
  3153. * @returns this
  3154. */
  3155. negateInPlace(): Vector4;
  3156. /**
  3157. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3158. * @param result defines the Vector3 object where to store the result
  3159. * @returns the current Vector4
  3160. */
  3161. negateToRef(result: Vector4): Vector4;
  3162. /**
  3163. * Multiplies the current Vector4 coordinates by scale (float).
  3164. * @param scale the number to scale with
  3165. * @returns the updated Vector4.
  3166. */
  3167. scaleInPlace(scale: number): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3170. * @param scale the number to scale with
  3171. * @returns a new vector with the result
  3172. */
  3173. scale(scale: number): Vector4;
  3174. /**
  3175. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3176. * @param scale the number to scale with
  3177. * @param result a vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. scaleToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3183. * @param scale defines the scale factor
  3184. * @param result defines the Vector4 object where to store the result
  3185. * @returns the unmodified current Vector4
  3186. */
  3187. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3190. * @param otherVector the vector to compare against
  3191. * @returns true if they are equal
  3192. */
  3193. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3194. /**
  3195. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3196. * @param otherVector vector to compare against
  3197. * @param epsilon (Default: very small number)
  3198. * @returns true if they are equal
  3199. */
  3200. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3201. /**
  3202. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3203. * @param x x value to compare against
  3204. * @param y y value to compare against
  3205. * @param z z value to compare against
  3206. * @param w w value to compare against
  3207. * @returns true if equal
  3208. */
  3209. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3210. /**
  3211. * Multiplies in place the current Vector4 by the given one.
  3212. * @param otherVector vector to multiple with
  3213. * @returns the updated Vector4.
  3214. */
  3215. multiplyInPlace(otherVector: Vector4): Vector4;
  3216. /**
  3217. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3218. * @param otherVector vector to multiple with
  3219. * @returns resulting new vector
  3220. */
  3221. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3222. /**
  3223. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3224. * @param otherVector vector to multiple with
  3225. * @param result vector to store the result
  3226. * @returns the current Vector4.
  3227. */
  3228. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3229. /**
  3230. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3231. * @param x x value multiply with
  3232. * @param y y value multiply with
  3233. * @param z z value multiply with
  3234. * @param w w value multiply with
  3235. * @returns resulting new vector
  3236. */
  3237. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3240. * @param otherVector vector to devide with
  3241. * @returns resulting new vector
  3242. */
  3243. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3246. * @param otherVector vector to devide with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Divides the current Vector3 coordinates by the given ones.
  3253. * @param otherVector vector to devide with
  3254. * @returns the updated Vector3.
  3255. */
  3256. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3257. /**
  3258. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3259. * @param other defines the second operand
  3260. * @returns the current updated Vector4
  3261. */
  3262. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3265. * @param other defines the second operand
  3266. * @returns the current updated Vector4
  3267. */
  3268. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Gets a new Vector4 from current Vector4 floored values
  3271. * @returns a new Vector4
  3272. */
  3273. floor(): Vector4;
  3274. /**
  3275. * Gets a new Vector4 from current Vector3 floored values
  3276. * @returns a new Vector4
  3277. */
  3278. fract(): Vector4;
  3279. /**
  3280. * Returns the Vector4 length (float).
  3281. * @returns the length
  3282. */
  3283. length(): number;
  3284. /**
  3285. * Returns the Vector4 squared length (float).
  3286. * @returns the length squared
  3287. */
  3288. lengthSquared(): number;
  3289. /**
  3290. * Normalizes in place the Vector4.
  3291. * @returns the updated Vector4.
  3292. */
  3293. normalize(): Vector4;
  3294. /**
  3295. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3296. * @returns this converted to a new vector3
  3297. */
  3298. toVector3(): Vector3;
  3299. /**
  3300. * Returns a new Vector4 copied from the current one.
  3301. * @returns the new cloned vector
  3302. */
  3303. clone(): Vector4;
  3304. /**
  3305. * Updates the current Vector4 with the given one coordinates.
  3306. * @param source the source vector to copy from
  3307. * @returns the updated Vector4.
  3308. */
  3309. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3310. /**
  3311. * Updates the current Vector4 coordinates with the given floats.
  3312. * @param x float to copy from
  3313. * @param y float to copy from
  3314. * @param z float to copy from
  3315. * @param w float to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to set from
  3322. * @param y float to set from
  3323. * @param z float to set from
  3324. * @param w float to set from
  3325. * @returns the updated Vector4.
  3326. */
  3327. set(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Copies the given float to the current Vector3 coordinates
  3330. * @param v defines the x, y, z and w coordinates of the operand
  3331. * @returns the current updated Vector3
  3332. */
  3333. setAll(v: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @returns the new vector
  3339. */
  3340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3341. /**
  3342. * Updates the given vector "result" from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @param result the vector to store the result in
  3346. */
  3347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given Float32Array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" coordinates from the given floats.
  3357. * @param x float to set from
  3358. * @param y float to set from
  3359. * @param z float to set from
  3360. * @param w float to set from
  3361. * @param result the vector to the floats in
  3362. */
  3363. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3364. /**
  3365. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3366. * @returns the new vector
  3367. */
  3368. static Zero(): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3371. * @returns the new vector
  3372. */
  3373. static One(): Vector4;
  3374. /**
  3375. * Returns a new normalized Vector4 from the given one.
  3376. * @param vector the vector to normalize
  3377. * @returns the vector
  3378. */
  3379. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3380. /**
  3381. * Updates the given vector "result" from the normalization of the given one.
  3382. * @param vector the vector to normalize
  3383. * @param result the vector to store the result in
  3384. */
  3385. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3386. /**
  3387. * Returns a vector with the minimum values from the left and right vectors
  3388. * @param left left vector to minimize
  3389. * @param right right vector to minimize
  3390. * @returns a new vector with the minimum of the left and right vector values
  3391. */
  3392. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns a vector with the maximum values from the left and right vectors
  3395. * @param left left vector to maximize
  3396. * @param right right vector to maximize
  3397. * @returns a new vector with the maximum of the left and right vector values
  3398. */
  3399. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns the distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors
  3405. */
  3406. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors squared
  3412. */
  3413. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the center between
  3417. * @param value2 value to calulate the center between
  3418. * @return the center between the two vectors
  3419. */
  3420. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3423. * This methods computes transformed normalized direction vectors only.
  3424. * @param vector the vector to transform
  3425. * @param transformation the transformation matrix to apply
  3426. * @returns the new vector
  3427. */
  3428. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3429. /**
  3430. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3431. * This methods computes transformed normalized direction vectors only.
  3432. * @param vector the vector to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the result in
  3435. */
  3436. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3439. * This methods computes transformed normalized direction vectors only.
  3440. * @param x value to transform
  3441. * @param y value to transform
  3442. * @param z value to transform
  3443. * @param w value to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the results in
  3446. */
  3447. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Creates a new Vector4 from a Vector3
  3450. * @param source defines the source data
  3451. * @param w defines the 4th component (default is 0)
  3452. * @returns a new Vector4
  3453. */
  3454. static FromVector3(source: Vector3, w?: number): Vector4;
  3455. }
  3456. /**
  3457. * Class used to store quaternion data
  3458. * @see https://en.wikipedia.org/wiki/Quaternion
  3459. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3460. */
  3461. export class Quaternion {
  3462. /** defines the first component (0 by default) */
  3463. x: number;
  3464. /** defines the second component (0 by default) */
  3465. y: number;
  3466. /** defines the third component (0 by default) */
  3467. z: number;
  3468. /** defines the fourth component (1.0 by default) */
  3469. w: number;
  3470. /**
  3471. * Creates a new Quaternion from the given floats
  3472. * @param x defines the first component (0 by default)
  3473. * @param y defines the second component (0 by default)
  3474. * @param z defines the third component (0 by default)
  3475. * @param w defines the fourth component (1.0 by default)
  3476. */
  3477. constructor(
  3478. /** defines the first component (0 by default) */
  3479. x?: number,
  3480. /** defines the second component (0 by default) */
  3481. y?: number,
  3482. /** defines the third component (0 by default) */
  3483. z?: number,
  3484. /** defines the fourth component (1.0 by default) */
  3485. w?: number);
  3486. /**
  3487. * Gets a string representation for the current quaternion
  3488. * @returns a string with the Quaternion coordinates
  3489. */
  3490. toString(): string;
  3491. /**
  3492. * Gets the class name of the quaternion
  3493. * @returns the string "Quaternion"
  3494. */
  3495. getClassName(): string;
  3496. /**
  3497. * Gets a hash code for this quaternion
  3498. * @returns the quaternion hash code
  3499. */
  3500. getHashCode(): number;
  3501. /**
  3502. * Copy the quaternion to an array
  3503. * @returns a new array populated with 4 elements from the quaternion coordinates
  3504. */
  3505. asArray(): number[];
  3506. /**
  3507. * Check if two quaternions are equals
  3508. * @param otherQuaternion defines the second operand
  3509. * @return true if the current quaternion and the given one coordinates are strictly equals
  3510. */
  3511. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3512. /**
  3513. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3514. * @param otherQuaternion defines the other quaternion
  3515. * @param epsilon defines the minimal distance to consider equality
  3516. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3517. */
  3518. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3519. /**
  3520. * Clone the current quaternion
  3521. * @returns a new quaternion copied from the current one
  3522. */
  3523. clone(): Quaternion;
  3524. /**
  3525. * Copy a quaternion to the current one
  3526. * @param other defines the other quaternion
  3527. * @returns the updated current quaternion
  3528. */
  3529. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3530. /**
  3531. * Updates the current quaternion with the given float coordinates
  3532. * @param x defines the x coordinate
  3533. * @param y defines the y coordinate
  3534. * @param z defines the z coordinate
  3535. * @param w defines the w coordinate
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3539. /**
  3540. * Updates the current quaternion from the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. set(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Adds two quaternions
  3550. * @param other defines the second operand
  3551. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3552. */
  3553. add(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Add a quaternion to the current one
  3556. * @param other defines the quaternion to add
  3557. * @returns the current quaternion
  3558. */
  3559. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3560. /**
  3561. * Subtract two quaternions
  3562. * @param other defines the second operand
  3563. * @returns a new quaternion as the subtraction result of the given one from the current one
  3564. */
  3565. subtract(other: Quaternion): Quaternion;
  3566. /**
  3567. * Multiplies the current quaternion by a scale factor
  3568. * @param value defines the scale factor
  3569. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3570. */
  3571. scale(value: number): Quaternion;
  3572. /**
  3573. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3574. * @param scale defines the scale factor
  3575. * @param result defines the Quaternion object where to store the result
  3576. * @returns the unmodified current quaternion
  3577. */
  3578. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3579. /**
  3580. * Multiplies in place the current quaternion by a scale factor
  3581. * @param value defines the scale factor
  3582. * @returns the current modified quaternion
  3583. */
  3584. scaleInPlace(value: number): Quaternion;
  3585. /**
  3586. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3587. * @param scale defines the scale factor
  3588. * @param result defines the Quaternion object where to store the result
  3589. * @returns the unmodified current quaternion
  3590. */
  3591. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies two quaternions
  3594. * @param q1 defines the second operand
  3595. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3596. */
  3597. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3598. /**
  3599. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @param result defines the target quaternion
  3602. * @returns the current quaternion
  3603. */
  3604. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3605. /**
  3606. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @returns the currentupdated quaternion
  3609. */
  3610. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3611. /**
  3612. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3613. * @param ref defines the target quaternion
  3614. * @returns the current quaternion
  3615. */
  3616. conjugateToRef(ref: Quaternion): Quaternion;
  3617. /**
  3618. * Conjugates in place (1-q) the current quaternion
  3619. * @returns the current updated quaternion
  3620. */
  3621. conjugateInPlace(): Quaternion;
  3622. /**
  3623. * Conjugates in place (1-q) the current quaternion
  3624. * @returns a new quaternion
  3625. */
  3626. conjugate(): Quaternion;
  3627. /**
  3628. * Gets length of current quaternion
  3629. * @returns the quaternion length (float)
  3630. */
  3631. length(): number;
  3632. /**
  3633. * Normalize in place the current quaternion
  3634. * @returns the current updated quaternion
  3635. */
  3636. normalize(): Quaternion;
  3637. /**
  3638. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns a new Vector3 containing the Euler angles
  3641. */
  3642. toEulerAngles(order?: string): Vector3;
  3643. /**
  3644. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3645. * @param result defines the vector which will be filled with the Euler angles
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toEulerAnglesToRef(result: Vector3): Quaternion;
  3650. /**
  3651. * Updates the given rotation matrix with the current quaternion values
  3652. * @param result defines the target matrix
  3653. * @returns the current unchanged quaternion
  3654. */
  3655. toRotationMatrix(result: Matrix): Quaternion;
  3656. /**
  3657. * Updates the current quaternion from the given rotation matrix values
  3658. * @param matrix defines the source matrix
  3659. * @returns the current updated quaternion
  3660. */
  3661. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Creates a new quaternion from a rotation matrix
  3664. * @param matrix defines the source matrix
  3665. * @returns a new quaternion created from the given rotation matrix values
  3666. */
  3667. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3668. /**
  3669. * Updates the given quaternion with the given rotation matrix values
  3670. * @param matrix defines the source matrix
  3671. * @param result defines the target quaternion
  3672. */
  3673. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3674. /**
  3675. * Returns the dot product (float) between the quaternions "left" and "right"
  3676. * @param left defines the left operand
  3677. * @param right defines the right operand
  3678. * @returns the dot product
  3679. */
  3680. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3681. /**
  3682. * Checks if the two quaternions are close to each other
  3683. * @param quat0 defines the first quaternion to check
  3684. * @param quat1 defines the second quaternion to check
  3685. * @returns true if the two quaternions are close to each other
  3686. */
  3687. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Creates an empty quaternion
  3690. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3691. */
  3692. static Zero(): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @returns a new quaternion as the inverted current quaternion
  3697. */
  3698. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Inverse a given quaternion
  3701. * @param q defines the source quaternion
  3702. * @param result the quaternion the result will be stored in
  3703. * @returns the result quaternion
  3704. */
  3705. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3706. /**
  3707. * Creates an identity quaternion
  3708. * @returns the identity quaternion
  3709. */
  3710. static Identity(): Quaternion;
  3711. /**
  3712. * Gets a boolean indicating if the given quaternion is identity
  3713. * @param quaternion defines the quaternion to check
  3714. * @returns true if the quaternion is identity
  3715. */
  3716. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3717. /**
  3718. * Creates a quaternion from a rotation around an axis
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3722. */
  3723. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3724. /**
  3725. * Creates a rotation around an axis and stores it into the given quaternion
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @param result defines the target quaternion
  3729. * @returns the target quaternion
  3730. */
  3731. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates a new quaternion from data stored into an array
  3734. * @param array defines the data source
  3735. * @param offset defines the offset in the source array where the data starts
  3736. * @returns a new quaternion
  3737. */
  3738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3739. /**
  3740. * Updates the given quaternion "result" from the starting index of the given array.
  3741. * @param array the array to pull values from
  3742. * @param offset the offset into the array to start at
  3743. * @param result the quaternion to store the result in
  3744. */
  3745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * 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)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * 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
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. 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;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. 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;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * 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"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * 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".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * 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.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4923. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @returns a string containing the hexadecimal representation of the Color4 object
  5780. */
  5781. toHexString(): string;
  5782. /**
  5783. * Computes a new Color4 converted from the current one to linear space
  5784. * @returns a new Color4 object
  5785. */
  5786. toLinearSpace(): Color4;
  5787. /**
  5788. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5789. * @param convertedColor defines the Color4 object where to store the linear space version
  5790. * @returns the unmodified Color4
  5791. */
  5792. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to gamma space
  5795. * @returns a new Color4 object
  5796. */
  5797. toGammaSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the gamma space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Creates a new Color4 from the string containing valid hexadecimal values
  5806. * @param hex defines a string containing valid hexadecimal values
  5807. * @returns a new Color4 object
  5808. */
  5809. static FromHexString(hex: string): Color4;
  5810. /**
  5811. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @returns a new Color4 object
  5816. */
  5817. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5818. /**
  5819. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @param result defines the Color4 object where to store data
  5824. */
  5825. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5826. /**
  5827. * Creates a new Color4 from a Color3 and an alpha value
  5828. * @param color3 defines the source Color3 to read from
  5829. * @param alpha defines the alpha component (1.0 by default)
  5830. * @returns a new Color4 object
  5831. */
  5832. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5833. /**
  5834. * Creates a new Color4 from the starting index element of the given array
  5835. * @param array defines the source array to read from
  5836. * @param offset defines the offset in the source array
  5837. * @returns a new Color4 object
  5838. */
  5839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5840. /**
  5841. * Creates a new Color3 from integer values (< 256)
  5842. * @param r defines the red component to read from (value between 0 and 255)
  5843. * @param g defines the green component to read from (value between 0 and 255)
  5844. * @param b defines the blue component to read from (value between 0 and 255)
  5845. * @param a defines the alpha component to read from (value between 0 and 255)
  5846. * @returns a new Color3 object
  5847. */
  5848. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5849. /**
  5850. * Check the content of a given array and convert it to an array containing RGBA data
  5851. * If the original array was already containing count * 4 values then it is returned directly
  5852. * @param colors defines the array to check
  5853. * @param count defines the number of RGBA data to expect
  5854. * @returns an array containing count * 4 values (RGBA)
  5855. */
  5856. static CheckColors4(colors: number[], count: number): number[];
  5857. }
  5858. /**
  5859. * @hidden
  5860. */
  5861. export class TmpColors {
  5862. static Color3: Color3[];
  5863. static Color4: Color4[];
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * Defines an interface which represents an animation key frame
  5869. */
  5870. export interface IAnimationKey {
  5871. /**
  5872. * Frame of the key frame
  5873. */
  5874. frame: number;
  5875. /**
  5876. * Value at the specifies key frame
  5877. */
  5878. value: any;
  5879. /**
  5880. * The input tangent for the cubic hermite spline
  5881. */
  5882. inTangent?: any;
  5883. /**
  5884. * The output tangent for the cubic hermite spline
  5885. */
  5886. outTangent?: any;
  5887. /**
  5888. * The animation interpolation type
  5889. */
  5890. interpolation?: AnimationKeyInterpolation;
  5891. }
  5892. /**
  5893. * Enum for the animation key frame interpolation type
  5894. */
  5895. export enum AnimationKeyInterpolation {
  5896. /**
  5897. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5898. */
  5899. STEP = 1
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * Represents the range of an animation
  5905. */
  5906. export class AnimationRange {
  5907. /**The name of the animation range**/
  5908. name: string;
  5909. /**The starting frame of the animation */
  5910. from: number;
  5911. /**The ending frame of the animation*/
  5912. to: number;
  5913. /**
  5914. * Initializes the range of an animation
  5915. * @param name The name of the animation range
  5916. * @param from The starting frame of the animation
  5917. * @param to The ending frame of the animation
  5918. */
  5919. constructor(
  5920. /**The name of the animation range**/
  5921. name: string,
  5922. /**The starting frame of the animation */
  5923. from: number,
  5924. /**The ending frame of the animation*/
  5925. to: number);
  5926. /**
  5927. * Makes a copy of the animation range
  5928. * @returns A copy of the animation range
  5929. */
  5930. clone(): AnimationRange;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Composed of a frame, and an action function
  5936. */
  5937. export class AnimationEvent {
  5938. /** The frame for which the event is triggered **/
  5939. frame: number;
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void;
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined;
  5944. /**
  5945. * Specifies if the animation event is done
  5946. */
  5947. isDone: boolean;
  5948. /**
  5949. * Initializes the animation event
  5950. * @param frame The frame for which the event is triggered
  5951. * @param action The event to perform when triggered
  5952. * @param onlyOnce Specifies if the event should be triggered only once
  5953. */
  5954. constructor(
  5955. /** The frame for which the event is triggered **/
  5956. frame: number,
  5957. /** The event to perform when triggered **/
  5958. action: (currentFrame: number) => void,
  5959. /** Specifies if the event should be triggered only once**/
  5960. onlyOnce?: boolean | undefined);
  5961. /** @hidden */
  5962. _clone(): AnimationEvent;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * Interface used to define a behavior
  5968. */
  5969. export interface Behavior<T> {
  5970. /** gets or sets behavior's name */
  5971. name: string;
  5972. /**
  5973. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5974. */
  5975. init(): void;
  5976. /**
  5977. * Called when the behavior is attached to a target
  5978. * @param target defines the target where the behavior is attached to
  5979. */
  5980. attach(target: T): void;
  5981. /**
  5982. * Called when the behavior is detached from its target
  5983. */
  5984. detach(): void;
  5985. }
  5986. /**
  5987. * Interface implemented by classes supporting behaviors
  5988. */
  5989. export interface IBehaviorAware<T> {
  5990. /**
  5991. * Attach a behavior
  5992. * @param behavior defines the behavior to attach
  5993. * @returns the current host
  5994. */
  5995. addBehavior(behavior: Behavior<T>): T;
  5996. /**
  5997. * Remove a behavior from the current object
  5998. * @param behavior defines the behavior to detach
  5999. * @returns the current host
  6000. */
  6001. removeBehavior(behavior: Behavior<T>): T;
  6002. /**
  6003. * Gets a behavior using its name to search
  6004. * @param name defines the name to search
  6005. * @returns the behavior or null if not found
  6006. */
  6007. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * Defines an array and its length.
  6013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6014. */
  6015. export interface ISmartArrayLike<T> {
  6016. /**
  6017. * The data of the array.
  6018. */
  6019. data: Array<T>;
  6020. /**
  6021. * The active length of the array.
  6022. */
  6023. length: number;
  6024. }
  6025. /**
  6026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6027. */
  6028. export class SmartArray<T> implements ISmartArrayLike<T> {
  6029. /**
  6030. * The full set of data from the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. protected _id: number;
  6038. /**
  6039. * Instantiates a Smart Array.
  6040. * @param capacity defines the default capacity of the array.
  6041. */
  6042. constructor(capacity: number);
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * @param value defines the object to push in the array.
  6046. */
  6047. push(value: T): void;
  6048. /**
  6049. * Iterates over the active data and apply the lambda to them.
  6050. * @param func defines the action to apply on each value.
  6051. */
  6052. forEach(func: (content: T) => void): void;
  6053. /**
  6054. * Sorts the full sets of data.
  6055. * @param compareFn defines the comparison function to apply.
  6056. */
  6057. sort(compareFn: (a: T, b: T) => number): void;
  6058. /**
  6059. * Resets the active data to an empty array.
  6060. */
  6061. reset(): void;
  6062. /**
  6063. * Releases all the data from the array as well as the array.
  6064. */
  6065. dispose(): void;
  6066. /**
  6067. * Concats the active data with a given array.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concat(array: any): void;
  6071. /**
  6072. * Returns the position of a value in the active data.
  6073. * @param value defines the value to find the index for
  6074. * @returns the index if found in the active data otherwise -1
  6075. */
  6076. indexOf(value: T): number;
  6077. /**
  6078. * Returns whether an element is part of the active data.
  6079. * @param value defines the value to look for
  6080. * @returns true if found in the active data otherwise false
  6081. */
  6082. contains(value: T): boolean;
  6083. private static _GlobalId;
  6084. }
  6085. /**
  6086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6087. * The data in this array can only be present once
  6088. */
  6089. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6090. private _duplicateId;
  6091. /**
  6092. * Pushes a value at the end of the active data.
  6093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Pushes a value at the end of the active data.
  6099. * If the data is already present, it won t be added again
  6100. * @param value defines the object to push in the array.
  6101. * @returns true if added false if it was already present
  6102. */
  6103. pushNoDuplicate(value: T): boolean;
  6104. /**
  6105. * Resets the active data to an empty array.
  6106. */
  6107. reset(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * This ensures no dupplicate will be present in the result.
  6111. * @param array defines the data to concatenate with.
  6112. */
  6113. concatWithNoDuplicate(array: any): void;
  6114. }
  6115. }
  6116. declare module BABYLON {
  6117. /**
  6118. * @ignore
  6119. * This is a list of all the different input types that are available in the application.
  6120. * Fo instance: ArcRotateCameraGamepadInput...
  6121. */
  6122. export var CameraInputTypes: {};
  6123. /**
  6124. * This is the contract to implement in order to create a new input class.
  6125. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6126. */
  6127. export interface ICameraInput<TCamera extends Camera> {
  6128. /**
  6129. * Defines the camera the input is attached to.
  6130. */
  6131. camera: Nullable<TCamera>;
  6132. /**
  6133. * Gets the class name of the current intput.
  6134. * @returns the class name
  6135. */
  6136. getClassName(): string;
  6137. /**
  6138. * Get the friendly name associated with the input class.
  6139. * @returns the input friendly name
  6140. */
  6141. getSimpleName(): string;
  6142. /**
  6143. * Attach the input controls to a specific dom element to get the input from.
  6144. * @param element Defines the element the controls should be listened from
  6145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6148. /**
  6149. * Detach the current controls from the specified dom element.
  6150. * @param element Defines the element to stop listening the inputs from
  6151. */
  6152. detachControl(element: Nullable<HTMLElement>): void;
  6153. /**
  6154. * Update the current camera state depending on the inputs that have been used this frame.
  6155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6156. */
  6157. checkInputs?: () => void;
  6158. }
  6159. /**
  6160. * Represents a map of input types to input instance or input index to input instance.
  6161. */
  6162. export interface CameraInputsMap<TCamera extends Camera> {
  6163. /**
  6164. * Accessor to the input by input type.
  6165. */
  6166. [name: string]: ICameraInput<TCamera>;
  6167. /**
  6168. * Accessor to the input by input index.
  6169. */
  6170. [idx: number]: ICameraInput<TCamera>;
  6171. }
  6172. /**
  6173. * This represents the input manager used within a camera.
  6174. * It helps dealing with all the different kind of input attached to a camera.
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. */
  6177. export class CameraInputsManager<TCamera extends Camera> {
  6178. /**
  6179. * Defines the list of inputs attahed to the camera.
  6180. */
  6181. attached: CameraInputsMap<TCamera>;
  6182. /**
  6183. * Defines the dom element the camera is collecting inputs from.
  6184. * This is null if the controls have not been attached.
  6185. */
  6186. attachedElement: Nullable<HTMLElement>;
  6187. /**
  6188. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6189. */
  6190. noPreventDefault: boolean;
  6191. /**
  6192. * Defined the camera the input manager belongs to.
  6193. */
  6194. camera: TCamera;
  6195. /**
  6196. * Update the current camera state depending on the inputs that have been used this frame.
  6197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6198. */
  6199. checkInputs: () => void;
  6200. /**
  6201. * Instantiate a new Camera Input Manager.
  6202. * @param camera Defines the camera the input manager blongs to
  6203. */
  6204. constructor(camera: TCamera);
  6205. /**
  6206. * Add an input method to a camera
  6207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6208. * @param input camera input method
  6209. */
  6210. add(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input method from a camera
  6213. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6214. * @param inputToRemove camera input method
  6215. */
  6216. remove(inputToRemove: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Remove a specific input type from a camera
  6219. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6220. * @param inputType the type of the input to remove
  6221. */
  6222. removeByType(inputType: string): void;
  6223. private _addCheckInputs;
  6224. /**
  6225. * Attach the input controls to the currently attached dom element to listen the events from.
  6226. * @param input Defines the input to attach
  6227. */
  6228. attachInput(input: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6235. /**
  6236. * Detach the current manager inputs controls from a specific dom element.
  6237. * @param element Defines the dom element to collect the events from
  6238. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6239. */
  6240. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6241. /**
  6242. * Rebuild the dynamic inputCheck function from the current list of
  6243. * defined inputs in the manager.
  6244. */
  6245. rebuildInputCheck(): void;
  6246. /**
  6247. * Remove all attached input methods from a camera
  6248. */
  6249. clear(): void;
  6250. /**
  6251. * Serialize the current input manager attached to a camera.
  6252. * This ensures than once parsed,
  6253. * the input associated to the camera will be identical to the current ones
  6254. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6255. */
  6256. serialize(serializedCamera: any): void;
  6257. /**
  6258. * Parses an input manager serialized JSON to restore the previous list of inputs
  6259. * and states associated to a camera.
  6260. * @param parsedCamera Defines the JSON to parse
  6261. */
  6262. parse(parsedCamera: any): void;
  6263. }
  6264. }
  6265. declare module BABYLON {
  6266. /**
  6267. * Class used to store data that will be store in GPU memory
  6268. */
  6269. export class Buffer {
  6270. private _engine;
  6271. private _buffer;
  6272. /** @hidden */
  6273. _data: Nullable<DataArray>;
  6274. private _updatable;
  6275. private _instanced;
  6276. private _divisor;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. * @param divisor sets an optional divisor for instances (1 by default)
  6291. */
  6292. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6293. /**
  6294. * Create a new VertexBuffer based on the current buffer
  6295. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6296. * @param offset defines offset in the buffer (0 by default)
  6297. * @param size defines the size in floats of attributes (position is 3 for instance)
  6298. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6299. * @param instanced defines if the vertex buffer contains indexed data
  6300. * @param useBytes defines if the offset and stride are in bytes *
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. * @returns the new vertex buffer
  6303. */
  6304. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6305. /**
  6306. * Gets a boolean indicating if the Buffer is updatable?
  6307. * @returns true if the buffer is updatable
  6308. */
  6309. isUpdatable(): boolean;
  6310. /**
  6311. * Gets current buffer's data
  6312. * @returns a DataArray or null
  6313. */
  6314. getData(): Nullable<DataArray>;
  6315. /**
  6316. * Gets underlying native buffer
  6317. * @returns underlying native buffer
  6318. */
  6319. getBuffer(): Nullable<DataBuffer>;
  6320. /**
  6321. * Gets the stride in float32 units (i.e. byte stride / 4).
  6322. * May not be an integer if the byte stride is not divisible by 4.
  6323. * @returns the stride in float32 units
  6324. * @deprecated Please use byteStride instead.
  6325. */
  6326. getStrideSize(): number;
  6327. /**
  6328. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6329. * @param data defines the data to store
  6330. */
  6331. create(data?: Nullable<DataArray>): void;
  6332. /** @hidden */
  6333. _rebuild(): void;
  6334. /**
  6335. * Update current buffer data
  6336. * @param data defines the data to store
  6337. */
  6338. update(data: DataArray): void;
  6339. /**
  6340. * Updates the data directly.
  6341. * @param data the new data
  6342. * @param offset the new offset
  6343. * @param vertexCount the vertex count (optional)
  6344. * @param useBytes set to true if the offset is in bytes
  6345. */
  6346. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6347. /**
  6348. * Release all resources
  6349. */
  6350. dispose(): void;
  6351. }
  6352. /**
  6353. * Specialized buffer used to store vertex data
  6354. */
  6355. export class VertexBuffer {
  6356. /** @hidden */
  6357. _buffer: Buffer;
  6358. private _kind;
  6359. private _size;
  6360. private _ownsBuffer;
  6361. private _instanced;
  6362. private _instanceDivisor;
  6363. /**
  6364. * The byte type.
  6365. */
  6366. static readonly BYTE: number;
  6367. /**
  6368. * The unsigned byte type.
  6369. */
  6370. static readonly UNSIGNED_BYTE: number;
  6371. /**
  6372. * The short type.
  6373. */
  6374. static readonly SHORT: number;
  6375. /**
  6376. * The unsigned short type.
  6377. */
  6378. static readonly UNSIGNED_SHORT: number;
  6379. /**
  6380. * The integer type.
  6381. */
  6382. static readonly INT: number;
  6383. /**
  6384. * The unsigned integer type.
  6385. */
  6386. static readonly UNSIGNED_INT: number;
  6387. /**
  6388. * The float type.
  6389. */
  6390. static readonly FLOAT: number;
  6391. /**
  6392. * Gets or sets the instance divisor when in instanced mode
  6393. */
  6394. get instanceDivisor(): number;
  6395. set instanceDivisor(value: number);
  6396. /**
  6397. * Gets the byte stride.
  6398. */
  6399. readonly byteStride: number;
  6400. /**
  6401. * Gets the byte offset.
  6402. */
  6403. readonly byteOffset: number;
  6404. /**
  6405. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6406. */
  6407. readonly normalized: boolean;
  6408. /**
  6409. * Gets the data type of each component in the array.
  6410. */
  6411. readonly type: number;
  6412. /**
  6413. * Constructor
  6414. * @param engine the engine
  6415. * @param data the data to use for this vertex buffer
  6416. * @param kind the vertex buffer kind
  6417. * @param updatable whether the data is updatable
  6418. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6419. * @param stride the stride (optional)
  6420. * @param instanced whether the buffer is instanced (optional)
  6421. * @param offset the offset of the data (optional)
  6422. * @param size the number of components (optional)
  6423. * @param type the type of the component (optional)
  6424. * @param normalized whether the data contains normalized data (optional)
  6425. * @param useBytes set to true if stride and offset are in bytes (optional)
  6426. * @param divisor defines the instance divisor to use (1 by default)
  6427. */
  6428. 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, divisor?: number);
  6429. /** @hidden */
  6430. _rebuild(): void;
  6431. /**
  6432. * Returns the kind of the VertexBuffer (string)
  6433. * @returns a string
  6434. */
  6435. getKind(): string;
  6436. /**
  6437. * Gets a boolean indicating if the VertexBuffer is updatable?
  6438. * @returns true if the buffer is updatable
  6439. */
  6440. isUpdatable(): boolean;
  6441. /**
  6442. * Gets current buffer's data
  6443. * @returns a DataArray or null
  6444. */
  6445. getData(): Nullable<DataArray>;
  6446. /**
  6447. * Gets underlying native buffer
  6448. * @returns underlying native buffer
  6449. */
  6450. getBuffer(): Nullable<DataBuffer>;
  6451. /**
  6452. * Gets the stride in float32 units (i.e. byte stride / 4).
  6453. * May not be an integer if the byte stride is not divisible by 4.
  6454. * @returns the stride in float32 units
  6455. * @deprecated Please use byteStride instead.
  6456. */
  6457. getStrideSize(): number;
  6458. /**
  6459. * Returns the offset as a multiple of the type byte length.
  6460. * @returns the offset in bytes
  6461. * @deprecated Please use byteOffset instead.
  6462. */
  6463. getOffset(): number;
  6464. /**
  6465. * Returns the number of components per vertex attribute (integer)
  6466. * @returns the size in float
  6467. */
  6468. getSize(): number;
  6469. /**
  6470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6471. * @returns true if this buffer is instanced
  6472. */
  6473. getIsInstanced(): boolean;
  6474. /**
  6475. * Returns the instancing divisor, zero for non-instanced (integer).
  6476. * @returns a number
  6477. */
  6478. getInstanceDivisor(): number;
  6479. /**
  6480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6481. * @param data defines the data to store
  6482. */
  6483. create(data?: DataArray): void;
  6484. /**
  6485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6486. * This function will create a new buffer if the current one is not updatable
  6487. * @param data defines the data to store
  6488. */
  6489. update(data: DataArray): void;
  6490. /**
  6491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6492. * Returns the directly updated WebGLBuffer.
  6493. * @param data the new data
  6494. * @param offset the new offset
  6495. * @param useBytes set to true if the offset is in bytes
  6496. */
  6497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6498. /**
  6499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Enumerates each value of this vertex buffer as numbers.
  6504. * @param count the number of values to enumerate
  6505. * @param callback the callback function called for each value
  6506. */
  6507. forEach(count: number, callback: (value: number, index: number) => void): void;
  6508. /**
  6509. * Positions
  6510. */
  6511. static readonly PositionKind: string;
  6512. /**
  6513. * Normals
  6514. */
  6515. static readonly NormalKind: string;
  6516. /**
  6517. * Tangents
  6518. */
  6519. static readonly TangentKind: string;
  6520. /**
  6521. * Texture coordinates
  6522. */
  6523. static readonly UVKind: string;
  6524. /**
  6525. * Texture coordinates 2
  6526. */
  6527. static readonly UV2Kind: string;
  6528. /**
  6529. * Texture coordinates 3
  6530. */
  6531. static readonly UV3Kind: string;
  6532. /**
  6533. * Texture coordinates 4
  6534. */
  6535. static readonly UV4Kind: string;
  6536. /**
  6537. * Texture coordinates 5
  6538. */
  6539. static readonly UV5Kind: string;
  6540. /**
  6541. * Texture coordinates 6
  6542. */
  6543. static readonly UV6Kind: string;
  6544. /**
  6545. * Colors
  6546. */
  6547. static readonly ColorKind: string;
  6548. /**
  6549. * Matrix indices (for bones)
  6550. */
  6551. static readonly MatricesIndicesKind: string;
  6552. /**
  6553. * Matrix weights (for bones)
  6554. */
  6555. static readonly MatricesWeightsKind: string;
  6556. /**
  6557. * Additional matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesExtraKind: string;
  6560. /**
  6561. * Additional matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsExtraKind: string;
  6564. /**
  6565. * Deduces the stride given a kind.
  6566. * @param kind The kind string to deduce
  6567. * @returns The deduced stride
  6568. */
  6569. static DeduceStride(kind: string): number;
  6570. /**
  6571. * Gets the byte length of the given type.
  6572. * @param type the type
  6573. * @returns the number of bytes
  6574. */
  6575. static GetTypeByteLength(type: number): number;
  6576. /**
  6577. * Enumerates each value of the given parameters as numbers.
  6578. * @param data the data to enumerate
  6579. * @param byteOffset the byte offset of the data
  6580. * @param byteStride the byte stride of the data
  6581. * @param componentCount the number of components per element
  6582. * @param componentType the type of the component
  6583. * @param count the number of values to enumerate
  6584. * @param normalized whether the data is normalized
  6585. * @param callback the callback function called for each value
  6586. */
  6587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6588. private static _GetFloatValue;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * @hidden
  6594. */
  6595. export class IntersectionInfo {
  6596. bu: Nullable<number>;
  6597. bv: Nullable<number>;
  6598. distance: number;
  6599. faceId: number;
  6600. subMeshId: number;
  6601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module BABYLON {
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module BABYLON {
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /** @hidden */
  6945. export class Collider {
  6946. /** Define if a collision was found */
  6947. collisionFound: boolean;
  6948. /**
  6949. * Define last intersection point in local space
  6950. */
  6951. intersectionPoint: Vector3;
  6952. /**
  6953. * Define last collided mesh
  6954. */
  6955. collidedMesh: Nullable<AbstractMesh>;
  6956. private _collisionPoint;
  6957. private _planeIntersectionPoint;
  6958. private _tempVector;
  6959. private _tempVector2;
  6960. private _tempVector3;
  6961. private _tempVector4;
  6962. private _edge;
  6963. private _baseToVertex;
  6964. private _destinationPoint;
  6965. private _slidePlaneNormal;
  6966. private _displacementVector;
  6967. /** @hidden */
  6968. _radius: Vector3;
  6969. /** @hidden */
  6970. _retry: number;
  6971. private _velocity;
  6972. private _basePoint;
  6973. private _epsilon;
  6974. /** @hidden */
  6975. _velocityWorldLength: number;
  6976. /** @hidden */
  6977. _basePointWorld: Vector3;
  6978. private _velocityWorld;
  6979. private _normalizedVelocity;
  6980. /** @hidden */
  6981. _initialVelocity: Vector3;
  6982. /** @hidden */
  6983. _initialPosition: Vector3;
  6984. private _nearestDistance;
  6985. private _collisionMask;
  6986. get collisionMask(): number;
  6987. set collisionMask(mask: number);
  6988. /**
  6989. * Gets the plane normal used to compute the sliding response (in local space)
  6990. */
  6991. get slidePlaneNormal(): Vector3;
  6992. /** @hidden */
  6993. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6994. /** @hidden */
  6995. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6996. /** @hidden */
  6997. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6998. /** @hidden */
  6999. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7000. /** @hidden */
  7001. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7002. /** @hidden */
  7003. _getResponse(pos: Vector3, vel: Vector3): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Interface for cullable objects
  7009. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7010. */
  7011. export interface ICullable {
  7012. /**
  7013. * Checks if the object or part of the object is in the frustum
  7014. * @param frustumPlanes Camera near/planes
  7015. * @returns true if the object is in frustum otherwise false
  7016. */
  7017. isInFrustum(frustumPlanes: Plane[]): boolean;
  7018. /**
  7019. * Checks if a cullable object (mesh...) is in the camera frustum
  7020. * Unlike isInFrustum this cheks the full bounding box
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7025. }
  7026. /**
  7027. * Info for a bounding data of a mesh
  7028. */
  7029. export class BoundingInfo implements ICullable {
  7030. /**
  7031. * Bounding box for the mesh
  7032. */
  7033. readonly boundingBox: BoundingBox;
  7034. /**
  7035. * Bounding sphere for the mesh
  7036. */
  7037. readonly boundingSphere: BoundingSphere;
  7038. private _isLocked;
  7039. private static readonly TmpVector3;
  7040. /**
  7041. * Constructs bounding info
  7042. * @param minimum min vector of the bounding box/sphere
  7043. * @param maximum max vector of the bounding box/sphere
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * min vector of the bounding box/sphere
  7056. */
  7057. get minimum(): Vector3;
  7058. /**
  7059. * max vector of the bounding box/sphere
  7060. */
  7061. get maximum(): Vector3;
  7062. /**
  7063. * If the info is locked and won't be updated to avoid perf overhead
  7064. */
  7065. get isLocked(): boolean;
  7066. set isLocked(value: boolean);
  7067. /**
  7068. * Updates the bounding sphere and box
  7069. * @param world world matrix to be used to update
  7070. */
  7071. update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7074. * @param center New center of the bounding info
  7075. * @param extend New extend of the bounding info
  7076. * @returns the current bounding info
  7077. */
  7078. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7079. /**
  7080. * Scale the current bounding info by applying a scale factor
  7081. * @param factor defines the scale factor to apply
  7082. * @returns the current bounding info
  7083. */
  7084. scale(factor: number): BoundingInfo;
  7085. /**
  7086. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7087. * @param frustumPlanes defines the frustum to test
  7088. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7089. * @returns true if the bounding info is in the frustum planes
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7092. /**
  7093. * Gets the world distance between the min and max points of the bounding box
  7094. */
  7095. get diagonalLength(): number;
  7096. /**
  7097. * Checks if a cullable object (mesh...) is in the camera frustum
  7098. * Unlike isInFrustum this cheks the full bounding box
  7099. * @param frustumPlanes Camera near/planes
  7100. * @returns true if the object is in frustum otherwise false
  7101. */
  7102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7103. /** @hidden */
  7104. _checkCollision(collider: Collider): boolean;
  7105. /**
  7106. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7107. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7108. * @param point the point to check intersection with
  7109. * @returns if the point intersects
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7114. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7115. * @param boundingInfo the bounding info to check intersection with
  7116. * @param precise if the intersection should be done using OBB
  7117. * @returns if the bounding info intersects
  7118. */
  7119. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Extracts minimum and maximum values from a list of indexed positions
  7125. * @param positions defines the positions to use
  7126. * @param indices defines the indices to the positions
  7127. * @param indexStart defines the start index
  7128. * @param indexCount defines the end index
  7129. * @param bias defines bias value to add to the result
  7130. * @return minimum and maximum values
  7131. */
  7132. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7133. minimum: Vector3;
  7134. maximum: Vector3;
  7135. };
  7136. /**
  7137. * Extracts minimum and maximum values from a list of positions
  7138. * @param positions defines the positions to use
  7139. * @param start defines the start index in the positions array
  7140. * @param count defines the number of positions to handle
  7141. * @param bias defines bias value to add to the result
  7142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7143. * @return minimum and maximum values
  7144. */
  7145. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7146. minimum: Vector3;
  7147. maximum: Vector3;
  7148. };
  7149. }
  7150. declare module BABYLON {
  7151. /** @hidden */
  7152. export class WebGLDataBuffer extends DataBuffer {
  7153. private _buffer;
  7154. constructor(resource: WebGLBuffer);
  7155. get underlyingResource(): any;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /** @hidden */
  7160. export class WebGLPipelineContext implements IPipelineContext {
  7161. engine: ThinEngine;
  7162. program: Nullable<WebGLProgram>;
  7163. context?: WebGLRenderingContext;
  7164. vertexShader?: WebGLShader;
  7165. fragmentShader?: WebGLShader;
  7166. isParallelCompiled: boolean;
  7167. onCompiled?: () => void;
  7168. transformFeedback?: WebGLTransformFeedback | null;
  7169. vertexCompilationError: Nullable<string>;
  7170. fragmentCompilationError: Nullable<string>;
  7171. programLinkError: Nullable<string>;
  7172. programValidationError: Nullable<string>;
  7173. get isAsync(): boolean;
  7174. get isReady(): boolean;
  7175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7176. _getVertexShaderCode(): string | null;
  7177. _getFragmentShaderCode(): string | null;
  7178. }
  7179. }
  7180. declare module BABYLON {
  7181. interface ThinEngine {
  7182. /**
  7183. * Create an uniform buffer
  7184. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7185. * @param elements defines the content of the uniform buffer
  7186. * @returns the webGL uniform buffer
  7187. */
  7188. createUniformBuffer(elements: FloatArray): DataBuffer;
  7189. /**
  7190. * Create a dynamic uniform buffer
  7191. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7192. * @param elements defines the content of the uniform buffer
  7193. * @returns the webGL uniform buffer
  7194. */
  7195. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7196. /**
  7197. * Update an existing uniform buffer
  7198. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7199. * @param uniformBuffer defines the target uniform buffer
  7200. * @param elements defines the content to update
  7201. * @param offset defines the offset in the uniform buffer where update should start
  7202. * @param count defines the size of the data to update
  7203. */
  7204. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7205. /**
  7206. * Bind an uniform buffer to the current webGL context
  7207. * @param buffer defines the buffer to bind
  7208. */
  7209. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7210. /**
  7211. * Bind a buffer to the current webGL context at a given location
  7212. * @param buffer defines the buffer to bind
  7213. * @param location defines the index where to bind the buffer
  7214. */
  7215. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7216. /**
  7217. * Bind a specific block at a given index in a specific shader program
  7218. * @param pipelineContext defines the pipeline context to use
  7219. * @param blockName defines the block name
  7220. * @param index defines the index where to bind the block
  7221. */
  7222. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7223. }
  7224. }
  7225. declare module BABYLON {
  7226. /**
  7227. * Uniform buffer objects.
  7228. *
  7229. * Handles blocks of uniform on the GPU.
  7230. *
  7231. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7232. *
  7233. * For more information, please refer to :
  7234. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7235. */
  7236. export class UniformBuffer {
  7237. private _engine;
  7238. private _buffer;
  7239. private _data;
  7240. private _bufferData;
  7241. private _dynamic?;
  7242. private _uniformLocations;
  7243. private _uniformSizes;
  7244. private _uniformLocationPointer;
  7245. private _needSync;
  7246. private _noUBO;
  7247. private _currentEffect;
  7248. /** @hidden */
  7249. _alreadyBound: boolean;
  7250. private static _MAX_UNIFORM_SIZE;
  7251. private static _tempBuffer;
  7252. /**
  7253. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7254. * This is dynamic to allow compat with webgl 1 and 2.
  7255. * You will need to pass the name of the uniform as well as the value.
  7256. */
  7257. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7258. /**
  7259. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7260. * This is dynamic to allow compat with webgl 1 and 2.
  7261. * You will need to pass the name of the uniform as well as the value.
  7262. */
  7263. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7264. /**
  7265. * Lambda to Update a single float in a uniform buffer.
  7266. * This is dynamic to allow compat with webgl 1 and 2.
  7267. * You will need to pass the name of the uniform as well as the value.
  7268. */
  7269. updateFloat: (name: string, x: number) => void;
  7270. /**
  7271. * Lambda to Update a vec2 of float in a uniform buffer.
  7272. * This is dynamic to allow compat with webgl 1 and 2.
  7273. * You will need to pass the name of the uniform as well as the value.
  7274. */
  7275. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7276. /**
  7277. * Lambda to Update a vec3 of float in a uniform buffer.
  7278. * This is dynamic to allow compat with webgl 1 and 2.
  7279. * You will need to pass the name of the uniform as well as the value.
  7280. */
  7281. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7282. /**
  7283. * Lambda to Update a vec4 of float in a uniform buffer.
  7284. * This is dynamic to allow compat with webgl 1 and 2.
  7285. * You will need to pass the name of the uniform as well as the value.
  7286. */
  7287. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7288. /**
  7289. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7290. * This is dynamic to allow compat with webgl 1 and 2.
  7291. * You will need to pass the name of the uniform as well as the value.
  7292. */
  7293. updateMatrix: (name: string, mat: Matrix) => void;
  7294. /**
  7295. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7296. * This is dynamic to allow compat with webgl 1 and 2.
  7297. * You will need to pass the name of the uniform as well as the value.
  7298. */
  7299. updateVector3: (name: string, vector: Vector3) => void;
  7300. /**
  7301. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7302. * This is dynamic to allow compat with webgl 1 and 2.
  7303. * You will need to pass the name of the uniform as well as the value.
  7304. */
  7305. updateVector4: (name: string, vector: Vector4) => void;
  7306. /**
  7307. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7308. * This is dynamic to allow compat with webgl 1 and 2.
  7309. * You will need to pass the name of the uniform as well as the value.
  7310. */
  7311. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7312. /**
  7313. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7314. * This is dynamic to allow compat with webgl 1 and 2.
  7315. * You will need to pass the name of the uniform as well as the value.
  7316. */
  7317. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7318. /**
  7319. * Instantiates a new Uniform buffer objects.
  7320. *
  7321. * Handles blocks of uniform on the GPU.
  7322. *
  7323. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7324. *
  7325. * For more information, please refer to :
  7326. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7327. * @param engine Define the engine the buffer is associated with
  7328. * @param data Define the data contained in the buffer
  7329. * @param dynamic Define if the buffer is updatable
  7330. */
  7331. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7332. /**
  7333. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7334. * or just falling back on setUniformXXX calls.
  7335. */
  7336. get useUbo(): boolean;
  7337. /**
  7338. * Indicates if the WebGL underlying uniform buffer is in sync
  7339. * with the javascript cache data.
  7340. */
  7341. get isSync(): boolean;
  7342. /**
  7343. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7344. * Also, a dynamic UniformBuffer will disable cache verification and always
  7345. * update the underlying WebGL uniform buffer to the GPU.
  7346. * @returns if Dynamic, otherwise false
  7347. */
  7348. isDynamic(): boolean;
  7349. /**
  7350. * The data cache on JS side.
  7351. * @returns the underlying data as a float array
  7352. */
  7353. getData(): Float32Array;
  7354. /**
  7355. * The underlying WebGL Uniform buffer.
  7356. * @returns the webgl buffer
  7357. */
  7358. getBuffer(): Nullable<DataBuffer>;
  7359. /**
  7360. * std140 layout specifies how to align data within an UBO structure.
  7361. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7362. * for specs.
  7363. */
  7364. private _fillAlignment;
  7365. /**
  7366. * Adds an uniform in the buffer.
  7367. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7368. * for the layout to be correct !
  7369. * @param name Name of the uniform, as used in the uniform block in the shader.
  7370. * @param size Data size, or data directly.
  7371. */
  7372. addUniform(name: string, size: number | number[]): void;
  7373. /**
  7374. * Adds a Matrix 4x4 to the uniform buffer.
  7375. * @param name Name of the uniform, as used in the uniform block in the shader.
  7376. * @param mat A 4x4 matrix.
  7377. */
  7378. addMatrix(name: string, mat: Matrix): void;
  7379. /**
  7380. * Adds a vec2 to the uniform buffer.
  7381. * @param name Name of the uniform, as used in the uniform block in the shader.
  7382. * @param x Define the x component value of the vec2
  7383. * @param y Define the y component value of the vec2
  7384. */
  7385. addFloat2(name: string, x: number, y: number): void;
  7386. /**
  7387. * Adds a vec3 to the uniform buffer.
  7388. * @param name Name of the uniform, as used in the uniform block in the shader.
  7389. * @param x Define the x component value of the vec3
  7390. * @param y Define the y component value of the vec3
  7391. * @param z Define the z component value of the vec3
  7392. */
  7393. addFloat3(name: string, x: number, y: number, z: number): void;
  7394. /**
  7395. * Adds a vec3 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param color Define the vec3 from a Color
  7398. */
  7399. addColor3(name: string, color: Color3): void;
  7400. /**
  7401. * Adds a vec4 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param color Define the rgb components from a Color
  7404. * @param alpha Define the a component of the vec4
  7405. */
  7406. addColor4(name: string, color: Color3, alpha: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param vector Define the vec3 components from a Vector
  7411. */
  7412. addVector3(name: string, vector: Vector3): void;
  7413. /**
  7414. * Adds a Matrix 3x3 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. */
  7417. addMatrix3x3(name: string): void;
  7418. /**
  7419. * Adds a Matrix 2x2 to the uniform buffer.
  7420. * @param name Name of the uniform, as used in the uniform block in the shader.
  7421. */
  7422. addMatrix2x2(name: string): void;
  7423. /**
  7424. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7425. */
  7426. create(): void;
  7427. /** @hidden */
  7428. _rebuild(): void;
  7429. /**
  7430. * Updates the WebGL Uniform Buffer on the GPU.
  7431. * If the `dynamic` flag is set to true, no cache comparison is done.
  7432. * Otherwise, the buffer will be updated only if the cache differs.
  7433. */
  7434. update(): void;
  7435. /**
  7436. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7437. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7438. * @param data Define the flattened data
  7439. * @param size Define the size of the data.
  7440. */
  7441. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7442. private _valueCache;
  7443. private _cacheMatrix;
  7444. private _updateMatrix3x3ForUniform;
  7445. private _updateMatrix3x3ForEffect;
  7446. private _updateMatrix2x2ForEffect;
  7447. private _updateMatrix2x2ForUniform;
  7448. private _updateFloatForEffect;
  7449. private _updateFloatForUniform;
  7450. private _updateFloat2ForEffect;
  7451. private _updateFloat2ForUniform;
  7452. private _updateFloat3ForEffect;
  7453. private _updateFloat3ForUniform;
  7454. private _updateFloat4ForEffect;
  7455. private _updateFloat4ForUniform;
  7456. private _updateMatrixForEffect;
  7457. private _updateMatrixForUniform;
  7458. private _updateVector3ForEffect;
  7459. private _updateVector3ForUniform;
  7460. private _updateVector4ForEffect;
  7461. private _updateVector4ForUniform;
  7462. private _updateColor3ForEffect;
  7463. private _updateColor3ForUniform;
  7464. private _updateColor4ForEffect;
  7465. private _updateColor4ForUniform;
  7466. /**
  7467. * Sets a sampler uniform on the effect.
  7468. * @param name Define the name of the sampler.
  7469. * @param texture Define the texture to set in the sampler
  7470. */
  7471. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7472. /**
  7473. * Directly updates the value of the uniform in the cache AND on the GPU.
  7474. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7475. * @param data Define the flattened data
  7476. */
  7477. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7478. /**
  7479. * Binds this uniform buffer to an effect.
  7480. * @param effect Define the effect to bind the buffer to
  7481. * @param name Name of the uniform block in the shader.
  7482. */
  7483. bindToEffect(effect: Effect, name: string): void;
  7484. /**
  7485. * Disposes the uniform buffer.
  7486. */
  7487. dispose(): void;
  7488. }
  7489. }
  7490. declare module BABYLON {
  7491. /**
  7492. * Enum that determines the text-wrapping mode to use.
  7493. */
  7494. export enum InspectableType {
  7495. /**
  7496. * Checkbox for booleans
  7497. */
  7498. Checkbox = 0,
  7499. /**
  7500. * Sliders for numbers
  7501. */
  7502. Slider = 1,
  7503. /**
  7504. * Vector3
  7505. */
  7506. Vector3 = 2,
  7507. /**
  7508. * Quaternions
  7509. */
  7510. Quaternion = 3,
  7511. /**
  7512. * Color3
  7513. */
  7514. Color3 = 4,
  7515. /**
  7516. * String
  7517. */
  7518. String = 5
  7519. }
  7520. /**
  7521. * Interface used to define custom inspectable properties.
  7522. * This interface is used by the inspector to display custom property grids
  7523. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7524. */
  7525. export interface IInspectable {
  7526. /**
  7527. * Gets the label to display
  7528. */
  7529. label: string;
  7530. /**
  7531. * Gets the name of the property to edit
  7532. */
  7533. propertyName: string;
  7534. /**
  7535. * Gets the type of the editor to use
  7536. */
  7537. type: InspectableType;
  7538. /**
  7539. * Gets the minimum value of the property when using in "slider" mode
  7540. */
  7541. min?: number;
  7542. /**
  7543. * Gets the maximum value of the property when using in "slider" mode
  7544. */
  7545. max?: number;
  7546. /**
  7547. * Gets the setp to use when using in "slider" mode
  7548. */
  7549. step?: number;
  7550. }
  7551. }
  7552. declare module BABYLON {
  7553. /**
  7554. * Class used to provide helper for timing
  7555. */
  7556. export class TimingTools {
  7557. /**
  7558. * Polyfill for setImmediate
  7559. * @param action defines the action to execute after the current execution block
  7560. */
  7561. static SetImmediate(action: () => void): void;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Class used to enable instatition of objects by class name
  7567. */
  7568. export class InstantiationTools {
  7569. /**
  7570. * Use this object to register external classes like custom textures or material
  7571. * to allow the laoders to instantiate them
  7572. */
  7573. static RegisteredExternalClasses: {
  7574. [key: string]: Object;
  7575. };
  7576. /**
  7577. * Tries to instantiate a new object from a given class name
  7578. * @param className defines the class name to instantiate
  7579. * @returns the new object or null if the system was not able to do the instantiation
  7580. */
  7581. static Instantiate(className: string): any;
  7582. }
  7583. }
  7584. declare module BABYLON {
  7585. /**
  7586. * Define options used to create a depth texture
  7587. */
  7588. export class DepthTextureCreationOptions {
  7589. /** Specifies whether or not a stencil should be allocated in the texture */
  7590. generateStencil?: boolean;
  7591. /** Specifies whether or not bilinear filtering is enable on the texture */
  7592. bilinearFiltering?: boolean;
  7593. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7594. comparisonFunction?: number;
  7595. /** Specifies if the created texture is a cube texture */
  7596. isCube?: boolean;
  7597. }
  7598. }
  7599. declare module BABYLON {
  7600. interface ThinEngine {
  7601. /**
  7602. * Creates a depth stencil cube texture.
  7603. * This is only available in WebGL 2.
  7604. * @param size The size of face edge in the cube texture.
  7605. * @param options The options defining the cube texture.
  7606. * @returns The cube texture
  7607. */
  7608. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7609. /**
  7610. * Creates a cube texture
  7611. * @param rootUrl defines the url where the files to load is located
  7612. * @param scene defines the current scene
  7613. * @param files defines the list of files to load (1 per face)
  7614. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7615. * @param onLoad defines an optional callback raised when the texture is loaded
  7616. * @param onError defines an optional callback raised if there is an issue to load the texture
  7617. * @param format defines the format of the data
  7618. * @param forcedExtension defines the extension to use to pick the right loader
  7619. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7620. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7621. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7622. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7623. * @returns the cube texture as an InternalTexture
  7624. */
  7625. 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>): InternalTexture;
  7626. /**
  7627. * Creates a cube texture
  7628. * @param rootUrl defines the url where the files to load is located
  7629. * @param scene defines the current scene
  7630. * @param files defines the list of files to load (1 per face)
  7631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7632. * @param onLoad defines an optional callback raised when the texture is loaded
  7633. * @param onError defines an optional callback raised if there is an issue to load the texture
  7634. * @param format defines the format of the data
  7635. * @param forcedExtension defines the extension to use to pick the right loader
  7636. * @returns the cube texture as an InternalTexture
  7637. */
  7638. 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;
  7639. /**
  7640. * Creates a cube texture
  7641. * @param rootUrl defines the url where the files to load is located
  7642. * @param scene defines the current scene
  7643. * @param files defines the list of files to load (1 per face)
  7644. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7645. * @param onLoad defines an optional callback raised when the texture is loaded
  7646. * @param onError defines an optional callback raised if there is an issue to load the texture
  7647. * @param format defines the format of the data
  7648. * @param forcedExtension defines the extension to use to pick the right loader
  7649. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7650. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7651. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7652. * @returns the cube texture as an InternalTexture
  7653. */
  7654. 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;
  7655. /** @hidden */
  7656. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7657. /** @hidden */
  7658. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7659. /** @hidden */
  7660. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7661. /** @hidden */
  7662. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7663. /**
  7664. * @hidden
  7665. */
  7666. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7667. }
  7668. }
  7669. declare module BABYLON {
  7670. /**
  7671. * Class for creating a cube texture
  7672. */
  7673. export class CubeTexture extends BaseTexture {
  7674. private _delayedOnLoad;
  7675. /**
  7676. * Observable triggered once the texture has been loaded.
  7677. */
  7678. onLoadObservable: Observable<CubeTexture>;
  7679. /**
  7680. * The url of the texture
  7681. */
  7682. url: string;
  7683. /**
  7684. * Gets or sets the center of the bounding box associated with the cube texture.
  7685. * It must define where the camera used to render the texture was set
  7686. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7687. */
  7688. boundingBoxPosition: Vector3;
  7689. private _boundingBoxSize;
  7690. /**
  7691. * Gets or sets the size of the bounding box associated with the cube texture
  7692. * When defined, the cubemap will switch to local mode
  7693. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7694. * @example https://www.babylonjs-playground.com/#RNASML
  7695. */
  7696. set boundingBoxSize(value: Vector3);
  7697. /**
  7698. * Returns the bounding box size
  7699. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7700. */
  7701. get boundingBoxSize(): Vector3;
  7702. protected _rotationY: number;
  7703. /**
  7704. * Sets texture matrix rotation angle around Y axis in radians.
  7705. */
  7706. set rotationY(value: number);
  7707. /**
  7708. * Gets texture matrix rotation angle around Y axis radians.
  7709. */
  7710. get rotationY(): number;
  7711. /**
  7712. * Are mip maps generated for this texture or not.
  7713. */
  7714. get noMipmap(): boolean;
  7715. private _noMipmap;
  7716. private _files;
  7717. protected _forcedExtension: Nullable<string>;
  7718. private _extensions;
  7719. private _textureMatrix;
  7720. private _format;
  7721. private _createPolynomials;
  7722. /** @hidden */
  7723. _prefiltered: boolean;
  7724. /**
  7725. * Creates a cube texture from an array of image urls
  7726. * @param files defines an array of image urls
  7727. * @param scene defines the hosting scene
  7728. * @param noMipmap specifies if mip maps are not used
  7729. * @returns a cube texture
  7730. */
  7731. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7732. /**
  7733. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7734. * @param url defines the url of the prefiltered texture
  7735. * @param scene defines the scene the texture is attached to
  7736. * @param forcedExtension defines the extension of the file if different from the url
  7737. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7738. * @return the prefiltered texture
  7739. */
  7740. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7741. /**
  7742. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7743. * as prefiltered data.
  7744. * @param rootUrl defines the url of the texture or the root name of the six images
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7747. * @param noMipmap defines if mipmaps should be created or not
  7748. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7749. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7750. * @param onError defines a callback triggered in case of error during load
  7751. * @param format defines the internal format to use for the texture once loaded
  7752. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7753. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7754. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7755. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7756. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7757. * @return the cube texture
  7758. */
  7759. 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);
  7760. /**
  7761. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7762. */
  7763. get isPrefiltered(): boolean;
  7764. /**
  7765. * Get the current class name of the texture useful for serialization or dynamic coding.
  7766. * @returns "CubeTexture"
  7767. */
  7768. getClassName(): string;
  7769. /**
  7770. * Update the url (and optional buffer) of this texture if url was null during construction.
  7771. * @param url the url of the texture
  7772. * @param forcedExtension defines the extension to use
  7773. * @param onLoad callback called when the texture is loaded (defaults to null)
  7774. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7775. */
  7776. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7777. /**
  7778. * Delays loading of the cube texture
  7779. * @param forcedExtension defines the extension to use
  7780. */
  7781. delayLoad(forcedExtension?: string): void;
  7782. /**
  7783. * Returns the reflection texture matrix
  7784. * @returns the reflection texture matrix
  7785. */
  7786. getReflectionTextureMatrix(): Matrix;
  7787. /**
  7788. * Sets the reflection texture matrix
  7789. * @param value Reflection texture matrix
  7790. */
  7791. setReflectionTextureMatrix(value: Matrix): void;
  7792. /**
  7793. * Parses text to create a cube texture
  7794. * @param parsedTexture define the serialized text to read from
  7795. * @param scene defines the hosting scene
  7796. * @param rootUrl defines the root url of the cube texture
  7797. * @returns a cube texture
  7798. */
  7799. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7800. /**
  7801. * Makes a clone, or deep copy, of the cube texture
  7802. * @returns a new cube texture
  7803. */
  7804. clone(): CubeTexture;
  7805. }
  7806. }
  7807. declare module BABYLON {
  7808. /**
  7809. * Manages the defines for the Material
  7810. */
  7811. export class MaterialDefines {
  7812. /** @hidden */
  7813. protected _keys: string[];
  7814. private _isDirty;
  7815. /** @hidden */
  7816. _renderId: number;
  7817. /** @hidden */
  7818. _areLightsDirty: boolean;
  7819. /** @hidden */
  7820. _areLightsDisposed: boolean;
  7821. /** @hidden */
  7822. _areAttributesDirty: boolean;
  7823. /** @hidden */
  7824. _areTexturesDirty: boolean;
  7825. /** @hidden */
  7826. _areFresnelDirty: boolean;
  7827. /** @hidden */
  7828. _areMiscDirty: boolean;
  7829. /** @hidden */
  7830. _areImageProcessingDirty: boolean;
  7831. /** @hidden */
  7832. _normals: boolean;
  7833. /** @hidden */
  7834. _uvs: boolean;
  7835. /** @hidden */
  7836. _needNormals: boolean;
  7837. /** @hidden */
  7838. _needUVs: boolean;
  7839. [id: string]: any;
  7840. /**
  7841. * Specifies if the material needs to be re-calculated
  7842. */
  7843. get isDirty(): boolean;
  7844. /**
  7845. * Marks the material to indicate that it has been re-calculated
  7846. */
  7847. markAsProcessed(): void;
  7848. /**
  7849. * Marks the material to indicate that it needs to be re-calculated
  7850. */
  7851. markAsUnprocessed(): void;
  7852. /**
  7853. * Marks the material to indicate all of its defines need to be re-calculated
  7854. */
  7855. markAllAsDirty(): void;
  7856. /**
  7857. * Marks the material to indicate that image processing needs to be re-calculated
  7858. */
  7859. markAsImageProcessingDirty(): void;
  7860. /**
  7861. * Marks the material to indicate the lights need to be re-calculated
  7862. * @param disposed Defines whether the light is dirty due to dispose or not
  7863. */
  7864. markAsLightDirty(disposed?: boolean): void;
  7865. /**
  7866. * Marks the attribute state as changed
  7867. */
  7868. markAsAttributesDirty(): void;
  7869. /**
  7870. * Marks the texture state as changed
  7871. */
  7872. markAsTexturesDirty(): void;
  7873. /**
  7874. * Marks the fresnel state as changed
  7875. */
  7876. markAsFresnelDirty(): void;
  7877. /**
  7878. * Marks the misc state as changed
  7879. */
  7880. markAsMiscDirty(): void;
  7881. /**
  7882. * Rebuilds the material defines
  7883. */
  7884. rebuild(): void;
  7885. /**
  7886. * Specifies if two material defines are equal
  7887. * @param other - A material define instance to compare to
  7888. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7889. */
  7890. isEqual(other: MaterialDefines): boolean;
  7891. /**
  7892. * Clones this instance's defines to another instance
  7893. * @param other - material defines to clone values to
  7894. */
  7895. cloneTo(other: MaterialDefines): void;
  7896. /**
  7897. * Resets the material define values
  7898. */
  7899. reset(): void;
  7900. /**
  7901. * Converts the material define values to a string
  7902. * @returns - String of material define information
  7903. */
  7904. toString(): string;
  7905. }
  7906. }
  7907. declare module BABYLON {
  7908. /**
  7909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7911. * 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;
  7912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7913. */
  7914. export class ColorCurves {
  7915. private _dirty;
  7916. private _tempColor;
  7917. private _globalCurve;
  7918. private _highlightsCurve;
  7919. private _midtonesCurve;
  7920. private _shadowsCurve;
  7921. private _positiveCurve;
  7922. private _negativeCurve;
  7923. private _globalHue;
  7924. private _globalDensity;
  7925. private _globalSaturation;
  7926. private _globalExposure;
  7927. /**
  7928. * Gets the global Hue value.
  7929. * 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).
  7930. */
  7931. get globalHue(): number;
  7932. /**
  7933. * Sets the global Hue value.
  7934. * 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).
  7935. */
  7936. set globalHue(value: number);
  7937. /**
  7938. * Gets the global Density value.
  7939. * 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.
  7940. * Values less than zero provide a filter of opposite hue.
  7941. */
  7942. get globalDensity(): number;
  7943. /**
  7944. * Sets the global Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. set globalDensity(value: number);
  7949. /**
  7950. * Gets the global Saturation value.
  7951. * 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.
  7952. */
  7953. get globalSaturation(): number;
  7954. /**
  7955. * Sets the global Saturation value.
  7956. * 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.
  7957. */
  7958. set globalSaturation(value: number);
  7959. /**
  7960. * Gets the global Exposure value.
  7961. * 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.
  7962. */
  7963. get globalExposure(): number;
  7964. /**
  7965. * Sets the global Exposure value.
  7966. * 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.
  7967. */
  7968. set globalExposure(value: number);
  7969. private _highlightsHue;
  7970. private _highlightsDensity;
  7971. private _highlightsSaturation;
  7972. private _highlightsExposure;
  7973. /**
  7974. * Gets the highlights Hue value.
  7975. * 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).
  7976. */
  7977. get highlightsHue(): number;
  7978. /**
  7979. * Sets the highlights Hue value.
  7980. * 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).
  7981. */
  7982. set highlightsHue(value: number);
  7983. /**
  7984. * Gets the highlights Density value.
  7985. * 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.
  7986. * Values less than zero provide a filter of opposite hue.
  7987. */
  7988. get highlightsDensity(): number;
  7989. /**
  7990. * Sets the highlights Density value.
  7991. * 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.
  7992. * Values less than zero provide a filter of opposite hue.
  7993. */
  7994. set highlightsDensity(value: number);
  7995. /**
  7996. * Gets the highlights Saturation value.
  7997. * 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.
  7998. */
  7999. get highlightsSaturation(): number;
  8000. /**
  8001. * Sets the highlights Saturation value.
  8002. * 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.
  8003. */
  8004. set highlightsSaturation(value: number);
  8005. /**
  8006. * Gets the highlights Exposure value.
  8007. * 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.
  8008. */
  8009. get highlightsExposure(): number;
  8010. /**
  8011. * Sets the highlights Exposure value.
  8012. * 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.
  8013. */
  8014. set highlightsExposure(value: number);
  8015. private _midtonesHue;
  8016. private _midtonesDensity;
  8017. private _midtonesSaturation;
  8018. private _midtonesExposure;
  8019. /**
  8020. * Gets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. get midtonesHue(): number;
  8024. /**
  8025. * Sets the midtones Hue value.
  8026. * 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).
  8027. */
  8028. set midtonesHue(value: number);
  8029. /**
  8030. * Gets the midtones Density value.
  8031. * 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.
  8032. * Values less than zero provide a filter of opposite hue.
  8033. */
  8034. get midtonesDensity(): number;
  8035. /**
  8036. * Sets the midtones Density value.
  8037. * 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.
  8038. * Values less than zero provide a filter of opposite hue.
  8039. */
  8040. set midtonesDensity(value: number);
  8041. /**
  8042. * Gets the midtones Saturation value.
  8043. * 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.
  8044. */
  8045. get midtonesSaturation(): number;
  8046. /**
  8047. * Sets the midtones Saturation value.
  8048. * 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.
  8049. */
  8050. set midtonesSaturation(value: number);
  8051. /**
  8052. * Gets the midtones Exposure value.
  8053. * 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.
  8054. */
  8055. get midtonesExposure(): number;
  8056. /**
  8057. * Sets the midtones Exposure value.
  8058. * 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.
  8059. */
  8060. set midtonesExposure(value: number);
  8061. private _shadowsHue;
  8062. private _shadowsDensity;
  8063. private _shadowsSaturation;
  8064. private _shadowsExposure;
  8065. /**
  8066. * Gets the shadows Hue value.
  8067. * 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).
  8068. */
  8069. get shadowsHue(): number;
  8070. /**
  8071. * Sets the shadows Hue value.
  8072. * 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).
  8073. */
  8074. set shadowsHue(value: number);
  8075. /**
  8076. * Gets the shadows Density value.
  8077. * 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.
  8078. * Values less than zero provide a filter of opposite hue.
  8079. */
  8080. get shadowsDensity(): number;
  8081. /**
  8082. * Sets the shadows Density value.
  8083. * 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.
  8084. * Values less than zero provide a filter of opposite hue.
  8085. */
  8086. set shadowsDensity(value: number);
  8087. /**
  8088. * Gets the shadows Saturation value.
  8089. * 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.
  8090. */
  8091. get shadowsSaturation(): number;
  8092. /**
  8093. * Sets the shadows Saturation value.
  8094. * 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.
  8095. */
  8096. set shadowsSaturation(value: number);
  8097. /**
  8098. * Gets the shadows Exposure value.
  8099. * 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.
  8100. */
  8101. get shadowsExposure(): number;
  8102. /**
  8103. * Sets the shadows Exposure value.
  8104. * 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.
  8105. */
  8106. set shadowsExposure(value: number);
  8107. /**
  8108. * Returns the class name
  8109. * @returns The class name
  8110. */
  8111. getClassName(): string;
  8112. /**
  8113. * Binds the color curves to the shader.
  8114. * @param colorCurves The color curve to bind
  8115. * @param effect The effect to bind to
  8116. * @param positiveUniform The positive uniform shader parameter
  8117. * @param neutralUniform The neutral uniform shader parameter
  8118. * @param negativeUniform The negative uniform shader parameter
  8119. */
  8120. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8121. /**
  8122. * Prepare the list of uniforms associated with the ColorCurves effects.
  8123. * @param uniformsList The list of uniforms used in the effect
  8124. */
  8125. static PrepareUniforms(uniformsList: string[]): void;
  8126. /**
  8127. * Returns color grading data based on a hue, density, saturation and exposure value.
  8128. * @param filterHue The hue of the color filter.
  8129. * @param filterDensity The density of the color filter.
  8130. * @param saturation The saturation.
  8131. * @param exposure The exposure.
  8132. * @param result The result data container.
  8133. */
  8134. private getColorGradingDataToRef;
  8135. /**
  8136. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8137. * @param value The input slider value in range [-100,100].
  8138. * @returns Adjusted value.
  8139. */
  8140. private static applyColorGradingSliderNonlinear;
  8141. /**
  8142. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8143. * @param hue The hue (H) input.
  8144. * @param saturation The saturation (S) input.
  8145. * @param brightness The brightness (B) input.
  8146. * @result An RGBA color represented as Vector4.
  8147. */
  8148. private static fromHSBToRef;
  8149. /**
  8150. * Returns a value clamped between min and max
  8151. * @param value The value to clamp
  8152. * @param min The minimum of value
  8153. * @param max The maximum of value
  8154. * @returns The clamped value.
  8155. */
  8156. private static clamp;
  8157. /**
  8158. * Clones the current color curve instance.
  8159. * @return The cloned curves
  8160. */
  8161. clone(): ColorCurves;
  8162. /**
  8163. * Serializes the current color curve instance to a json representation.
  8164. * @return a JSON representation
  8165. */
  8166. serialize(): any;
  8167. /**
  8168. * Parses the color curve from a json representation.
  8169. * @param source the JSON source to parse
  8170. * @return The parsed curves
  8171. */
  8172. static Parse(source: any): ColorCurves;
  8173. }
  8174. }
  8175. declare module BABYLON {
  8176. /**
  8177. * Interface to follow in your material defines to integrate easily the
  8178. * Image proccessing functions.
  8179. * @hidden
  8180. */
  8181. export interface IImageProcessingConfigurationDefines {
  8182. IMAGEPROCESSING: boolean;
  8183. VIGNETTE: boolean;
  8184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8185. VIGNETTEBLENDMODEOPAQUE: boolean;
  8186. TONEMAPPING: boolean;
  8187. TONEMAPPING_ACES: boolean;
  8188. CONTRAST: boolean;
  8189. EXPOSURE: boolean;
  8190. COLORCURVES: boolean;
  8191. COLORGRADING: boolean;
  8192. COLORGRADING3D: boolean;
  8193. SAMPLER3DGREENDEPTH: boolean;
  8194. SAMPLER3DBGRMAP: boolean;
  8195. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8196. }
  8197. /**
  8198. * @hidden
  8199. */
  8200. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. COLORCURVES: boolean;
  8209. COLORGRADING: boolean;
  8210. COLORGRADING3D: boolean;
  8211. SAMPLER3DGREENDEPTH: boolean;
  8212. SAMPLER3DBGRMAP: boolean;
  8213. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8214. EXPOSURE: boolean;
  8215. constructor();
  8216. }
  8217. /**
  8218. * This groups together the common properties used for image processing either in direct forward pass
  8219. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8220. * or not.
  8221. */
  8222. export class ImageProcessingConfiguration {
  8223. /**
  8224. * Default tone mapping applied in BabylonJS.
  8225. */
  8226. static readonly TONEMAPPING_STANDARD: number;
  8227. /**
  8228. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8229. * to other engines rendering to increase portability.
  8230. */
  8231. static readonly TONEMAPPING_ACES: number;
  8232. /**
  8233. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8234. */
  8235. colorCurves: Nullable<ColorCurves>;
  8236. private _colorCurvesEnabled;
  8237. /**
  8238. * Gets wether the color curves effect is enabled.
  8239. */
  8240. get colorCurvesEnabled(): boolean;
  8241. /**
  8242. * Sets wether the color curves effect is enabled.
  8243. */
  8244. set colorCurvesEnabled(value: boolean);
  8245. private _colorGradingTexture;
  8246. /**
  8247. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8248. */
  8249. get colorGradingTexture(): Nullable<BaseTexture>;
  8250. /**
  8251. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8252. */
  8253. set colorGradingTexture(value: Nullable<BaseTexture>);
  8254. private _colorGradingEnabled;
  8255. /**
  8256. * Gets wether the color grading effect is enabled.
  8257. */
  8258. get colorGradingEnabled(): boolean;
  8259. /**
  8260. * Sets wether the color grading effect is enabled.
  8261. */
  8262. set colorGradingEnabled(value: boolean);
  8263. private _colorGradingWithGreenDepth;
  8264. /**
  8265. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8266. */
  8267. get colorGradingWithGreenDepth(): boolean;
  8268. /**
  8269. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8270. */
  8271. set colorGradingWithGreenDepth(value: boolean);
  8272. private _colorGradingBGR;
  8273. /**
  8274. * Gets wether the color grading texture contains BGR values.
  8275. */
  8276. get colorGradingBGR(): boolean;
  8277. /**
  8278. * Sets wether the color grading texture contains BGR values.
  8279. */
  8280. set colorGradingBGR(value: boolean);
  8281. /** @hidden */
  8282. _exposure: number;
  8283. /**
  8284. * Gets the Exposure used in the effect.
  8285. */
  8286. get exposure(): number;
  8287. /**
  8288. * Sets the Exposure used in the effect.
  8289. */
  8290. set exposure(value: number);
  8291. private _toneMappingEnabled;
  8292. /**
  8293. * Gets wether the tone mapping effect is enabled.
  8294. */
  8295. get toneMappingEnabled(): boolean;
  8296. /**
  8297. * Sets wether the tone mapping effect is enabled.
  8298. */
  8299. set toneMappingEnabled(value: boolean);
  8300. private _toneMappingType;
  8301. /**
  8302. * Gets the type of tone mapping effect.
  8303. */
  8304. get toneMappingType(): number;
  8305. /**
  8306. * Sets the type of tone mapping effect used in BabylonJS.
  8307. */
  8308. set toneMappingType(value: number);
  8309. protected _contrast: number;
  8310. /**
  8311. * Gets the contrast used in the effect.
  8312. */
  8313. get contrast(): number;
  8314. /**
  8315. * Sets the contrast used in the effect.
  8316. */
  8317. set contrast(value: number);
  8318. /**
  8319. * Vignette stretch size.
  8320. */
  8321. vignetteStretch: number;
  8322. /**
  8323. * Vignette centre X Offset.
  8324. */
  8325. vignetteCentreX: number;
  8326. /**
  8327. * Vignette centre Y Offset.
  8328. */
  8329. vignetteCentreY: number;
  8330. /**
  8331. * Vignette weight or intensity of the vignette effect.
  8332. */
  8333. vignetteWeight: number;
  8334. /**
  8335. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8336. * if vignetteEnabled is set to true.
  8337. */
  8338. vignetteColor: Color4;
  8339. /**
  8340. * Camera field of view used by the Vignette effect.
  8341. */
  8342. vignetteCameraFov: number;
  8343. private _vignetteBlendMode;
  8344. /**
  8345. * Gets the vignette blend mode allowing different kind of effect.
  8346. */
  8347. get vignetteBlendMode(): number;
  8348. /**
  8349. * Sets the vignette blend mode allowing different kind of effect.
  8350. */
  8351. set vignetteBlendMode(value: number);
  8352. private _vignetteEnabled;
  8353. /**
  8354. * Gets wether the vignette effect is enabled.
  8355. */
  8356. get vignetteEnabled(): boolean;
  8357. /**
  8358. * Sets wether the vignette effect is enabled.
  8359. */
  8360. set vignetteEnabled(value: boolean);
  8361. private _applyByPostProcess;
  8362. /**
  8363. * Gets wether the image processing is applied through a post process or not.
  8364. */
  8365. get applyByPostProcess(): boolean;
  8366. /**
  8367. * Sets wether the image processing is applied through a post process or not.
  8368. */
  8369. set applyByPostProcess(value: boolean);
  8370. private _isEnabled;
  8371. /**
  8372. * Gets wether the image processing is enabled or not.
  8373. */
  8374. get isEnabled(): boolean;
  8375. /**
  8376. * Sets wether the image processing is enabled or not.
  8377. */
  8378. set isEnabled(value: boolean);
  8379. /**
  8380. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8381. */
  8382. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8383. /**
  8384. * Method called each time the image processing information changes requires to recompile the effect.
  8385. */
  8386. protected _updateParameters(): void;
  8387. /**
  8388. * Gets the current class name.
  8389. * @return "ImageProcessingConfiguration"
  8390. */
  8391. getClassName(): string;
  8392. /**
  8393. * Prepare the list of uniforms associated with the Image Processing effects.
  8394. * @param uniforms The list of uniforms used in the effect
  8395. * @param defines the list of defines currently in use
  8396. */
  8397. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8398. /**
  8399. * Prepare the list of samplers associated with the Image Processing effects.
  8400. * @param samplersList The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of defines associated to the shader.
  8406. * @param defines the list of defines to complete
  8407. * @param forPostProcess Define if we are currently in post process mode or not
  8408. */
  8409. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8410. /**
  8411. * Returns true if all the image processing information are ready.
  8412. * @returns True if ready, otherwise, false
  8413. */
  8414. isReady(): boolean;
  8415. /**
  8416. * Binds the image processing to the shader.
  8417. * @param effect The effect to bind to
  8418. * @param overrideAspectRatio Override the aspect ratio of the effect
  8419. */
  8420. bind(effect: Effect, overrideAspectRatio?: number): void;
  8421. /**
  8422. * Clones the current image processing instance.
  8423. * @return The cloned image processing
  8424. */
  8425. clone(): ImageProcessingConfiguration;
  8426. /**
  8427. * Serializes the current image processing instance to a json representation.
  8428. * @return a JSON representation
  8429. */
  8430. serialize(): any;
  8431. /**
  8432. * Parses the image processing from a json representation.
  8433. * @param source the JSON source to parse
  8434. * @return The parsed image processing
  8435. */
  8436. static Parse(source: any): ImageProcessingConfiguration;
  8437. private static _VIGNETTEMODE_MULTIPLY;
  8438. private static _VIGNETTEMODE_OPAQUE;
  8439. /**
  8440. * Used to apply the vignette as a mix with the pixel color.
  8441. */
  8442. static get VIGNETTEMODE_MULTIPLY(): number;
  8443. /**
  8444. * Used to apply the vignette as a replacement of the pixel color.
  8445. */
  8446. static get VIGNETTEMODE_OPAQUE(): number;
  8447. }
  8448. }
  8449. declare module BABYLON {
  8450. /** @hidden */
  8451. export var postprocessVertexShader: {
  8452. name: string;
  8453. shader: string;
  8454. };
  8455. }
  8456. declare module BABYLON {
  8457. interface ThinEngine {
  8458. /**
  8459. * Creates a new render target texture
  8460. * @param size defines the size of the texture
  8461. * @param options defines the options used to create the texture
  8462. * @returns a new render target texture stored in an InternalTexture
  8463. */
  8464. createRenderTargetTexture(size: number | {
  8465. width: number;
  8466. height: number;
  8467. layers?: number;
  8468. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8469. /**
  8470. * Creates a depth stencil texture.
  8471. * This is only available in WebGL 2 or with the depth texture extension available.
  8472. * @param size The size of face edge in the texture.
  8473. * @param options The options defining the texture.
  8474. * @returns The texture
  8475. */
  8476. createDepthStencilTexture(size: number | {
  8477. width: number;
  8478. height: number;
  8479. layers?: number;
  8480. }, options: DepthTextureCreationOptions): InternalTexture;
  8481. /** @hidden */
  8482. _createDepthStencilTexture(size: number | {
  8483. width: number;
  8484. height: number;
  8485. layers?: number;
  8486. }, options: DepthTextureCreationOptions): InternalTexture;
  8487. }
  8488. }
  8489. declare module BABYLON {
  8490. /** Defines supported spaces */
  8491. export enum Space {
  8492. /** Local (object) space */
  8493. LOCAL = 0,
  8494. /** World space */
  8495. WORLD = 1,
  8496. /** Bone space */
  8497. BONE = 2
  8498. }
  8499. /** Defines the 3 main axes */
  8500. export class Axis {
  8501. /** X axis */
  8502. static X: Vector3;
  8503. /** Y axis */
  8504. static Y: Vector3;
  8505. /** Z axis */
  8506. static Z: Vector3;
  8507. }
  8508. }
  8509. declare module BABYLON {
  8510. /**
  8511. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8512. * This is the base of the follow, arc rotate cameras and Free camera
  8513. * @see http://doc.babylonjs.com/features/cameras
  8514. */
  8515. export class TargetCamera extends Camera {
  8516. private static _RigCamTransformMatrix;
  8517. private static _TargetTransformMatrix;
  8518. private static _TargetFocalPoint;
  8519. /**
  8520. * Define the current direction the camera is moving to
  8521. */
  8522. cameraDirection: Vector3;
  8523. /**
  8524. * Define the current rotation the camera is rotating to
  8525. */
  8526. cameraRotation: Vector2;
  8527. /**
  8528. * When set, the up vector of the camera will be updated by the rotation of the camera
  8529. */
  8530. updateUpVectorFromRotation: boolean;
  8531. private _tmpQuaternion;
  8532. /**
  8533. * Define the current rotation of the camera
  8534. */
  8535. rotation: Vector3;
  8536. /**
  8537. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8538. */
  8539. rotationQuaternion: Quaternion;
  8540. /**
  8541. * Define the current speed of the camera
  8542. */
  8543. speed: number;
  8544. /**
  8545. * Add constraint to the camera to prevent it to move freely in all directions and
  8546. * around all axis.
  8547. */
  8548. noRotationConstraint: boolean;
  8549. /**
  8550. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8551. * panning
  8552. */
  8553. invertRotation: boolean;
  8554. /**
  8555. * Speed multiplier for inverse camera panning
  8556. */
  8557. inverseRotationSpeed: number;
  8558. /**
  8559. * Define the current target of the camera as an object or a position.
  8560. */
  8561. lockedTarget: any;
  8562. /** @hidden */
  8563. _currentTarget: Vector3;
  8564. /** @hidden */
  8565. _initialFocalDistance: number;
  8566. /** @hidden */
  8567. _viewMatrix: Matrix;
  8568. /** @hidden */
  8569. _camMatrix: Matrix;
  8570. /** @hidden */
  8571. _cameraTransformMatrix: Matrix;
  8572. /** @hidden */
  8573. _cameraRotationMatrix: Matrix;
  8574. /** @hidden */
  8575. _referencePoint: Vector3;
  8576. /** @hidden */
  8577. _transformedReferencePoint: Vector3;
  8578. protected _globalCurrentTarget: Vector3;
  8579. protected _globalCurrentUpVector: Vector3;
  8580. /** @hidden */
  8581. _reset: () => void;
  8582. private _defaultUp;
  8583. /**
  8584. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8585. * This is the base of the follow, arc rotate cameras and Free camera
  8586. * @see http://doc.babylonjs.com/features/cameras
  8587. * @param name Defines the name of the camera in the scene
  8588. * @param position Defines the start position of the camera in the scene
  8589. * @param scene Defines the scene the camera belongs to
  8590. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8591. */
  8592. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8593. /**
  8594. * Gets the position in front of the camera at a given distance.
  8595. * @param distance The distance from the camera we want the position to be
  8596. * @returns the position
  8597. */
  8598. getFrontPosition(distance: number): Vector3;
  8599. /** @hidden */
  8600. _getLockedTargetPosition(): Nullable<Vector3>;
  8601. private _storedPosition;
  8602. private _storedRotation;
  8603. private _storedRotationQuaternion;
  8604. /**
  8605. * Store current camera state of the camera (fov, position, rotation, etc..)
  8606. * @returns the camera
  8607. */
  8608. storeState(): Camera;
  8609. /**
  8610. * Restored camera state. You must call storeState() first
  8611. * @returns whether it was successful or not
  8612. * @hidden
  8613. */
  8614. _restoreStateValues(): boolean;
  8615. /** @hidden */
  8616. _initCache(): void;
  8617. /** @hidden */
  8618. _updateCache(ignoreParentClass?: boolean): void;
  8619. /** @hidden */
  8620. _isSynchronizedViewMatrix(): boolean;
  8621. /** @hidden */
  8622. _computeLocalCameraSpeed(): number;
  8623. /**
  8624. * Defines the target the camera should look at.
  8625. * @param target Defines the new target as a Vector or a mesh
  8626. */
  8627. setTarget(target: Vector3): void;
  8628. /**
  8629. * Return the current target position of the camera. This value is expressed in local space.
  8630. * @returns the target position
  8631. */
  8632. getTarget(): Vector3;
  8633. /** @hidden */
  8634. _decideIfNeedsToMove(): boolean;
  8635. /** @hidden */
  8636. _updatePosition(): void;
  8637. /** @hidden */
  8638. _checkInputs(): void;
  8639. protected _updateCameraRotationMatrix(): void;
  8640. /**
  8641. * 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)
  8642. * @returns the current camera
  8643. */
  8644. private _rotateUpVectorWithCameraRotationMatrix;
  8645. private _cachedRotationZ;
  8646. private _cachedQuaternionRotationZ;
  8647. /** @hidden */
  8648. _getViewMatrix(): Matrix;
  8649. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8650. /**
  8651. * @hidden
  8652. */
  8653. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8654. /**
  8655. * @hidden
  8656. */
  8657. _updateRigCameras(): void;
  8658. private _getRigCamPositionAndTarget;
  8659. /**
  8660. * Gets the current object class name.
  8661. * @return the class name
  8662. */
  8663. getClassName(): string;
  8664. }
  8665. }
  8666. declare module BABYLON {
  8667. /**
  8668. * Gather the list of keyboard event types as constants.
  8669. */
  8670. export class KeyboardEventTypes {
  8671. /**
  8672. * The keydown event is fired when a key becomes active (pressed).
  8673. */
  8674. static readonly KEYDOWN: number;
  8675. /**
  8676. * The keyup event is fired when a key has been released.
  8677. */
  8678. static readonly KEYUP: number;
  8679. }
  8680. /**
  8681. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8682. */
  8683. export class KeyboardInfo {
  8684. /**
  8685. * Defines the type of event (KeyboardEventTypes)
  8686. */
  8687. type: number;
  8688. /**
  8689. * Defines the related dom event
  8690. */
  8691. event: KeyboardEvent;
  8692. /**
  8693. * Instantiates a new keyboard info.
  8694. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8695. * @param type Defines the type of event (KeyboardEventTypes)
  8696. * @param event Defines the related dom event
  8697. */
  8698. constructor(
  8699. /**
  8700. * Defines the type of event (KeyboardEventTypes)
  8701. */
  8702. type: number,
  8703. /**
  8704. * Defines the related dom event
  8705. */
  8706. event: KeyboardEvent);
  8707. }
  8708. /**
  8709. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8710. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8711. */
  8712. export class KeyboardInfoPre extends KeyboardInfo {
  8713. /**
  8714. * Defines the type of event (KeyboardEventTypes)
  8715. */
  8716. type: number;
  8717. /**
  8718. * Defines the related dom event
  8719. */
  8720. event: KeyboardEvent;
  8721. /**
  8722. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8723. */
  8724. skipOnPointerObservable: boolean;
  8725. /**
  8726. * Instantiates a new keyboard pre info.
  8727. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8728. * @param type Defines the type of event (KeyboardEventTypes)
  8729. * @param event Defines the related dom event
  8730. */
  8731. constructor(
  8732. /**
  8733. * Defines the type of event (KeyboardEventTypes)
  8734. */
  8735. type: number,
  8736. /**
  8737. * Defines the related dom event
  8738. */
  8739. event: KeyboardEvent);
  8740. }
  8741. }
  8742. declare module BABYLON {
  8743. /**
  8744. * Manage the keyboard inputs to control the movement of a free camera.
  8745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8746. */
  8747. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8748. /**
  8749. * Defines the camera the input is attached to.
  8750. */
  8751. camera: FreeCamera;
  8752. /**
  8753. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8754. */
  8755. keysUp: number[];
  8756. /**
  8757. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8758. */
  8759. keysUpward: number[];
  8760. /**
  8761. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8762. */
  8763. keysDown: number[];
  8764. /**
  8765. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8766. */
  8767. keysDownward: number[];
  8768. /**
  8769. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8770. */
  8771. keysLeft: number[];
  8772. /**
  8773. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8774. */
  8775. keysRight: number[];
  8776. private _keys;
  8777. private _onCanvasBlurObserver;
  8778. private _onKeyboardObserver;
  8779. private _engine;
  8780. private _scene;
  8781. /**
  8782. * Attach the input controls to a specific dom element to get the input from.
  8783. * @param element Defines the element the controls should be listened from
  8784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8785. */
  8786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8787. /**
  8788. * Detach the current controls from the specified dom element.
  8789. * @param element Defines the element to stop listening the inputs from
  8790. */
  8791. detachControl(element: Nullable<HTMLElement>): void;
  8792. /**
  8793. * Update the current camera state depending on the inputs that have been used this frame.
  8794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8795. */
  8796. checkInputs(): void;
  8797. /**
  8798. * Gets the class name of the current intput.
  8799. * @returns the class name
  8800. */
  8801. getClassName(): string;
  8802. /** @hidden */
  8803. _onLostFocus(): void;
  8804. /**
  8805. * Get the friendly name associated with the input class.
  8806. * @returns the input friendly name
  8807. */
  8808. getSimpleName(): string;
  8809. }
  8810. }
  8811. declare module BABYLON {
  8812. /**
  8813. * Interface describing all the common properties and methods a shadow light needs to implement.
  8814. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8815. * as well as binding the different shadow properties to the effects.
  8816. */
  8817. export interface IShadowLight extends Light {
  8818. /**
  8819. * The light id in the scene (used in scene.findLighById for instance)
  8820. */
  8821. id: string;
  8822. /**
  8823. * The position the shdow will be casted from.
  8824. */
  8825. position: Vector3;
  8826. /**
  8827. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8828. */
  8829. direction: Vector3;
  8830. /**
  8831. * The transformed position. Position of the light in world space taking parenting in account.
  8832. */
  8833. transformedPosition: Vector3;
  8834. /**
  8835. * The transformed direction. Direction of the light in world space taking parenting in account.
  8836. */
  8837. transformedDirection: Vector3;
  8838. /**
  8839. * The friendly name of the light in the scene.
  8840. */
  8841. name: string;
  8842. /**
  8843. * Defines the shadow projection clipping minimum z value.
  8844. */
  8845. shadowMinZ: number;
  8846. /**
  8847. * Defines the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8852. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8853. */
  8854. computeTransformedInformation(): boolean;
  8855. /**
  8856. * Gets the scene the light belongs to.
  8857. * @returns The scene
  8858. */
  8859. getScene(): Scene;
  8860. /**
  8861. * Callback defining a custom Projection Matrix Builder.
  8862. * This can be used to override the default projection matrix computation.
  8863. */
  8864. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8865. /**
  8866. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8867. * @param matrix The materix to updated with the projection information
  8868. * @param viewMatrix The transform matrix of the light
  8869. * @param renderList The list of mesh to render in the map
  8870. * @returns The current light
  8871. */
  8872. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8873. /**
  8874. * Gets the current depth scale used in ESM.
  8875. * @returns The scale
  8876. */
  8877. getDepthScale(): number;
  8878. /**
  8879. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8880. * @returns true if a cube texture needs to be use
  8881. */
  8882. needCube(): boolean;
  8883. /**
  8884. * Detects if the projection matrix requires to be recomputed this frame.
  8885. * @returns true if it requires to be recomputed otherwise, false.
  8886. */
  8887. needProjectionMatrixCompute(): boolean;
  8888. /**
  8889. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8890. */
  8891. forceProjectionMatrixCompute(): void;
  8892. /**
  8893. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8894. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8895. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8896. */
  8897. getShadowDirection(faceIndex?: number): Vector3;
  8898. /**
  8899. * Gets the minZ used for shadow according to both the scene and the light.
  8900. * @param activeCamera The camera we are returning the min for
  8901. * @returns the depth min z
  8902. */
  8903. getDepthMinZ(activeCamera: Camera): number;
  8904. /**
  8905. * Gets the maxZ used for shadow according to both the scene and the light.
  8906. * @param activeCamera The camera we are returning the max for
  8907. * @returns the depth max z
  8908. */
  8909. getDepthMaxZ(activeCamera: Camera): number;
  8910. }
  8911. /**
  8912. * Base implementation IShadowLight
  8913. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8914. */
  8915. export abstract class ShadowLight extends Light implements IShadowLight {
  8916. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8917. protected _position: Vector3;
  8918. protected _setPosition(value: Vector3): void;
  8919. /**
  8920. * Sets the position the shadow will be casted from. Also use as the light position for both
  8921. * point and spot lights.
  8922. */
  8923. get position(): Vector3;
  8924. /**
  8925. * Sets the position the shadow will be casted from. Also use as the light position for both
  8926. * point and spot lights.
  8927. */
  8928. set position(value: Vector3);
  8929. protected _direction: Vector3;
  8930. protected _setDirection(value: Vector3): void;
  8931. /**
  8932. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8933. * Also use as the light direction on spot and directional lights.
  8934. */
  8935. get direction(): Vector3;
  8936. /**
  8937. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8938. * Also use as the light direction on spot and directional lights.
  8939. */
  8940. set direction(value: Vector3);
  8941. protected _shadowMinZ: number;
  8942. /**
  8943. * Gets the shadow projection clipping minimum z value.
  8944. */
  8945. get shadowMinZ(): number;
  8946. /**
  8947. * Sets the shadow projection clipping minimum z value.
  8948. */
  8949. set shadowMinZ(value: number);
  8950. protected _shadowMaxZ: number;
  8951. /**
  8952. * Sets the shadow projection clipping maximum z value.
  8953. */
  8954. get shadowMaxZ(): number;
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. set shadowMaxZ(value: number);
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module BABYLON {
  9052. /**
  9053. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9054. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9055. */
  9056. export class EffectFallbacks implements IEffectFallbacks {
  9057. private _defines;
  9058. private _currentRank;
  9059. private _maxRank;
  9060. private _mesh;
  9061. /**
  9062. * Removes the fallback from the bound mesh.
  9063. */
  9064. unBindMesh(): void;
  9065. /**
  9066. * Adds a fallback on the specified property.
  9067. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9068. * @param define The name of the define in the shader
  9069. */
  9070. addFallback(rank: number, define: string): void;
  9071. /**
  9072. * Sets the mesh to use CPU skinning when needing to fallback.
  9073. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9074. * @param mesh The mesh to use the fallbacks.
  9075. */
  9076. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9077. /**
  9078. * Checks to see if more fallbacks are still availible.
  9079. */
  9080. get hasMoreFallbacks(): boolean;
  9081. /**
  9082. * Removes the defines that should be removed when falling back.
  9083. * @param currentDefines defines the current define statements for the shader.
  9084. * @param effect defines the current effect we try to compile
  9085. * @returns The resulting defines with defines of the current rank removed.
  9086. */
  9087. reduce(currentDefines: string, effect: Effect): string;
  9088. }
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * "Static Class" containing the most commonly used helper while dealing with material for
  9093. * rendering purpose.
  9094. *
  9095. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9096. *
  9097. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9098. */
  9099. export class MaterialHelper {
  9100. /**
  9101. * Bind the current view position to an effect.
  9102. * @param effect The effect to be bound
  9103. * @param scene The scene the eyes position is used from
  9104. */
  9105. static BindEyePosition(effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Helps preparing the defines values about the UVs in used in the effect.
  9108. * UVs are shared as much as we can accross channels in the shaders.
  9109. * @param texture The texture we are preparing the UVs for
  9110. * @param defines The defines to update
  9111. * @param key The channel key "diffuse", "specular"... used in the shader
  9112. */
  9113. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9114. /**
  9115. * Binds a texture matrix value to its corrsponding uniform
  9116. * @param texture The texture to bind the matrix for
  9117. * @param uniformBuffer The uniform buffer receivin the data
  9118. * @param key The channel key "diffuse", "specular"... used in the shader
  9119. */
  9120. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9121. /**
  9122. * Gets the current status of the fog (should it be enabled?)
  9123. * @param mesh defines the mesh to evaluate for fog support
  9124. * @param scene defines the hosting scene
  9125. * @returns true if fog must be enabled
  9126. */
  9127. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9128. /**
  9129. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9130. * @param mesh defines the current mesh
  9131. * @param scene defines the current scene
  9132. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9133. * @param pointsCloud defines if point cloud rendering has to be turned on
  9134. * @param fogEnabled defines if fog has to be turned on
  9135. * @param alphaTest defines if alpha testing has to be turned on
  9136. * @param defines defines the current list of defines
  9137. */
  9138. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9139. /**
  9140. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9141. * @param scene defines the current scene
  9142. * @param engine defines the current engine
  9143. * @param defines specifies the list of active defines
  9144. * @param useInstances defines if instances have to be turned on
  9145. * @param useClipPlane defines if clip plane have to be turned on
  9146. */
  9147. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9148. /**
  9149. * Prepares the defines for bones
  9150. * @param mesh The mesh containing the geometry data we will draw
  9151. * @param defines The defines to update
  9152. */
  9153. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9154. /**
  9155. * Prepares the defines for morph targets
  9156. * @param mesh The mesh containing the geometry data we will draw
  9157. * @param defines The defines to update
  9158. */
  9159. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9160. /**
  9161. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9162. * @param mesh The mesh containing the geometry data we will draw
  9163. * @param defines The defines to update
  9164. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9165. * @param useBones Precise whether bones should be used or not (override mesh info)
  9166. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9167. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9168. * @returns false if defines are considered not dirty and have not been checked
  9169. */
  9170. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9171. /**
  9172. * Prepares the defines related to multiview
  9173. * @param scene The scene we are intending to draw
  9174. * @param defines The defines to update
  9175. */
  9176. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9177. /**
  9178. * Prepares the defines related to the light information passed in parameter
  9179. * @param scene The scene we are intending to draw
  9180. * @param mesh The mesh the effect is compiling for
  9181. * @param light The light the effect is compiling for
  9182. * @param lightIndex The index of the light
  9183. * @param defines The defines to update
  9184. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9185. * @param state Defines the current state regarding what is needed (normals, etc...)
  9186. */
  9187. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9188. needNormals: boolean;
  9189. needRebuild: boolean;
  9190. shadowEnabled: boolean;
  9191. specularEnabled: boolean;
  9192. lightmapMode: boolean;
  9193. }): void;
  9194. /**
  9195. * Prepares the defines related to the light information passed in parameter
  9196. * @param scene The scene we are intending to draw
  9197. * @param mesh The mesh the effect is compiling for
  9198. * @param defines The defines to update
  9199. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9200. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9201. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9202. * @returns true if normals will be required for the rest of the effect
  9203. */
  9204. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9205. /**
  9206. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9207. * @param lightIndex defines the light index
  9208. * @param uniformsList The uniform list
  9209. * @param samplersList The sampler list
  9210. * @param projectedLightTexture defines if projected texture must be used
  9211. * @param uniformBuffersList defines an optional list of uniform buffers
  9212. */
  9213. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9214. /**
  9215. * Prepares the uniforms and samplers list to be used in the effect
  9216. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9217. * @param samplersList The sampler list
  9218. * @param defines The defines helping in the list generation
  9219. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9220. */
  9221. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9222. /**
  9223. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9224. * @param defines The defines to update while falling back
  9225. * @param fallbacks The authorized effect fallbacks
  9226. * @param maxSimultaneousLights The maximum number of lights allowed
  9227. * @param rank the current rank of the Effect
  9228. * @returns The newly affected rank
  9229. */
  9230. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9231. private static _TmpMorphInfluencers;
  9232. /**
  9233. * Prepares the list of attributes required for morph targets according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the morph targets attributes for
  9236. * @param influencers The number of influencers
  9237. */
  9238. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9239. /**
  9240. * Prepares the list of attributes required for morph targets according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param mesh The mesh to prepare the morph targets attributes for
  9243. * @param defines The current Defines of the effect
  9244. */
  9245. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9246. /**
  9247. * Prepares the list of attributes required for bones according to the effect defines.
  9248. * @param attribs The current list of supported attribs
  9249. * @param mesh The mesh to prepare the bones attributes for
  9250. * @param defines The current Defines of the effect
  9251. * @param fallbacks The current efffect fallback strategy
  9252. */
  9253. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9254. /**
  9255. * Check and prepare the list of attributes required for instances according to the effect defines.
  9256. * @param attribs The current list of supported attribs
  9257. * @param defines The current MaterialDefines of the effect
  9258. */
  9259. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9260. /**
  9261. * Add the list of attributes required for instances to the attribs array.
  9262. * @param attribs The current list of supported attribs
  9263. */
  9264. static PushAttributesForInstances(attribs: string[]): void;
  9265. /**
  9266. * Binds the light information to the effect.
  9267. * @param light The light containing the generator
  9268. * @param effect The effect we are binding the data to
  9269. * @param lightIndex The light index in the effect used to render
  9270. */
  9271. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9272. /**
  9273. * Binds the lights information from the scene to the effect for the given mesh.
  9274. * @param light Light to bind
  9275. * @param lightIndex Light index
  9276. * @param scene The scene where the light belongs to
  9277. * @param effect The effect we are binding the data to
  9278. * @param useSpecular Defines if specular is supported
  9279. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9280. */
  9281. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param scene The scene the lights belongs to
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. * @param defines The generated defines for the effect
  9288. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9292. private static _tempFogColor;
  9293. /**
  9294. * Binds the fog information from the scene to the effect for the given mesh.
  9295. * @param scene The scene the lights belongs to
  9296. * @param mesh The mesh we are binding the information to render
  9297. * @param effect The effect we are binding the data to
  9298. * @param linearSpace Defines if the fog effect is applied in linear space
  9299. */
  9300. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9301. /**
  9302. * Binds the bones information from the mesh to the effect.
  9303. * @param mesh The mesh we are binding the information to render
  9304. * @param effect The effect we are binding the data to
  9305. */
  9306. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9307. /**
  9308. * Binds the morph targets information from the mesh to the effect.
  9309. * @param abstractMesh The mesh we are binding the information to render
  9310. * @param effect The effect we are binding the data to
  9311. */
  9312. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9313. /**
  9314. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9315. * @param defines The generated defines used in the effect
  9316. * @param effect The effect we are binding the data to
  9317. * @param scene The scene we are willing to render with logarithmic scale for
  9318. */
  9319. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9320. /**
  9321. * Binds the clip plane information from the scene to the effect.
  9322. * @param scene The scene the clip plane information are extracted from
  9323. * @param effect The effect we are binding the data to
  9324. */
  9325. static BindClipPlane(effect: Effect, scene: Scene): void;
  9326. }
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var packingFunctions: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var clipPlaneFragmentDeclaration: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var clipPlaneFragment: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /** @hidden */
  9351. export var shadowMapPixelShader: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module BABYLON {
  9357. /** @hidden */
  9358. export var bonesDeclaration: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module BABYLON {
  9364. /** @hidden */
  9365. export var morphTargetsVertexGlobalDeclaration: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module BABYLON {
  9371. /** @hidden */
  9372. export var morphTargetsVertexDeclaration: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module BABYLON {
  9378. /** @hidden */
  9379. export var instancesDeclaration: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module BABYLON {
  9385. /** @hidden */
  9386. export var helperFunctions: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module BABYLON {
  9392. /** @hidden */
  9393. export var clipPlaneVertexDeclaration: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module BABYLON {
  9399. /** @hidden */
  9400. export var morphTargetsVertex: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module BABYLON {
  9406. /** @hidden */
  9407. export var instancesVertex: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module BABYLON {
  9413. /** @hidden */
  9414. export var bonesVertex: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module BABYLON {
  9420. /** @hidden */
  9421. export var clipPlaneVertex: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module BABYLON {
  9427. /** @hidden */
  9428. export var shadowMapVertexShader: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module BABYLON {
  9434. /** @hidden */
  9435. export var depthBoxBlurPixelShader: {
  9436. name: string;
  9437. shader: string;
  9438. };
  9439. }
  9440. declare module BABYLON {
  9441. /**
  9442. * Class representing a ray with position and direction
  9443. */
  9444. export class Ray {
  9445. /** origin point */
  9446. origin: Vector3;
  9447. /** direction */
  9448. direction: Vector3;
  9449. /** length of the ray */
  9450. length: number;
  9451. private static readonly TmpVector3;
  9452. private _tmpRay;
  9453. /**
  9454. * Creates a new ray
  9455. * @param origin origin point
  9456. * @param direction direction
  9457. * @param length length of the ray
  9458. */
  9459. constructor(
  9460. /** origin point */
  9461. origin: Vector3,
  9462. /** direction */
  9463. direction: Vector3,
  9464. /** length of the ray */
  9465. length?: number);
  9466. /**
  9467. * Checks if the ray intersects a box
  9468. * @param minimum bound of the box
  9469. * @param maximum bound of the box
  9470. * @param intersectionTreshold extra extend to be added to the box in all direction
  9471. * @returns if the box was hit
  9472. */
  9473. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9474. /**
  9475. * Checks if the ray intersects a box
  9476. * @param box the bounding box to check
  9477. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9478. * @returns if the box was hit
  9479. */
  9480. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9481. /**
  9482. * If the ray hits a sphere
  9483. * @param sphere the bounding sphere to check
  9484. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9485. * @returns true if it hits the sphere
  9486. */
  9487. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9488. /**
  9489. * If the ray hits a triange
  9490. * @param vertex0 triangle vertex
  9491. * @param vertex1 triangle vertex
  9492. * @param vertex2 triangle vertex
  9493. * @returns intersection information if hit
  9494. */
  9495. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9496. /**
  9497. * Checks if ray intersects a plane
  9498. * @param plane the plane to check
  9499. * @returns the distance away it was hit
  9500. */
  9501. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9502. /**
  9503. * Calculate the intercept of a ray on a given axis
  9504. * @param axis to check 'x' | 'y' | 'z'
  9505. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9506. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9507. */
  9508. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9509. /**
  9510. * Checks if ray intersects a mesh
  9511. * @param mesh the mesh to check
  9512. * @param fastCheck if only the bounding box should checked
  9513. * @returns picking info of the intersecton
  9514. */
  9515. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9516. /**
  9517. * Checks if ray intersects a mesh
  9518. * @param meshes the meshes to check
  9519. * @param fastCheck if only the bounding box should checked
  9520. * @param results array to store result in
  9521. * @returns Array of picking infos
  9522. */
  9523. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9524. private _comparePickingInfo;
  9525. private static smallnum;
  9526. private static rayl;
  9527. /**
  9528. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9529. * @param sega the first point of the segment to test the intersection against
  9530. * @param segb the second point of the segment to test the intersection against
  9531. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9532. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9533. */
  9534. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9535. /**
  9536. * Update the ray from viewport position
  9537. * @param x position
  9538. * @param y y position
  9539. * @param viewportWidth viewport width
  9540. * @param viewportHeight viewport height
  9541. * @param world world matrix
  9542. * @param view view matrix
  9543. * @param projection projection matrix
  9544. * @returns this ray updated
  9545. */
  9546. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9547. /**
  9548. * Creates a ray with origin and direction of 0,0,0
  9549. * @returns the new ray
  9550. */
  9551. static Zero(): Ray;
  9552. /**
  9553. * Creates a new ray from screen space and viewport
  9554. * @param x position
  9555. * @param y y position
  9556. * @param viewportWidth viewport width
  9557. * @param viewportHeight viewport height
  9558. * @param world world matrix
  9559. * @param view view matrix
  9560. * @param projection projection matrix
  9561. * @returns new ray
  9562. */
  9563. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9564. /**
  9565. * 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
  9566. * transformed to the given world matrix.
  9567. * @param origin The origin point
  9568. * @param end The end point
  9569. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9570. * @returns the new ray
  9571. */
  9572. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9573. /**
  9574. * Transforms a ray by a matrix
  9575. * @param ray ray to transform
  9576. * @param matrix matrix to apply
  9577. * @returns the resulting new ray
  9578. */
  9579. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9580. /**
  9581. * Transforms a ray by a matrix
  9582. * @param ray ray to transform
  9583. * @param matrix matrix to apply
  9584. * @param result ray to store result in
  9585. */
  9586. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9587. /**
  9588. * Unproject a ray from screen space to object space
  9589. * @param sourceX defines the screen space x coordinate to use
  9590. * @param sourceY defines the screen space y coordinate to use
  9591. * @param viewportWidth defines the current width of the viewport
  9592. * @param viewportHeight defines the current height of the viewport
  9593. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9594. * @param view defines the view matrix to use
  9595. * @param projection defines the projection matrix to use
  9596. */
  9597. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9598. }
  9599. /**
  9600. * Type used to define predicate used to select faces when a mesh intersection is detected
  9601. */
  9602. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9603. interface Scene {
  9604. /** @hidden */
  9605. _tempPickingRay: Nullable<Ray>;
  9606. /** @hidden */
  9607. _cachedRayForTransform: Ray;
  9608. /** @hidden */
  9609. _pickWithRayInverseMatrix: Matrix;
  9610. /** @hidden */
  9611. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9612. /** @hidden */
  9613. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9614. }
  9615. }
  9616. declare module BABYLON {
  9617. /**
  9618. * Groups all the scene component constants in one place to ease maintenance.
  9619. * @hidden
  9620. */
  9621. export class SceneComponentConstants {
  9622. static readonly NAME_EFFECTLAYER: string;
  9623. static readonly NAME_LAYER: string;
  9624. static readonly NAME_LENSFLARESYSTEM: string;
  9625. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9626. static readonly NAME_PARTICLESYSTEM: string;
  9627. static readonly NAME_GAMEPAD: string;
  9628. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9629. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9630. static readonly NAME_DEPTHRENDERER: string;
  9631. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9632. static readonly NAME_SPRITE: string;
  9633. static readonly NAME_OUTLINERENDERER: string;
  9634. static readonly NAME_PROCEDURALTEXTURE: string;
  9635. static readonly NAME_SHADOWGENERATOR: string;
  9636. static readonly NAME_OCTREE: string;
  9637. static readonly NAME_PHYSICSENGINE: string;
  9638. static readonly NAME_AUDIO: string;
  9639. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9640. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9641. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9642. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9643. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9644. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9645. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9646. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9647. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9648. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9649. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9650. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9651. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9652. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9653. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9654. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9655. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9656. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9657. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9658. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9659. static readonly STEP_AFTERRENDER_AUDIO: number;
  9660. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9661. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9662. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9663. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9664. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9665. static readonly STEP_POINTERMOVE_SPRITE: number;
  9666. static readonly STEP_POINTERDOWN_SPRITE: number;
  9667. static readonly STEP_POINTERUP_SPRITE: number;
  9668. }
  9669. /**
  9670. * This represents a scene component.
  9671. *
  9672. * This is used to decouple the dependency the scene is having on the different workloads like
  9673. * layers, post processes...
  9674. */
  9675. export interface ISceneComponent {
  9676. /**
  9677. * The name of the component. Each component must have a unique name.
  9678. */
  9679. name: string;
  9680. /**
  9681. * The scene the component belongs to.
  9682. */
  9683. scene: Scene;
  9684. /**
  9685. * Register the component to one instance of a scene.
  9686. */
  9687. register(): void;
  9688. /**
  9689. * Rebuilds the elements related to this component in case of
  9690. * context lost for instance.
  9691. */
  9692. rebuild(): void;
  9693. /**
  9694. * Disposes the component and the associated ressources.
  9695. */
  9696. dispose(): void;
  9697. }
  9698. /**
  9699. * This represents a SERIALIZABLE scene component.
  9700. *
  9701. * This extends Scene Component to add Serialization methods on top.
  9702. */
  9703. export interface ISceneSerializableComponent extends ISceneComponent {
  9704. /**
  9705. * Adds all the elements from the container to the scene
  9706. * @param container the container holding the elements
  9707. */
  9708. addFromContainer(container: AbstractScene): void;
  9709. /**
  9710. * Removes all the elements in the container from the scene
  9711. * @param container contains the elements to remove
  9712. * @param dispose if the removed element should be disposed (default: false)
  9713. */
  9714. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9715. /**
  9716. * Serializes the component data to the specified json object
  9717. * @param serializationObject The object to serialize to
  9718. */
  9719. serialize(serializationObject: any): void;
  9720. }
  9721. /**
  9722. * Strong typing of a Mesh related stage step action
  9723. */
  9724. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9725. /**
  9726. * Strong typing of a Evaluate Sub Mesh related stage step action
  9727. */
  9728. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9729. /**
  9730. * Strong typing of a Active Mesh related stage step action
  9731. */
  9732. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9733. /**
  9734. * Strong typing of a Camera related stage step action
  9735. */
  9736. export type CameraStageAction = (camera: Camera) => void;
  9737. /**
  9738. * Strong typing of a Camera Frame buffer related stage step action
  9739. */
  9740. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9741. /**
  9742. * Strong typing of a Render Target related stage step action
  9743. */
  9744. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9745. /**
  9746. * Strong typing of a RenderingGroup related stage step action
  9747. */
  9748. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9749. /**
  9750. * Strong typing of a Mesh Render related stage step action
  9751. */
  9752. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9753. /**
  9754. * Strong typing of a simple stage step action
  9755. */
  9756. export type SimpleStageAction = () => void;
  9757. /**
  9758. * Strong typing of a render target action.
  9759. */
  9760. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9761. /**
  9762. * Strong typing of a pointer move action.
  9763. */
  9764. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9765. /**
  9766. * Strong typing of a pointer up/down action.
  9767. */
  9768. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9769. /**
  9770. * Representation of a stage in the scene (Basically a list of ordered steps)
  9771. * @hidden
  9772. */
  9773. export class Stage<T extends Function> extends Array<{
  9774. index: number;
  9775. component: ISceneComponent;
  9776. action: T;
  9777. }> {
  9778. /**
  9779. * Hide ctor from the rest of the world.
  9780. * @param items The items to add.
  9781. */
  9782. private constructor();
  9783. /**
  9784. * Creates a new Stage.
  9785. * @returns A new instance of a Stage
  9786. */
  9787. static Create<T extends Function>(): Stage<T>;
  9788. /**
  9789. * Registers a step in an ordered way in the targeted stage.
  9790. * @param index Defines the position to register the step in
  9791. * @param component Defines the component attached to the step
  9792. * @param action Defines the action to launch during the step
  9793. */
  9794. registerStep(index: number, component: ISceneComponent, action: T): void;
  9795. /**
  9796. * Clears all the steps from the stage.
  9797. */
  9798. clear(): void;
  9799. }
  9800. }
  9801. declare module BABYLON {
  9802. interface Scene {
  9803. /** @hidden */
  9804. _pointerOverSprite: Nullable<Sprite>;
  9805. /** @hidden */
  9806. _pickedDownSprite: Nullable<Sprite>;
  9807. /** @hidden */
  9808. _tempSpritePickingRay: Nullable<Ray>;
  9809. /**
  9810. * All of the sprite managers added to this scene
  9811. * @see http://doc.babylonjs.com/babylon101/sprites
  9812. */
  9813. spriteManagers: Array<ISpriteManager>;
  9814. /**
  9815. * An event triggered when sprites rendering is about to start
  9816. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9817. */
  9818. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9819. /**
  9820. * An event triggered when sprites rendering is done
  9821. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9822. */
  9823. onAfterSpritesRenderingObservable: Observable<Scene>;
  9824. /** @hidden */
  9825. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9826. /** Launch a ray to try to pick a sprite in the scene
  9827. * @param x position on screen
  9828. * @param y position on screen
  9829. * @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
  9830. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9832. * @returns a PickingInfo
  9833. */
  9834. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9835. /** Use the given ray to pick a sprite in the scene
  9836. * @param ray The ray (in world space) to use to pick meshes
  9837. * @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
  9838. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9839. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9840. * @returns a PickingInfo
  9841. */
  9842. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9843. /** @hidden */
  9844. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9845. /** Launch a ray to try to pick sprites in the scene
  9846. * @param x position on screen
  9847. * @param y position on screen
  9848. * @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
  9849. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9850. * @returns a PickingInfo array
  9851. */
  9852. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9853. /** Use the given ray to pick sprites in the scene
  9854. * @param ray The ray (in world space) to use to pick meshes
  9855. * @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
  9856. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9857. * @returns a PickingInfo array
  9858. */
  9859. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9860. /**
  9861. * Force the sprite under the pointer
  9862. * @param sprite defines the sprite to use
  9863. */
  9864. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9865. /**
  9866. * Gets the sprite under the pointer
  9867. * @returns a Sprite or null if no sprite is under the pointer
  9868. */
  9869. getPointerOverSprite(): Nullable<Sprite>;
  9870. }
  9871. /**
  9872. * Defines the sprite scene component responsible to manage sprites
  9873. * in a given scene.
  9874. */
  9875. export class SpriteSceneComponent implements ISceneComponent {
  9876. /**
  9877. * The component name helpfull to identify the component in the list of scene components.
  9878. */
  9879. readonly name: string;
  9880. /**
  9881. * The scene the component belongs to.
  9882. */
  9883. scene: Scene;
  9884. /** @hidden */
  9885. private _spritePredicate;
  9886. /**
  9887. * Creates a new instance of the component for the given scene
  9888. * @param scene Defines the scene to register the component in
  9889. */
  9890. constructor(scene: Scene);
  9891. /**
  9892. * Registers the component in a given scene
  9893. */
  9894. register(): void;
  9895. /**
  9896. * Rebuilds the elements related to this component in case of
  9897. * context lost for instance.
  9898. */
  9899. rebuild(): void;
  9900. /**
  9901. * Disposes the component and the associated ressources.
  9902. */
  9903. dispose(): void;
  9904. private _pickSpriteButKeepRay;
  9905. private _pointerMove;
  9906. private _pointerDown;
  9907. private _pointerUp;
  9908. }
  9909. }
  9910. declare module BABYLON {
  9911. /** @hidden */
  9912. export var fogFragmentDeclaration: {
  9913. name: string;
  9914. shader: string;
  9915. };
  9916. }
  9917. declare module BABYLON {
  9918. /** @hidden */
  9919. export var fogFragment: {
  9920. name: string;
  9921. shader: string;
  9922. };
  9923. }
  9924. declare module BABYLON {
  9925. /** @hidden */
  9926. export var spritesPixelShader: {
  9927. name: string;
  9928. shader: string;
  9929. };
  9930. }
  9931. declare module BABYLON {
  9932. /** @hidden */
  9933. export var fogVertexDeclaration: {
  9934. name: string;
  9935. shader: string;
  9936. };
  9937. }
  9938. declare module BABYLON {
  9939. /** @hidden */
  9940. export var spritesVertexShader: {
  9941. name: string;
  9942. shader: string;
  9943. };
  9944. }
  9945. declare module BABYLON {
  9946. /**
  9947. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9948. */
  9949. export interface ISpriteManager extends IDisposable {
  9950. /**
  9951. * Restricts the camera to viewing objects with the same layerMask.
  9952. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9953. */
  9954. layerMask: number;
  9955. /**
  9956. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9957. */
  9958. isPickable: boolean;
  9959. /**
  9960. * Specifies the rendering group id for this mesh (0 by default)
  9961. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9962. */
  9963. renderingGroupId: number;
  9964. /**
  9965. * Defines the list of sprites managed by the manager.
  9966. */
  9967. sprites: Array<Sprite>;
  9968. /**
  9969. * Tests the intersection of a sprite with a specific ray.
  9970. * @param ray The ray we are sending to test the collision
  9971. * @param camera The camera space we are sending rays in
  9972. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9973. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9974. * @returns picking info or null.
  9975. */
  9976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9977. /**
  9978. * Intersects the sprites with a ray
  9979. * @param ray defines the ray to intersect with
  9980. * @param camera defines the current active camera
  9981. * @param predicate defines a predicate used to select candidate sprites
  9982. * @returns null if no hit or a PickingInfo array
  9983. */
  9984. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9985. /**
  9986. * Renders the list of sprites on screen.
  9987. */
  9988. render(): void;
  9989. }
  9990. /**
  9991. * Class used to manage multiple sprites on the same spritesheet
  9992. * @see http://doc.babylonjs.com/babylon101/sprites
  9993. */
  9994. export class SpriteManager implements ISpriteManager {
  9995. /** defines the manager's name */
  9996. name: string;
  9997. /** Gets the list of sprites */
  9998. sprites: Sprite[];
  9999. /** Gets or sets the rendering group id (0 by default) */
  10000. renderingGroupId: number;
  10001. /** Gets or sets camera layer mask */
  10002. layerMask: number;
  10003. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10004. fogEnabled: boolean;
  10005. /** Gets or sets a boolean indicating if the sprites are pickable */
  10006. isPickable: boolean;
  10007. /** Defines the default width of a cell in the spritesheet */
  10008. cellWidth: number;
  10009. /** Defines the default height of a cell in the spritesheet */
  10010. cellHeight: number;
  10011. /** Associative array from JSON sprite data file */
  10012. private _cellData;
  10013. /** Array of sprite names from JSON sprite data file */
  10014. private _spriteMap;
  10015. /** True when packed cell data from JSON file is ready*/
  10016. private _packedAndReady;
  10017. /**
  10018. * An event triggered when the manager is disposed.
  10019. */
  10020. onDisposeObservable: Observable<SpriteManager>;
  10021. private _onDisposeObserver;
  10022. /**
  10023. * Callback called when the manager is disposed
  10024. */
  10025. set onDispose(callback: () => void);
  10026. private _capacity;
  10027. private _fromPacked;
  10028. private _spriteTexture;
  10029. private _epsilon;
  10030. private _scene;
  10031. private _vertexData;
  10032. private _buffer;
  10033. private _vertexBuffers;
  10034. private _indexBuffer;
  10035. private _effectBase;
  10036. private _effectFog;
  10037. /**
  10038. * Gets or sets the spritesheet texture
  10039. */
  10040. get texture(): Texture;
  10041. set texture(value: Texture);
  10042. private _blendMode;
  10043. /**
  10044. * Blend mode use to render the particle, it can be any of
  10045. * the static Constants.ALPHA_x properties provided in this class.
  10046. * Default value is Constants.ALPHA_COMBINE
  10047. */
  10048. get blendMode(): number;
  10049. set blendMode(blendMode: number);
  10050. /** Disables writing to the depth buffer when rendering the sprites.
  10051. * It can be handy to disable depth writing when using textures without alpha channel
  10052. * and setting some specific blend modes.
  10053. */
  10054. disableDepthWrite: boolean;
  10055. /**
  10056. * Creates a new sprite manager
  10057. * @param name defines the manager's name
  10058. * @param imgUrl defines the sprite sheet url
  10059. * @param capacity defines the maximum allowed number of sprites
  10060. * @param cellSize defines the size of a sprite cell
  10061. * @param scene defines the hosting scene
  10062. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10063. * @param samplingMode defines the smapling mode to use with spritesheet
  10064. * @param fromPacked set to false; do not alter
  10065. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10066. */
  10067. constructor(
  10068. /** defines the manager's name */
  10069. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10070. private _makePacked;
  10071. private _appendSpriteVertex;
  10072. /**
  10073. * Intersects the sprites with a ray
  10074. * @param ray defines the ray to intersect with
  10075. * @param camera defines the current active camera
  10076. * @param predicate defines a predicate used to select candidate sprites
  10077. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10078. * @returns null if no hit or a PickingInfo
  10079. */
  10080. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10081. /**
  10082. * Intersects the sprites with a ray
  10083. * @param ray defines the ray to intersect with
  10084. * @param camera defines the current active camera
  10085. * @param predicate defines a predicate used to select candidate sprites
  10086. * @returns null if no hit or a PickingInfo array
  10087. */
  10088. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10089. /**
  10090. * Render all child sprites
  10091. */
  10092. render(): void;
  10093. /**
  10094. * Release associated resources
  10095. */
  10096. dispose(): void;
  10097. }
  10098. }
  10099. declare module BABYLON {
  10100. /** Interface used by value gradients (color, factor, ...) */
  10101. export interface IValueGradient {
  10102. /**
  10103. * Gets or sets the gradient value (between 0 and 1)
  10104. */
  10105. gradient: number;
  10106. }
  10107. /** Class used to store color4 gradient */
  10108. export class ColorGradient implements IValueGradient {
  10109. /**
  10110. * Gets or sets the gradient value (between 0 and 1)
  10111. */
  10112. gradient: number;
  10113. /**
  10114. * Gets or sets first associated color
  10115. */
  10116. color1: Color4;
  10117. /**
  10118. * Gets or sets second associated color
  10119. */
  10120. color2?: Color4;
  10121. /**
  10122. * Will get a color picked randomly between color1 and color2.
  10123. * If color2 is undefined then color1 will be used
  10124. * @param result defines the target Color4 to store the result in
  10125. */
  10126. getColorToRef(result: Color4): void;
  10127. }
  10128. /** Class used to store color 3 gradient */
  10129. export class Color3Gradient implements IValueGradient {
  10130. /**
  10131. * Gets or sets the gradient value (between 0 and 1)
  10132. */
  10133. gradient: number;
  10134. /**
  10135. * Gets or sets the associated color
  10136. */
  10137. color: Color3;
  10138. }
  10139. /** Class used to store factor gradient */
  10140. export class FactorGradient implements IValueGradient {
  10141. /**
  10142. * Gets or sets the gradient value (between 0 and 1)
  10143. */
  10144. gradient: number;
  10145. /**
  10146. * Gets or sets first associated factor
  10147. */
  10148. factor1: number;
  10149. /**
  10150. * Gets or sets second associated factor
  10151. */
  10152. factor2?: number;
  10153. /**
  10154. * Will get a number picked randomly between factor1 and factor2.
  10155. * If factor2 is undefined then factor1 will be used
  10156. * @returns the picked number
  10157. */
  10158. getFactor(): number;
  10159. }
  10160. /**
  10161. * Helper used to simplify some generic gradient tasks
  10162. */
  10163. export class GradientHelper {
  10164. /**
  10165. * Gets the current gradient from an array of IValueGradient
  10166. * @param ratio defines the current ratio to get
  10167. * @param gradients defines the array of IValueGradient
  10168. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10169. */
  10170. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10171. }
  10172. }
  10173. declare module BABYLON {
  10174. /**
  10175. * Interface for the size containing width and height
  10176. */
  10177. export interface ISize {
  10178. /**
  10179. * Width
  10180. */
  10181. width: number;
  10182. /**
  10183. * Heighht
  10184. */
  10185. height: number;
  10186. }
  10187. /**
  10188. * Size containing widht and height
  10189. */
  10190. export class Size implements ISize {
  10191. /**
  10192. * Width
  10193. */
  10194. width: number;
  10195. /**
  10196. * Height
  10197. */
  10198. height: number;
  10199. /**
  10200. * Creates a Size object from the given width and height (floats).
  10201. * @param width width of the new size
  10202. * @param height height of the new size
  10203. */
  10204. constructor(width: number, height: number);
  10205. /**
  10206. * Returns a string with the Size width and height
  10207. * @returns a string with the Size width and height
  10208. */
  10209. toString(): string;
  10210. /**
  10211. * "Size"
  10212. * @returns the string "Size"
  10213. */
  10214. getClassName(): string;
  10215. /**
  10216. * Returns the Size hash code.
  10217. * @returns a hash code for a unique width and height
  10218. */
  10219. getHashCode(): number;
  10220. /**
  10221. * Updates the current size from the given one.
  10222. * @param src the given size
  10223. */
  10224. copyFrom(src: Size): void;
  10225. /**
  10226. * Updates in place the current Size from the given floats.
  10227. * @param width width of the new size
  10228. * @param height height of the new size
  10229. * @returns the updated Size.
  10230. */
  10231. copyFromFloats(width: number, height: number): Size;
  10232. /**
  10233. * Updates in place the current Size from the given floats.
  10234. * @param width width to set
  10235. * @param height height to set
  10236. * @returns the updated Size.
  10237. */
  10238. set(width: number, height: number): Size;
  10239. /**
  10240. * Multiplies the width and height by numbers
  10241. * @param w factor to multiple the width by
  10242. * @param h factor to multiple the height by
  10243. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10244. */
  10245. multiplyByFloats(w: number, h: number): Size;
  10246. /**
  10247. * Clones the size
  10248. * @returns a new Size copied from the given one.
  10249. */
  10250. clone(): Size;
  10251. /**
  10252. * True if the current Size and the given one width and height are strictly equal.
  10253. * @param other the other size to compare against
  10254. * @returns True if the current Size and the given one width and height are strictly equal.
  10255. */
  10256. equals(other: Size): boolean;
  10257. /**
  10258. * The surface of the Size : width * height (float).
  10259. */
  10260. get surface(): number;
  10261. /**
  10262. * Create a new size of zero
  10263. * @returns a new Size set to (0.0, 0.0)
  10264. */
  10265. static Zero(): Size;
  10266. /**
  10267. * Sums the width and height of two sizes
  10268. * @param otherSize size to add to this size
  10269. * @returns a new Size set as the addition result of the current Size and the given one.
  10270. */
  10271. add(otherSize: Size): Size;
  10272. /**
  10273. * Subtracts the width and height of two
  10274. * @param otherSize size to subtract to this size
  10275. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10276. */
  10277. subtract(otherSize: Size): Size;
  10278. /**
  10279. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10280. * @param start starting size to lerp between
  10281. * @param end end size to lerp between
  10282. * @param amount amount to lerp between the start and end values
  10283. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10284. */
  10285. static Lerp(start: Size, end: Size, amount: number): Size;
  10286. }
  10287. }
  10288. declare module BABYLON {
  10289. interface ThinEngine {
  10290. /**
  10291. * Creates a dynamic texture
  10292. * @param width defines the width of the texture
  10293. * @param height defines the height of the texture
  10294. * @param generateMipMaps defines if the engine should generate the mip levels
  10295. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10296. * @returns the dynamic texture inside an InternalTexture
  10297. */
  10298. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10299. /**
  10300. * Update the content of a dynamic texture
  10301. * @param texture defines the texture to update
  10302. * @param canvas defines the canvas containing the source
  10303. * @param invertY defines if data must be stored with Y axis inverted
  10304. * @param premulAlpha defines if alpha is stored as premultiplied
  10305. * @param format defines the format of the data
  10306. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10307. */
  10308. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * Helper class used to generate a canvas to manipulate images
  10314. */
  10315. export class CanvasGenerator {
  10316. /**
  10317. * Create a new canvas (or offscreen canvas depending on the context)
  10318. * @param width defines the expected width
  10319. * @param height defines the expected height
  10320. * @return a new canvas or offscreen canvas
  10321. */
  10322. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10323. }
  10324. }
  10325. declare module BABYLON {
  10326. /**
  10327. * A class extending Texture allowing drawing on a texture
  10328. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10329. */
  10330. export class DynamicTexture extends Texture {
  10331. private _generateMipMaps;
  10332. private _canvas;
  10333. private _context;
  10334. private _engine;
  10335. /**
  10336. * Creates a DynamicTexture
  10337. * @param name defines the name of the texture
  10338. * @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
  10339. * @param scene defines the scene where you want the texture
  10340. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10341. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10342. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10343. */
  10344. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10345. /**
  10346. * Get the current class name of the texture useful for serialization or dynamic coding.
  10347. * @returns "DynamicTexture"
  10348. */
  10349. getClassName(): string;
  10350. /**
  10351. * Gets the current state of canRescale
  10352. */
  10353. get canRescale(): boolean;
  10354. private _recreate;
  10355. /**
  10356. * Scales the texture
  10357. * @param ratio the scale factor to apply to both width and height
  10358. */
  10359. scale(ratio: number): void;
  10360. /**
  10361. * Resizes the texture
  10362. * @param width the new width
  10363. * @param height the new height
  10364. */
  10365. scaleTo(width: number, height: number): void;
  10366. /**
  10367. * Gets the context of the canvas used by the texture
  10368. * @returns the canvas context of the dynamic texture
  10369. */
  10370. getContext(): CanvasRenderingContext2D;
  10371. /**
  10372. * Clears the texture
  10373. */
  10374. clear(): void;
  10375. /**
  10376. * Updates the texture
  10377. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10378. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10379. */
  10380. update(invertY?: boolean, premulAlpha?: boolean): void;
  10381. /**
  10382. * Draws text onto the texture
  10383. * @param text defines the text to be drawn
  10384. * @param x defines the placement of the text from the left
  10385. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10386. * @param font defines the font to be used with font-style, font-size, font-name
  10387. * @param color defines the color used for the text
  10388. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10389. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10390. * @param update defines whether texture is immediately update (default is true)
  10391. */
  10392. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10393. /**
  10394. * Clones the texture
  10395. * @returns the clone of the texture.
  10396. */
  10397. clone(): DynamicTexture;
  10398. /**
  10399. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10400. * @returns a serialized dynamic texture object
  10401. */
  10402. serialize(): any;
  10403. /** @hidden */
  10404. _rebuild(): void;
  10405. }
  10406. }
  10407. declare module BABYLON {
  10408. interface Engine {
  10409. /**
  10410. * Creates a raw texture
  10411. * @param data defines the data to store in the texture
  10412. * @param width defines the width of the texture
  10413. * @param height defines the height of the texture
  10414. * @param format defines the format of the data
  10415. * @param generateMipMaps defines if the engine should generate the mip levels
  10416. * @param invertY defines if data must be stored with Y axis inverted
  10417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10418. * @param compression defines the compression used (null by default)
  10419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10420. * @returns the raw texture inside an InternalTexture
  10421. */
  10422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10423. /**
  10424. * Update a raw texture
  10425. * @param texture defines the texture to update
  10426. * @param data defines the data to store in the texture
  10427. * @param format defines the format of the data
  10428. * @param invertY defines if data must be stored with Y axis inverted
  10429. */
  10430. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10431. /**
  10432. * Update a raw texture
  10433. * @param texture defines the texture to update
  10434. * @param data defines the data to store in the texture
  10435. * @param format defines the format of the data
  10436. * @param invertY defines if data must be stored with Y axis inverted
  10437. * @param compression defines the compression used (null by default)
  10438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10439. */
  10440. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10441. /**
  10442. * Creates a new raw cube texture
  10443. * @param data defines the array of data to use to create each face
  10444. * @param size defines the size of the textures
  10445. * @param format defines the format of the data
  10446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10447. * @param generateMipMaps defines if the engine should generate the mip levels
  10448. * @param invertY defines if data must be stored with Y axis inverted
  10449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10450. * @param compression defines the compression used (null by default)
  10451. * @returns the cube texture as an InternalTexture
  10452. */
  10453. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10454. /**
  10455. * Update a raw cube texture
  10456. * @param texture defines the texture to udpdate
  10457. * @param data defines the data to store
  10458. * @param format defines the data format
  10459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. */
  10462. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10463. /**
  10464. * Update a raw cube texture
  10465. * @param texture defines the texture to udpdate
  10466. * @param data defines the data to store
  10467. * @param format defines the data format
  10468. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10469. * @param invertY defines if data must be stored with Y axis inverted
  10470. * @param compression defines the compression used (null by default)
  10471. */
  10472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10473. /**
  10474. * Update a raw cube texture
  10475. * @param texture defines the texture to udpdate
  10476. * @param data defines the data to store
  10477. * @param format defines the data format
  10478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10479. * @param invertY defines if data must be stored with Y axis inverted
  10480. * @param compression defines the compression used (null by default)
  10481. * @param level defines which level of the texture to update
  10482. */
  10483. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10484. /**
  10485. * Creates a new raw cube texture from a specified url
  10486. * @param url defines the url where the data is located
  10487. * @param scene defines the current scene
  10488. * @param size defines the size of the textures
  10489. * @param format defines the format of the data
  10490. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10491. * @param noMipmap defines if the engine should avoid generating the mip levels
  10492. * @param callback defines a callback used to extract texture data from loaded data
  10493. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10494. * @param onLoad defines a callback called when texture is loaded
  10495. * @param onError defines a callback called if there is an error
  10496. * @returns the cube texture as an InternalTexture
  10497. */
  10498. 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;
  10499. /**
  10500. * Creates a new raw cube texture from a specified url
  10501. * @param url defines the url where the data is located
  10502. * @param scene defines the current scene
  10503. * @param size defines the size of the textures
  10504. * @param format defines the format of the data
  10505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10506. * @param noMipmap defines if the engine should avoid generating the mip levels
  10507. * @param callback defines a callback used to extract texture data from loaded data
  10508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10509. * @param onLoad defines a callback called when texture is loaded
  10510. * @param onError defines a callback called if there is an error
  10511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10512. * @param invertY defines if data must be stored with Y axis inverted
  10513. * @returns the cube texture as an InternalTexture
  10514. */
  10515. 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;
  10516. /**
  10517. * Creates a new raw 3D texture
  10518. * @param data defines the data used to create the texture
  10519. * @param width defines the width of the texture
  10520. * @param height defines the height of the texture
  10521. * @param depth defines the depth of the texture
  10522. * @param format defines the format of the texture
  10523. * @param generateMipMaps defines if the engine must generate mip levels
  10524. * @param invertY defines if data must be stored with Y axis inverted
  10525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10526. * @param compression defines the compressed used (can be null)
  10527. * @param textureType defines the compressed used (can be null)
  10528. * @returns a new raw 3D texture (stored in an InternalTexture)
  10529. */
  10530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10531. /**
  10532. * Update a raw 3D texture
  10533. * @param texture defines the texture to update
  10534. * @param data defines the data to store
  10535. * @param format defines the data format
  10536. * @param invertY defines if data must be stored with Y axis inverted
  10537. */
  10538. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10539. /**
  10540. * Update a raw 3D texture
  10541. * @param texture defines the texture to update
  10542. * @param data defines the data to store
  10543. * @param format defines the data format
  10544. * @param invertY defines if data must be stored with Y axis inverted
  10545. * @param compression defines the used compression (can be null)
  10546. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10547. */
  10548. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10549. /**
  10550. * Creates a new raw 2D array texture
  10551. * @param data defines the data used to create the texture
  10552. * @param width defines the width of the texture
  10553. * @param height defines the height of the texture
  10554. * @param depth defines the number of layers of the texture
  10555. * @param format defines the format of the texture
  10556. * @param generateMipMaps defines if the engine must generate mip levels
  10557. * @param invertY defines if data must be stored with Y axis inverted
  10558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10559. * @param compression defines the compressed used (can be null)
  10560. * @param textureType defines the compressed used (can be null)
  10561. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10562. */
  10563. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10564. /**
  10565. * Update a raw 2D array texture
  10566. * @param texture defines the texture to update
  10567. * @param data defines the data to store
  10568. * @param format defines the data format
  10569. * @param invertY defines if data must be stored with Y axis inverted
  10570. */
  10571. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10572. /**
  10573. * Update a raw 2D array texture
  10574. * @param texture defines the texture to update
  10575. * @param data defines the data to store
  10576. * @param format defines the data format
  10577. * @param invertY defines if data must be stored with Y axis inverted
  10578. * @param compression defines the used compression (can be null)
  10579. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10580. */
  10581. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10582. }
  10583. }
  10584. declare module BABYLON {
  10585. /**
  10586. * Raw texture can help creating a texture directly from an array of data.
  10587. * This can be super useful if you either get the data from an uncompressed source or
  10588. * if you wish to create your texture pixel by pixel.
  10589. */
  10590. export class RawTexture extends Texture {
  10591. /**
  10592. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10593. */
  10594. format: number;
  10595. private _engine;
  10596. /**
  10597. * Instantiates a new RawTexture.
  10598. * Raw texture can help creating a texture directly from an array of data.
  10599. * This can be super useful if you either get the data from an uncompressed source or
  10600. * if you wish to create your texture pixel by pixel.
  10601. * @param data define the array of data to use to create the texture
  10602. * @param width define the width of the texture
  10603. * @param height define the height of the texture
  10604. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10605. * @param scene define the scene the texture belongs to
  10606. * @param generateMipMaps define whether mip maps should be generated or not
  10607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10609. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10610. */
  10611. constructor(data: ArrayBufferView, width: number, height: number,
  10612. /**
  10613. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10614. */
  10615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10616. /**
  10617. * Updates the texture underlying data.
  10618. * @param data Define the new data of the texture
  10619. */
  10620. update(data: ArrayBufferView): void;
  10621. /**
  10622. * Creates a luminance texture from some data.
  10623. * @param data Define the texture data
  10624. * @param width Define the width of the texture
  10625. * @param height Define the height of the texture
  10626. * @param scene Define the scene the texture belongs to
  10627. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10630. * @returns the luminance texture
  10631. */
  10632. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10633. /**
  10634. * Creates a luminance alpha texture from some data.
  10635. * @param data Define the texture data
  10636. * @param width Define the width of the texture
  10637. * @param height Define the height of the texture
  10638. * @param scene Define the scene the texture belongs to
  10639. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10642. * @returns the luminance alpha texture
  10643. */
  10644. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10645. /**
  10646. * Creates an alpha texture from some data.
  10647. * @param data Define the texture data
  10648. * @param width Define the width of the texture
  10649. * @param height Define the height of the texture
  10650. * @param scene Define the scene the texture belongs to
  10651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10654. * @returns the alpha texture
  10655. */
  10656. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10657. /**
  10658. * Creates a RGB texture from some data.
  10659. * @param data Define the texture data
  10660. * @param width Define the width of the texture
  10661. * @param height Define the height of the texture
  10662. * @param scene Define the scene the texture belongs to
  10663. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10667. * @returns the RGB alpha texture
  10668. */
  10669. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10670. /**
  10671. * Creates a RGBA texture from some data.
  10672. * @param data Define the texture data
  10673. * @param width Define the width of the texture
  10674. * @param height Define the height of the texture
  10675. * @param scene Define the scene the texture belongs to
  10676. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10677. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10678. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10679. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10680. * @returns the RGBA texture
  10681. */
  10682. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10683. /**
  10684. * Creates a R texture from some data.
  10685. * @param data Define the texture data
  10686. * @param width Define the width of the texture
  10687. * @param height Define the height of the texture
  10688. * @param scene Define the scene the texture belongs to
  10689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10692. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10693. * @returns the R texture
  10694. */
  10695. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10696. }
  10697. }
  10698. declare module BABYLON {
  10699. interface AbstractScene {
  10700. /**
  10701. * The list of procedural textures added to the scene
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10703. */
  10704. proceduralTextures: Array<ProceduralTexture>;
  10705. }
  10706. /**
  10707. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10708. * in a given scene.
  10709. */
  10710. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10711. /**
  10712. * The component name helpfull to identify the component in the list of scene components.
  10713. */
  10714. readonly name: string;
  10715. /**
  10716. * The scene the component belongs to.
  10717. */
  10718. scene: Scene;
  10719. /**
  10720. * Creates a new instance of the component for the given scene
  10721. * @param scene Defines the scene to register the component in
  10722. */
  10723. constructor(scene: Scene);
  10724. /**
  10725. * Registers the component in a given scene
  10726. */
  10727. register(): void;
  10728. /**
  10729. * Rebuilds the elements related to this component in case of
  10730. * context lost for instance.
  10731. */
  10732. rebuild(): void;
  10733. /**
  10734. * Disposes the component and the associated ressources.
  10735. */
  10736. dispose(): void;
  10737. private _beforeClear;
  10738. }
  10739. }
  10740. declare module BABYLON {
  10741. interface ThinEngine {
  10742. /**
  10743. * Creates a new render target cube texture
  10744. * @param size defines the size of the texture
  10745. * @param options defines the options used to create the texture
  10746. * @returns a new render target cube texture stored in an InternalTexture
  10747. */
  10748. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10749. }
  10750. }
  10751. declare module BABYLON {
  10752. /** @hidden */
  10753. export var proceduralVertexShader: {
  10754. name: string;
  10755. shader: string;
  10756. };
  10757. }
  10758. declare module BABYLON {
  10759. /**
  10760. * 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.
  10761. * This is the base class of any Procedural texture and contains most of the shareable code.
  10762. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10763. */
  10764. export class ProceduralTexture extends Texture {
  10765. isCube: boolean;
  10766. /**
  10767. * Define if the texture is enabled or not (disabled texture will not render)
  10768. */
  10769. isEnabled: boolean;
  10770. /**
  10771. * Define if the texture must be cleared before rendering (default is true)
  10772. */
  10773. autoClear: boolean;
  10774. /**
  10775. * Callback called when the texture is generated
  10776. */
  10777. onGenerated: () => void;
  10778. /**
  10779. * Event raised when the texture is generated
  10780. */
  10781. onGeneratedObservable: Observable<ProceduralTexture>;
  10782. /** @hidden */
  10783. _generateMipMaps: boolean;
  10784. /** @hidden **/
  10785. _effect: Effect;
  10786. /** @hidden */
  10787. _textures: {
  10788. [key: string]: Texture;
  10789. };
  10790. private _size;
  10791. private _currentRefreshId;
  10792. private _frameId;
  10793. private _refreshRate;
  10794. private _vertexBuffers;
  10795. private _indexBuffer;
  10796. private _uniforms;
  10797. private _samplers;
  10798. private _fragment;
  10799. private _floats;
  10800. private _ints;
  10801. private _floatsArrays;
  10802. private _colors3;
  10803. private _colors4;
  10804. private _vectors2;
  10805. private _vectors3;
  10806. private _matrices;
  10807. private _fallbackTexture;
  10808. private _fallbackTextureUsed;
  10809. private _engine;
  10810. private _cachedDefines;
  10811. private _contentUpdateId;
  10812. private _contentData;
  10813. /**
  10814. * Instantiates a new procedural texture.
  10815. * 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.
  10816. * This is the base class of any Procedural texture and contains most of the shareable code.
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10818. * @param name Define the name of the texture
  10819. * @param size Define the size of the texture to create
  10820. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10821. * @param scene Define the scene the texture belongs to
  10822. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10823. * @param generateMipMaps Define if the texture should creates mip maps or not
  10824. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10825. */
  10826. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10827. /**
  10828. * The effect that is created when initializing the post process.
  10829. * @returns The created effect corresponding the the postprocess.
  10830. */
  10831. getEffect(): Effect;
  10832. /**
  10833. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10834. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10835. */
  10836. getContent(): Nullable<ArrayBufferView>;
  10837. private _createIndexBuffer;
  10838. /** @hidden */
  10839. _rebuild(): void;
  10840. /**
  10841. * Resets the texture in order to recreate its associated resources.
  10842. * This can be called in case of context loss
  10843. */
  10844. reset(): void;
  10845. protected _getDefines(): string;
  10846. /**
  10847. * Is the texture ready to be used ? (rendered at least once)
  10848. * @returns true if ready, otherwise, false.
  10849. */
  10850. isReady(): boolean;
  10851. /**
  10852. * Resets the refresh counter of the texture and start bak from scratch.
  10853. * Could be useful to regenerate the texture if it is setup to render only once.
  10854. */
  10855. resetRefreshCounter(): void;
  10856. /**
  10857. * Set the fragment shader to use in order to render the texture.
  10858. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10859. */
  10860. setFragment(fragment: any): void;
  10861. /**
  10862. * Define the refresh rate of the texture or the rendering frequency.
  10863. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10864. */
  10865. get refreshRate(): number;
  10866. set refreshRate(value: number);
  10867. /** @hidden */
  10868. _shouldRender(): boolean;
  10869. /**
  10870. * Get the size the texture is rendering at.
  10871. * @returns the size (texture is always squared)
  10872. */
  10873. getRenderSize(): number;
  10874. /**
  10875. * Resize the texture to new value.
  10876. * @param size Define the new size the texture should have
  10877. * @param generateMipMaps Define whether the new texture should create mip maps
  10878. */
  10879. resize(size: number, generateMipMaps: boolean): void;
  10880. private _checkUniform;
  10881. /**
  10882. * Set a texture in the shader program used to render.
  10883. * @param name Define the name of the uniform samplers as defined in the shader
  10884. * @param texture Define the texture to bind to this sampler
  10885. * @return the texture itself allowing "fluent" like uniform updates
  10886. */
  10887. setTexture(name: string, texture: Texture): ProceduralTexture;
  10888. /**
  10889. * Set a float in the shader.
  10890. * @param name Define the name of the uniform as defined in the shader
  10891. * @param value Define the value to give to the uniform
  10892. * @return the texture itself allowing "fluent" like uniform updates
  10893. */
  10894. setFloat(name: string, value: number): ProceduralTexture;
  10895. /**
  10896. * Set a int in the shader.
  10897. * @param name Define the name of the uniform as defined in the shader
  10898. * @param value Define the value to give to the uniform
  10899. * @return the texture itself allowing "fluent" like uniform updates
  10900. */
  10901. setInt(name: string, value: number): ProceduralTexture;
  10902. /**
  10903. * Set an array of floats in the shader.
  10904. * @param name Define the name of the uniform as defined in the shader
  10905. * @param value Define the value to give to the uniform
  10906. * @return the texture itself allowing "fluent" like uniform updates
  10907. */
  10908. setFloats(name: string, value: number[]): ProceduralTexture;
  10909. /**
  10910. * Set a vec3 in the shader from a Color3.
  10911. * @param name Define the name of the uniform as defined in the shader
  10912. * @param value Define the value to give to the uniform
  10913. * @return the texture itself allowing "fluent" like uniform updates
  10914. */
  10915. setColor3(name: string, value: Color3): ProceduralTexture;
  10916. /**
  10917. * Set a vec4 in the shader from a Color4.
  10918. * @param name Define the name of the uniform as defined in the shader
  10919. * @param value Define the value to give to the uniform
  10920. * @return the texture itself allowing "fluent" like uniform updates
  10921. */
  10922. setColor4(name: string, value: Color4): ProceduralTexture;
  10923. /**
  10924. * Set a vec2 in the shader from a Vector2.
  10925. * @param name Define the name of the uniform as defined in the shader
  10926. * @param value Define the value to give to the uniform
  10927. * @return the texture itself allowing "fluent" like uniform updates
  10928. */
  10929. setVector2(name: string, value: Vector2): ProceduralTexture;
  10930. /**
  10931. * Set a vec3 in the shader from a Vector3.
  10932. * @param name Define the name of the uniform as defined in the shader
  10933. * @param value Define the value to give to the uniform
  10934. * @return the texture itself allowing "fluent" like uniform updates
  10935. */
  10936. setVector3(name: string, value: Vector3): ProceduralTexture;
  10937. /**
  10938. * Set a mat4 in the shader from a MAtrix.
  10939. * @param name Define the name of the uniform as defined in the shader
  10940. * @param value Define the value to give to the uniform
  10941. * @return the texture itself allowing "fluent" like uniform updates
  10942. */
  10943. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10944. /**
  10945. * Render the texture to its associated render target.
  10946. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10947. */
  10948. render(useCameraPostProcess?: boolean): void;
  10949. /**
  10950. * Clone the texture.
  10951. * @returns the cloned texture
  10952. */
  10953. clone(): ProceduralTexture;
  10954. /**
  10955. * Dispose the texture and release its asoociated resources.
  10956. */
  10957. dispose(): void;
  10958. }
  10959. }
  10960. declare module BABYLON {
  10961. /**
  10962. * This represents the base class for particle system in Babylon.
  10963. * 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.
  10964. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10965. * @example https://doc.babylonjs.com/babylon101/particles
  10966. */
  10967. export class BaseParticleSystem {
  10968. /**
  10969. * Source color is added to the destination color without alpha affecting the result
  10970. */
  10971. static BLENDMODE_ONEONE: number;
  10972. /**
  10973. * Blend current color and particle color using particle’s alpha
  10974. */
  10975. static BLENDMODE_STANDARD: number;
  10976. /**
  10977. * Add current color and particle color multiplied by particle’s alpha
  10978. */
  10979. static BLENDMODE_ADD: number;
  10980. /**
  10981. * Multiply current color with particle color
  10982. */
  10983. static BLENDMODE_MULTIPLY: number;
  10984. /**
  10985. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10986. */
  10987. static BLENDMODE_MULTIPLYADD: number;
  10988. /**
  10989. * List of animations used by the particle system.
  10990. */
  10991. animations: Animation[];
  10992. /**
  10993. * The id of the Particle system.
  10994. */
  10995. id: string;
  10996. /**
  10997. * The friendly name of the Particle system.
  10998. */
  10999. name: string;
  11000. /**
  11001. * The rendering group used by the Particle system to chose when to render.
  11002. */
  11003. renderingGroupId: number;
  11004. /**
  11005. * The emitter represents the Mesh or position we are attaching the particle system to.
  11006. */
  11007. emitter: Nullable<AbstractMesh | Vector3>;
  11008. /**
  11009. * The maximum number of particles to emit per frame
  11010. */
  11011. emitRate: number;
  11012. /**
  11013. * If you want to launch only a few particles at once, that can be done, as well.
  11014. */
  11015. manualEmitCount: number;
  11016. /**
  11017. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11018. */
  11019. updateSpeed: number;
  11020. /**
  11021. * The amount of time the particle system is running (depends of the overall update speed).
  11022. */
  11023. targetStopDuration: number;
  11024. /**
  11025. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11026. */
  11027. disposeOnStop: boolean;
  11028. /**
  11029. * Minimum power of emitting particles.
  11030. */
  11031. minEmitPower: number;
  11032. /**
  11033. * Maximum power of emitting particles.
  11034. */
  11035. maxEmitPower: number;
  11036. /**
  11037. * Minimum life time of emitting particles.
  11038. */
  11039. minLifeTime: number;
  11040. /**
  11041. * Maximum life time of emitting particles.
  11042. */
  11043. maxLifeTime: number;
  11044. /**
  11045. * Minimum Size of emitting particles.
  11046. */
  11047. minSize: number;
  11048. /**
  11049. * Maximum Size of emitting particles.
  11050. */
  11051. maxSize: number;
  11052. /**
  11053. * Minimum scale of emitting particles on X axis.
  11054. */
  11055. minScaleX: number;
  11056. /**
  11057. * Maximum scale of emitting particles on X axis.
  11058. */
  11059. maxScaleX: number;
  11060. /**
  11061. * Minimum scale of emitting particles on Y axis.
  11062. */
  11063. minScaleY: number;
  11064. /**
  11065. * Maximum scale of emitting particles on Y axis.
  11066. */
  11067. maxScaleY: number;
  11068. /**
  11069. * Gets or sets the minimal initial rotation in radians.
  11070. */
  11071. minInitialRotation: number;
  11072. /**
  11073. * Gets or sets the maximal initial rotation in radians.
  11074. */
  11075. maxInitialRotation: number;
  11076. /**
  11077. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11078. */
  11079. minAngularSpeed: number;
  11080. /**
  11081. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11082. */
  11083. maxAngularSpeed: number;
  11084. /**
  11085. * The texture used to render each particle. (this can be a spritesheet)
  11086. */
  11087. particleTexture: Nullable<Texture>;
  11088. /**
  11089. * The layer mask we are rendering the particles through.
  11090. */
  11091. layerMask: number;
  11092. /**
  11093. * This can help using your own shader to render the particle system.
  11094. * The according effect will be created
  11095. */
  11096. customShader: any;
  11097. /**
  11098. * By default particle system starts as soon as they are created. This prevents the
  11099. * automatic start to happen and let you decide when to start emitting particles.
  11100. */
  11101. preventAutoStart: boolean;
  11102. private _noiseTexture;
  11103. /**
  11104. * Gets or sets a texture used to add random noise to particle positions
  11105. */
  11106. get noiseTexture(): Nullable<ProceduralTexture>;
  11107. set noiseTexture(value: Nullable<ProceduralTexture>);
  11108. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11109. noiseStrength: Vector3;
  11110. /**
  11111. * Callback triggered when the particle animation is ending.
  11112. */
  11113. onAnimationEnd: Nullable<() => void>;
  11114. /**
  11115. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11116. */
  11117. blendMode: number;
  11118. /**
  11119. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11120. * to override the particles.
  11121. */
  11122. forceDepthWrite: boolean;
  11123. /** 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 */
  11124. preWarmCycles: number;
  11125. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11126. preWarmStepOffset: number;
  11127. /**
  11128. * 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)
  11129. */
  11130. spriteCellChangeSpeed: number;
  11131. /**
  11132. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11133. */
  11134. startSpriteCellID: number;
  11135. /**
  11136. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11137. */
  11138. endSpriteCellID: number;
  11139. /**
  11140. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11141. */
  11142. spriteCellWidth: number;
  11143. /**
  11144. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11145. */
  11146. spriteCellHeight: number;
  11147. /**
  11148. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11149. */
  11150. spriteRandomStartCell: boolean;
  11151. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11152. translationPivot: Vector2;
  11153. /** @hidden */
  11154. protected _isAnimationSheetEnabled: boolean;
  11155. /**
  11156. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11157. */
  11158. beginAnimationOnStart: boolean;
  11159. /**
  11160. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11161. */
  11162. beginAnimationFrom: number;
  11163. /**
  11164. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11165. */
  11166. beginAnimationTo: number;
  11167. /**
  11168. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11169. */
  11170. beginAnimationLoop: boolean;
  11171. /**
  11172. * Gets or sets a world offset applied to all particles
  11173. */
  11174. worldOffset: Vector3;
  11175. /**
  11176. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11177. */
  11178. get isAnimationSheetEnabled(): boolean;
  11179. set isAnimationSheetEnabled(value: boolean);
  11180. /**
  11181. * Get hosting scene
  11182. * @returns the scene
  11183. */
  11184. getScene(): Scene;
  11185. /**
  11186. * You can use gravity if you want to give an orientation to your particles.
  11187. */
  11188. gravity: Vector3;
  11189. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11190. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11191. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11192. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11193. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11194. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11195. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11196. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11197. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11198. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11199. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11200. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11201. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11202. /**
  11203. * Defines the delay in milliseconds before starting the system (0 by default)
  11204. */
  11205. startDelay: number;
  11206. /**
  11207. * Gets the current list of drag gradients.
  11208. * You must use addDragGradient and removeDragGradient to udpate this list
  11209. * @returns the list of drag gradients
  11210. */
  11211. getDragGradients(): Nullable<Array<FactorGradient>>;
  11212. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11213. limitVelocityDamping: number;
  11214. /**
  11215. * Gets the current list of limit velocity gradients.
  11216. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11217. * @returns the list of limit velocity gradients
  11218. */
  11219. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11220. /**
  11221. * Gets the current list of color gradients.
  11222. * You must use addColorGradient and removeColorGradient to udpate this list
  11223. * @returns the list of color gradients
  11224. */
  11225. getColorGradients(): Nullable<Array<ColorGradient>>;
  11226. /**
  11227. * Gets the current list of size gradients.
  11228. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11229. * @returns the list of size gradients
  11230. */
  11231. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11232. /**
  11233. * Gets the current list of color remap gradients.
  11234. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11235. * @returns the list of color remap gradients
  11236. */
  11237. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11238. /**
  11239. * Gets the current list of alpha remap gradients.
  11240. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11241. * @returns the list of alpha remap gradients
  11242. */
  11243. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11244. /**
  11245. * Gets the current list of life time gradients.
  11246. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11247. * @returns the list of life time gradients
  11248. */
  11249. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11250. /**
  11251. * Gets the current list of angular speed gradients.
  11252. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11253. * @returns the list of angular speed gradients
  11254. */
  11255. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11256. /**
  11257. * Gets the current list of velocity gradients.
  11258. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11259. * @returns the list of velocity gradients
  11260. */
  11261. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11262. /**
  11263. * Gets the current list of start size gradients.
  11264. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11265. * @returns the list of start size gradients
  11266. */
  11267. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11268. /**
  11269. * Gets the current list of emit rate gradients.
  11270. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11271. * @returns the list of emit rate gradients
  11272. */
  11273. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11274. /**
  11275. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11276. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11277. */
  11278. get direction1(): Vector3;
  11279. set direction1(value: Vector3);
  11280. /**
  11281. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11283. */
  11284. get direction2(): Vector3;
  11285. set direction2(value: Vector3);
  11286. /**
  11287. * 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.
  11288. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11289. */
  11290. get minEmitBox(): Vector3;
  11291. set minEmitBox(value: Vector3);
  11292. /**
  11293. * 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.
  11294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11295. */
  11296. get maxEmitBox(): Vector3;
  11297. set maxEmitBox(value: Vector3);
  11298. /**
  11299. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11300. */
  11301. color1: Color4;
  11302. /**
  11303. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11304. */
  11305. color2: Color4;
  11306. /**
  11307. * Color the particle will have at the end of its lifetime
  11308. */
  11309. colorDead: Color4;
  11310. /**
  11311. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11312. */
  11313. textureMask: Color4;
  11314. /**
  11315. * The particle emitter type defines the emitter used by the particle system.
  11316. * It can be for example box, sphere, or cone...
  11317. */
  11318. particleEmitterType: IParticleEmitterType;
  11319. /** @hidden */
  11320. _isSubEmitter: boolean;
  11321. /**
  11322. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11323. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11324. */
  11325. billboardMode: number;
  11326. protected _isBillboardBased: boolean;
  11327. /**
  11328. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11329. */
  11330. get isBillboardBased(): boolean;
  11331. set isBillboardBased(value: boolean);
  11332. /**
  11333. * The scene the particle system belongs to.
  11334. */
  11335. protected _scene: Scene;
  11336. /**
  11337. * Local cache of defines for image processing.
  11338. */
  11339. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11340. /**
  11341. * Default configuration related to image processing available in the standard Material.
  11342. */
  11343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11344. /**
  11345. * Gets the image processing configuration used either in this material.
  11346. */
  11347. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11348. /**
  11349. * Sets the Default image processing configuration used either in the this material.
  11350. *
  11351. * If sets to null, the scene one is in use.
  11352. */
  11353. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11354. /**
  11355. * Attaches a new image processing configuration to the Standard Material.
  11356. * @param configuration
  11357. */
  11358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11359. /** @hidden */
  11360. protected _reset(): void;
  11361. /** @hidden */
  11362. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11363. /**
  11364. * Instantiates a particle system.
  11365. * 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.
  11366. * @param name The name of the particle system
  11367. */
  11368. constructor(name: string);
  11369. /**
  11370. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11373. * @returns the emitter
  11374. */
  11375. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11376. /**
  11377. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11378. * @param radius The radius of the hemisphere to emit from
  11379. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11380. * @returns the emitter
  11381. */
  11382. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11383. /**
  11384. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11385. * @param radius The radius of the sphere to emit from
  11386. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11387. * @returns the emitter
  11388. */
  11389. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11390. /**
  11391. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11392. * @param radius The radius of the sphere to emit from
  11393. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11394. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11395. * @returns the emitter
  11396. */
  11397. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11398. /**
  11399. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11400. * @param radius The radius of the emission cylinder
  11401. * @param height The height of the emission cylinder
  11402. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11403. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11404. * @returns the emitter
  11405. */
  11406. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11407. /**
  11408. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11409. * @param radius The radius of the cylinder to emit from
  11410. * @param height The height of the emission cylinder
  11411. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11412. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11413. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11414. * @returns the emitter
  11415. */
  11416. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11417. /**
  11418. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11419. * @param radius The radius of the cone to emit from
  11420. * @param angle The base angle of the cone
  11421. * @returns the emitter
  11422. */
  11423. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11424. /**
  11425. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11428. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11429. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11430. * @returns the emitter
  11431. */
  11432. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11433. }
  11434. }
  11435. declare module BABYLON {
  11436. /**
  11437. * Type of sub emitter
  11438. */
  11439. export enum SubEmitterType {
  11440. /**
  11441. * Attached to the particle over it's lifetime
  11442. */
  11443. ATTACHED = 0,
  11444. /**
  11445. * Created when the particle dies
  11446. */
  11447. END = 1
  11448. }
  11449. /**
  11450. * Sub emitter class used to emit particles from an existing particle
  11451. */
  11452. export class SubEmitter {
  11453. /**
  11454. * the particle system to be used by the sub emitter
  11455. */
  11456. particleSystem: ParticleSystem;
  11457. /**
  11458. * Type of the submitter (Default: END)
  11459. */
  11460. type: SubEmitterType;
  11461. /**
  11462. * 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)
  11463. * Note: This only is supported when using an emitter of type Mesh
  11464. */
  11465. inheritDirection: boolean;
  11466. /**
  11467. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11468. */
  11469. inheritedVelocityAmount: number;
  11470. /**
  11471. * Creates a sub emitter
  11472. * @param particleSystem the particle system to be used by the sub emitter
  11473. */
  11474. constructor(
  11475. /**
  11476. * the particle system to be used by the sub emitter
  11477. */
  11478. particleSystem: ParticleSystem);
  11479. /**
  11480. * Clones the sub emitter
  11481. * @returns the cloned sub emitter
  11482. */
  11483. clone(): SubEmitter;
  11484. /**
  11485. * Serialize current object to a JSON object
  11486. * @returns the serialized object
  11487. */
  11488. serialize(): any;
  11489. /** @hidden */
  11490. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11491. /**
  11492. * Creates a new SubEmitter from a serialized JSON version
  11493. * @param serializationObject defines the JSON object to read from
  11494. * @param scene defines the hosting scene
  11495. * @param rootUrl defines the rootUrl for data loading
  11496. * @returns a new SubEmitter
  11497. */
  11498. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11499. /** Release associated resources */
  11500. dispose(): void;
  11501. }
  11502. }
  11503. declare module BABYLON {
  11504. /** @hidden */
  11505. export var imageProcessingDeclaration: {
  11506. name: string;
  11507. shader: string;
  11508. };
  11509. }
  11510. declare module BABYLON {
  11511. /** @hidden */
  11512. export var imageProcessingFunctions: {
  11513. name: string;
  11514. shader: string;
  11515. };
  11516. }
  11517. declare module BABYLON {
  11518. /** @hidden */
  11519. export var particlesPixelShader: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module BABYLON {
  11525. /** @hidden */
  11526. export var particlesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module BABYLON {
  11532. /**
  11533. * This represents a particle system in Babylon.
  11534. * 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.
  11535. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11536. * @example https://doc.babylonjs.com/babylon101/particles
  11537. */
  11538. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11539. /**
  11540. * Billboard mode will only apply to Y axis
  11541. */
  11542. static readonly BILLBOARDMODE_Y: number;
  11543. /**
  11544. * Billboard mode will apply to all axes
  11545. */
  11546. static readonly BILLBOARDMODE_ALL: number;
  11547. /**
  11548. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11549. */
  11550. static readonly BILLBOARDMODE_STRETCHED: number;
  11551. /**
  11552. * This function can be defined to provide custom update for active particles.
  11553. * This function will be called instead of regular update (age, position, color, etc.).
  11554. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11555. */
  11556. updateFunction: (particles: Particle[]) => void;
  11557. private _emitterWorldMatrix;
  11558. /**
  11559. * This function can be defined to specify initial direction for every new particle.
  11560. * It by default use the emitterType defined function
  11561. */
  11562. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11563. /**
  11564. * This function can be defined to specify initial position for every new particle.
  11565. * It by default use the emitterType defined function
  11566. */
  11567. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11568. /**
  11569. * @hidden
  11570. */
  11571. _inheritedVelocityOffset: Vector3;
  11572. /**
  11573. * An event triggered when the system is disposed
  11574. */
  11575. onDisposeObservable: Observable<ParticleSystem>;
  11576. private _onDisposeObserver;
  11577. /**
  11578. * Sets a callback that will be triggered when the system is disposed
  11579. */
  11580. set onDispose(callback: () => void);
  11581. private _particles;
  11582. private _epsilon;
  11583. private _capacity;
  11584. private _stockParticles;
  11585. private _newPartsExcess;
  11586. private _vertexData;
  11587. private _vertexBuffer;
  11588. private _vertexBuffers;
  11589. private _spriteBuffer;
  11590. private _indexBuffer;
  11591. private _effect;
  11592. private _customEffect;
  11593. private _cachedDefines;
  11594. private _scaledColorStep;
  11595. private _colorDiff;
  11596. private _scaledDirection;
  11597. private _scaledGravity;
  11598. private _currentRenderId;
  11599. private _alive;
  11600. private _useInstancing;
  11601. private _started;
  11602. private _stopped;
  11603. private _actualFrame;
  11604. private _scaledUpdateSpeed;
  11605. private _vertexBufferSize;
  11606. /** @hidden */
  11607. _currentEmitRateGradient: Nullable<FactorGradient>;
  11608. /** @hidden */
  11609. _currentEmitRate1: number;
  11610. /** @hidden */
  11611. _currentEmitRate2: number;
  11612. /** @hidden */
  11613. _currentStartSizeGradient: Nullable<FactorGradient>;
  11614. /** @hidden */
  11615. _currentStartSize1: number;
  11616. /** @hidden */
  11617. _currentStartSize2: number;
  11618. private readonly _rawTextureWidth;
  11619. private _rampGradientsTexture;
  11620. private _useRampGradients;
  11621. /** Gets or sets a boolean indicating that ramp gradients must be used
  11622. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11623. */
  11624. get useRampGradients(): boolean;
  11625. set useRampGradients(value: boolean);
  11626. /**
  11627. * 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.
  11628. * 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: [])
  11629. */
  11630. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11631. private _subEmitters;
  11632. /**
  11633. * @hidden
  11634. * If the particle systems emitter should be disposed when the particle system is disposed
  11635. */
  11636. _disposeEmitterOnDispose: boolean;
  11637. /**
  11638. * The current active Sub-systems, this property is used by the root particle system only.
  11639. */
  11640. activeSubSystems: Array<ParticleSystem>;
  11641. /**
  11642. * Specifies if the particles are updated in emitter local space or world space
  11643. */
  11644. isLocal: boolean;
  11645. private _rootParticleSystem;
  11646. /**
  11647. * Gets the current list of active particles
  11648. */
  11649. get particles(): Particle[];
  11650. /**
  11651. * Returns the string "ParticleSystem"
  11652. * @returns a string containing the class name
  11653. */
  11654. getClassName(): string;
  11655. /**
  11656. * Instantiates a particle system.
  11657. * 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.
  11658. * @param name The name of the particle system
  11659. * @param capacity The max number of particles alive at the same time
  11660. * @param scene The scene the particle system belongs to
  11661. * @param customEffect a custom effect used to change the way particles are rendered by default
  11662. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11663. * @param epsilon Offset used to render the particles
  11664. */
  11665. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11666. private _addFactorGradient;
  11667. private _removeFactorGradient;
  11668. /**
  11669. * Adds a new life time gradient
  11670. * @param gradient defines the gradient to use (between 0 and 1)
  11671. * @param factor defines the life time factor to affect to the specified gradient
  11672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11673. * @returns the current particle system
  11674. */
  11675. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11676. /**
  11677. * Remove a specific life time gradient
  11678. * @param gradient defines the gradient to remove
  11679. * @returns the current particle system
  11680. */
  11681. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11682. /**
  11683. * Adds a new size gradient
  11684. * @param gradient defines the gradient to use (between 0 and 1)
  11685. * @param factor defines the size factor to affect to the specified gradient
  11686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11687. * @returns the current particle system
  11688. */
  11689. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11690. /**
  11691. * Remove a specific size gradient
  11692. * @param gradient defines the gradient to remove
  11693. * @returns the current particle system
  11694. */
  11695. removeSizeGradient(gradient: number): IParticleSystem;
  11696. /**
  11697. * Adds a new color remap gradient
  11698. * @param gradient defines the gradient to use (between 0 and 1)
  11699. * @param min defines the color remap minimal range
  11700. * @param max defines the color remap maximal range
  11701. * @returns the current particle system
  11702. */
  11703. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11704. /**
  11705. * Remove a specific color remap gradient
  11706. * @param gradient defines the gradient to remove
  11707. * @returns the current particle system
  11708. */
  11709. removeColorRemapGradient(gradient: number): IParticleSystem;
  11710. /**
  11711. * Adds a new alpha remap gradient
  11712. * @param gradient defines the gradient to use (between 0 and 1)
  11713. * @param min defines the alpha remap minimal range
  11714. * @param max defines the alpha remap maximal range
  11715. * @returns the current particle system
  11716. */
  11717. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11718. /**
  11719. * Remove a specific alpha remap gradient
  11720. * @param gradient defines the gradient to remove
  11721. * @returns the current particle system
  11722. */
  11723. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11724. /**
  11725. * Adds a new angular speed gradient
  11726. * @param gradient defines the gradient to use (between 0 and 1)
  11727. * @param factor defines the angular speed to affect to the specified gradient
  11728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11729. * @returns the current particle system
  11730. */
  11731. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11732. /**
  11733. * Remove a specific angular speed gradient
  11734. * @param gradient defines the gradient to remove
  11735. * @returns the current particle system
  11736. */
  11737. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11738. /**
  11739. * Adds a new velocity gradient
  11740. * @param gradient defines the gradient to use (between 0 and 1)
  11741. * @param factor defines the velocity to affect to the specified gradient
  11742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11743. * @returns the current particle system
  11744. */
  11745. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11746. /**
  11747. * Remove a specific velocity gradient
  11748. * @param gradient defines the gradient to remove
  11749. * @returns the current particle system
  11750. */
  11751. removeVelocityGradient(gradient: number): IParticleSystem;
  11752. /**
  11753. * Adds a new limit velocity gradient
  11754. * @param gradient defines the gradient to use (between 0 and 1)
  11755. * @param factor defines the limit velocity value to affect to the specified gradient
  11756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11757. * @returns the current particle system
  11758. */
  11759. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11760. /**
  11761. * Remove a specific limit velocity gradient
  11762. * @param gradient defines the gradient to remove
  11763. * @returns the current particle system
  11764. */
  11765. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11766. /**
  11767. * Adds a new drag gradient
  11768. * @param gradient defines the gradient to use (between 0 and 1)
  11769. * @param factor defines the drag value to affect to the specified gradient
  11770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11771. * @returns the current particle system
  11772. */
  11773. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11774. /**
  11775. * Remove a specific drag gradient
  11776. * @param gradient defines the gradient to remove
  11777. * @returns the current particle system
  11778. */
  11779. removeDragGradient(gradient: number): IParticleSystem;
  11780. /**
  11781. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11782. * @param gradient defines the gradient to use (between 0 and 1)
  11783. * @param factor defines the emit rate value to affect to the specified gradient
  11784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11785. * @returns the current particle system
  11786. */
  11787. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11788. /**
  11789. * Remove a specific emit rate gradient
  11790. * @param gradient defines the gradient to remove
  11791. * @returns the current particle system
  11792. */
  11793. removeEmitRateGradient(gradient: number): IParticleSystem;
  11794. /**
  11795. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11796. * @param gradient defines the gradient to use (between 0 and 1)
  11797. * @param factor defines the start size value to affect to the specified gradient
  11798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11799. * @returns the current particle system
  11800. */
  11801. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11802. /**
  11803. * Remove a specific start size gradient
  11804. * @param gradient defines the gradient to remove
  11805. * @returns the current particle system
  11806. */
  11807. removeStartSizeGradient(gradient: number): IParticleSystem;
  11808. private _createRampGradientTexture;
  11809. /**
  11810. * Gets the current list of ramp gradients.
  11811. * You must use addRampGradient and removeRampGradient to udpate this list
  11812. * @returns the list of ramp gradients
  11813. */
  11814. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11815. /**
  11816. * Adds a new ramp gradient used to remap particle colors
  11817. * @param gradient defines the gradient to use (between 0 and 1)
  11818. * @param color defines the color to affect to the specified gradient
  11819. * @returns the current particle system
  11820. */
  11821. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11822. /**
  11823. * Remove a specific ramp gradient
  11824. * @param gradient defines the gradient to remove
  11825. * @returns the current particle system
  11826. */
  11827. removeRampGradient(gradient: number): ParticleSystem;
  11828. /**
  11829. * Adds a new color gradient
  11830. * @param gradient defines the gradient to use (between 0 and 1)
  11831. * @param color1 defines the color to affect to the specified gradient
  11832. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11833. * @returns this particle system
  11834. */
  11835. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11836. /**
  11837. * Remove a specific color gradient
  11838. * @param gradient defines the gradient to remove
  11839. * @returns this particle system
  11840. */
  11841. removeColorGradient(gradient: number): IParticleSystem;
  11842. private _fetchR;
  11843. protected _reset(): void;
  11844. private _resetEffect;
  11845. private _createVertexBuffers;
  11846. private _createIndexBuffer;
  11847. /**
  11848. * Gets the maximum number of particles active at the same time.
  11849. * @returns The max number of active particles.
  11850. */
  11851. getCapacity(): number;
  11852. /**
  11853. * Gets whether there are still active particles in the system.
  11854. * @returns True if it is alive, otherwise false.
  11855. */
  11856. isAlive(): boolean;
  11857. /**
  11858. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11859. * @returns True if it has been started, otherwise false.
  11860. */
  11861. isStarted(): boolean;
  11862. private _prepareSubEmitterInternalArray;
  11863. /**
  11864. * Starts the particle system and begins to emit
  11865. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11866. */
  11867. start(delay?: number): void;
  11868. /**
  11869. * Stops the particle system.
  11870. * @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.
  11871. */
  11872. stop(stopSubEmitters?: boolean): void;
  11873. /**
  11874. * Remove all active particles
  11875. */
  11876. reset(): void;
  11877. /**
  11878. * @hidden (for internal use only)
  11879. */
  11880. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11881. /**
  11882. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11883. * Its lifetime will start back at 0.
  11884. */
  11885. recycleParticle: (particle: Particle) => void;
  11886. private _stopSubEmitters;
  11887. private _createParticle;
  11888. private _removeFromRoot;
  11889. private _emitFromParticle;
  11890. private _update;
  11891. /** @hidden */
  11892. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11893. /** @hidden */
  11894. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11895. /** @hidden */
  11896. private _getEffect;
  11897. /**
  11898. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11899. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11900. */
  11901. animate(preWarmOnly?: boolean): void;
  11902. private _appendParticleVertices;
  11903. /**
  11904. * Rebuilds the particle system.
  11905. */
  11906. rebuild(): void;
  11907. /**
  11908. * Is this system ready to be used/rendered
  11909. * @return true if the system is ready
  11910. */
  11911. isReady(): boolean;
  11912. private _render;
  11913. /**
  11914. * Renders the particle system in its current state.
  11915. * @returns the current number of particles
  11916. */
  11917. render(): number;
  11918. /**
  11919. * Disposes the particle system and free the associated resources
  11920. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11921. */
  11922. dispose(disposeTexture?: boolean): void;
  11923. /**
  11924. * Clones the particle system.
  11925. * @param name The name of the cloned object
  11926. * @param newEmitter The new emitter to use
  11927. * @returns the cloned particle system
  11928. */
  11929. clone(name: string, newEmitter: any): ParticleSystem;
  11930. /**
  11931. * Serializes the particle system to a JSON object.
  11932. * @returns the JSON object
  11933. */
  11934. serialize(): any;
  11935. /** @hidden */
  11936. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11937. /** @hidden */
  11938. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11939. /**
  11940. * Parses a JSON object to create a particle system.
  11941. * @param parsedParticleSystem The JSON object to parse
  11942. * @param scene The scene to create the particle system in
  11943. * @param rootUrl The root url to use to load external dependencies like texture
  11944. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11945. * @returns the Parsed particle system
  11946. */
  11947. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11948. }
  11949. }
  11950. declare module BABYLON {
  11951. /**
  11952. * A particle represents one of the element emitted by a particle system.
  11953. * This is mainly define by its coordinates, direction, velocity and age.
  11954. */
  11955. export class Particle {
  11956. /**
  11957. * The particle system the particle belongs to.
  11958. */
  11959. particleSystem: ParticleSystem;
  11960. private static _Count;
  11961. /**
  11962. * Unique ID of the particle
  11963. */
  11964. id: number;
  11965. /**
  11966. * The world position of the particle in the scene.
  11967. */
  11968. position: Vector3;
  11969. /**
  11970. * The world direction of the particle in the scene.
  11971. */
  11972. direction: Vector3;
  11973. /**
  11974. * The color of the particle.
  11975. */
  11976. color: Color4;
  11977. /**
  11978. * The color change of the particle per step.
  11979. */
  11980. colorStep: Color4;
  11981. /**
  11982. * Defines how long will the life of the particle be.
  11983. */
  11984. lifeTime: number;
  11985. /**
  11986. * The current age of the particle.
  11987. */
  11988. age: number;
  11989. /**
  11990. * The current size of the particle.
  11991. */
  11992. size: number;
  11993. /**
  11994. * The current scale of the particle.
  11995. */
  11996. scale: Vector2;
  11997. /**
  11998. * The current angle of the particle.
  11999. */
  12000. angle: number;
  12001. /**
  12002. * Defines how fast is the angle changing.
  12003. */
  12004. angularSpeed: number;
  12005. /**
  12006. * Defines the cell index used by the particle to be rendered from a sprite.
  12007. */
  12008. cellIndex: number;
  12009. /**
  12010. * The information required to support color remapping
  12011. */
  12012. remapData: Vector4;
  12013. /** @hidden */
  12014. _randomCellOffset?: number;
  12015. /** @hidden */
  12016. _initialDirection: Nullable<Vector3>;
  12017. /** @hidden */
  12018. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12019. /** @hidden */
  12020. _initialStartSpriteCellID: number;
  12021. /** @hidden */
  12022. _initialEndSpriteCellID: number;
  12023. /** @hidden */
  12024. _currentColorGradient: Nullable<ColorGradient>;
  12025. /** @hidden */
  12026. _currentColor1: Color4;
  12027. /** @hidden */
  12028. _currentColor2: Color4;
  12029. /** @hidden */
  12030. _currentSizeGradient: Nullable<FactorGradient>;
  12031. /** @hidden */
  12032. _currentSize1: number;
  12033. /** @hidden */
  12034. _currentSize2: number;
  12035. /** @hidden */
  12036. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12037. /** @hidden */
  12038. _currentAngularSpeed1: number;
  12039. /** @hidden */
  12040. _currentAngularSpeed2: number;
  12041. /** @hidden */
  12042. _currentVelocityGradient: Nullable<FactorGradient>;
  12043. /** @hidden */
  12044. _currentVelocity1: number;
  12045. /** @hidden */
  12046. _currentVelocity2: number;
  12047. /** @hidden */
  12048. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12049. /** @hidden */
  12050. _currentLimitVelocity1: number;
  12051. /** @hidden */
  12052. _currentLimitVelocity2: number;
  12053. /** @hidden */
  12054. _currentDragGradient: Nullable<FactorGradient>;
  12055. /** @hidden */
  12056. _currentDrag1: number;
  12057. /** @hidden */
  12058. _currentDrag2: number;
  12059. /** @hidden */
  12060. _randomNoiseCoordinates1: Vector3;
  12061. /** @hidden */
  12062. _randomNoiseCoordinates2: Vector3;
  12063. /** @hidden */
  12064. _localPosition?: Vector3;
  12065. /**
  12066. * Creates a new instance Particle
  12067. * @param particleSystem the particle system the particle belongs to
  12068. */
  12069. constructor(
  12070. /**
  12071. * The particle system the particle belongs to.
  12072. */
  12073. particleSystem: ParticleSystem);
  12074. private updateCellInfoFromSystem;
  12075. /**
  12076. * Defines how the sprite cell index is updated for the particle
  12077. */
  12078. updateCellIndex(): void;
  12079. /** @hidden */
  12080. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12081. /** @hidden */
  12082. _inheritParticleInfoToSubEmitters(): void;
  12083. /** @hidden */
  12084. _reset(): void;
  12085. /**
  12086. * Copy the properties of particle to another one.
  12087. * @param other the particle to copy the information to.
  12088. */
  12089. copyTo(other: Particle): void;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * Particle emitter represents a volume emitting particles.
  12095. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12096. */
  12097. export interface IParticleEmitterType {
  12098. /**
  12099. * Called by the particle System when the direction is computed for the created particle.
  12100. * @param worldMatrix is the world matrix of the particle system
  12101. * @param directionToUpdate is the direction vector to update with the result
  12102. * @param particle is the particle we are computed the direction for
  12103. * @param isLocal defines if the direction should be set in local space
  12104. */
  12105. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12106. /**
  12107. * Called by the particle System when the position is computed for the created particle.
  12108. * @param worldMatrix is the world matrix of the particle system
  12109. * @param positionToUpdate is the position vector to update with the result
  12110. * @param particle is the particle we are computed the position for
  12111. * @param isLocal defines if the position should be set in local space
  12112. */
  12113. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12114. /**
  12115. * Clones the current emitter and returns a copy of it
  12116. * @returns the new emitter
  12117. */
  12118. clone(): IParticleEmitterType;
  12119. /**
  12120. * Called by the GPUParticleSystem to setup the update shader
  12121. * @param effect defines the update shader
  12122. */
  12123. applyToShader(effect: Effect): void;
  12124. /**
  12125. * Returns a string to use to update the GPU particles update shader
  12126. * @returns the effect defines string
  12127. */
  12128. getEffectDefines(): string;
  12129. /**
  12130. * Returns a string representing the class name
  12131. * @returns a string containing the class name
  12132. */
  12133. getClassName(): string;
  12134. /**
  12135. * Serializes the particle system to a JSON object.
  12136. * @returns the JSON object
  12137. */
  12138. serialize(): any;
  12139. /**
  12140. * Parse properties from a JSON object
  12141. * @param serializationObject defines the JSON object
  12142. * @param scene defines the hosting scene
  12143. */
  12144. parse(serializationObject: any, scene: Scene): void;
  12145. }
  12146. }
  12147. declare module BABYLON {
  12148. /**
  12149. * Particle emitter emitting particles from the inside of a box.
  12150. * It emits the particles randomly between 2 given directions.
  12151. */
  12152. export class BoxParticleEmitter implements IParticleEmitterType {
  12153. /**
  12154. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12155. */
  12156. direction1: Vector3;
  12157. /**
  12158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12159. */
  12160. direction2: Vector3;
  12161. /**
  12162. * 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.
  12163. */
  12164. minEmitBox: Vector3;
  12165. /**
  12166. * 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.
  12167. */
  12168. maxEmitBox: Vector3;
  12169. /**
  12170. * Creates a new instance BoxParticleEmitter
  12171. */
  12172. constructor();
  12173. /**
  12174. * Called by the particle System when the direction is computed for the created particle.
  12175. * @param worldMatrix is the world matrix of the particle system
  12176. * @param directionToUpdate is the direction vector to update with the result
  12177. * @param particle is the particle we are computed the direction for
  12178. * @param isLocal defines if the direction should be set in local space
  12179. */
  12180. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12181. /**
  12182. * Called by the particle System when the position is computed for the created particle.
  12183. * @param worldMatrix is the world matrix of the particle system
  12184. * @param positionToUpdate is the position vector to update with the result
  12185. * @param particle is the particle we are computed the position for
  12186. * @param isLocal defines if the position should be set in local space
  12187. */
  12188. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12189. /**
  12190. * Clones the current emitter and returns a copy of it
  12191. * @returns the new emitter
  12192. */
  12193. clone(): BoxParticleEmitter;
  12194. /**
  12195. * Called by the GPUParticleSystem to setup the update shader
  12196. * @param effect defines the update shader
  12197. */
  12198. applyToShader(effect: Effect): void;
  12199. /**
  12200. * Returns a string to use to update the GPU particles update shader
  12201. * @returns a string containng the defines string
  12202. */
  12203. getEffectDefines(): string;
  12204. /**
  12205. * Returns the string "BoxParticleEmitter"
  12206. * @returns a string containing the class name
  12207. */
  12208. getClassName(): string;
  12209. /**
  12210. * Serializes the particle system to a JSON object.
  12211. * @returns the JSON object
  12212. */
  12213. serialize(): any;
  12214. /**
  12215. * Parse properties from a JSON object
  12216. * @param serializationObject defines the JSON object
  12217. */
  12218. parse(serializationObject: any): void;
  12219. }
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * Particle emitter emitting particles from the inside of a cone.
  12224. * It emits the particles alongside the cone volume from the base to the particle.
  12225. * The emission direction might be randomized.
  12226. */
  12227. export class ConeParticleEmitter implements IParticleEmitterType {
  12228. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12229. directionRandomizer: number;
  12230. private _radius;
  12231. private _angle;
  12232. private _height;
  12233. /**
  12234. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12235. */
  12236. radiusRange: number;
  12237. /**
  12238. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12239. */
  12240. heightRange: number;
  12241. /**
  12242. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12243. */
  12244. emitFromSpawnPointOnly: boolean;
  12245. /**
  12246. * Gets or sets the radius of the emission cone
  12247. */
  12248. get radius(): number;
  12249. set radius(value: number);
  12250. /**
  12251. * Gets or sets the angle of the emission cone
  12252. */
  12253. get angle(): number;
  12254. set angle(value: number);
  12255. private _buildHeight;
  12256. /**
  12257. * Creates a new instance ConeParticleEmitter
  12258. * @param radius the radius of the emission cone (1 by default)
  12259. * @param angle the cone base angle (PI by default)
  12260. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12261. */
  12262. constructor(radius?: number, angle?: number,
  12263. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12264. directionRandomizer?: number);
  12265. /**
  12266. * Called by the particle System when the direction is computed for the created particle.
  12267. * @param worldMatrix is the world matrix of the particle system
  12268. * @param directionToUpdate is the direction vector to update with the result
  12269. * @param particle is the particle we are computed the direction for
  12270. * @param isLocal defines if the direction should be set in local space
  12271. */
  12272. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12273. /**
  12274. * Called by the particle System when the position is computed for the created particle.
  12275. * @param worldMatrix is the world matrix of the particle system
  12276. * @param positionToUpdate is the position vector to update with the result
  12277. * @param particle is the particle we are computed the position for
  12278. * @param isLocal defines if the position should be set in local space
  12279. */
  12280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12281. /**
  12282. * Clones the current emitter and returns a copy of it
  12283. * @returns the new emitter
  12284. */
  12285. clone(): ConeParticleEmitter;
  12286. /**
  12287. * Called by the GPUParticleSystem to setup the update shader
  12288. * @param effect defines the update shader
  12289. */
  12290. applyToShader(effect: Effect): void;
  12291. /**
  12292. * Returns a string to use to update the GPU particles update shader
  12293. * @returns a string containng the defines string
  12294. */
  12295. getEffectDefines(): string;
  12296. /**
  12297. * Returns the string "ConeParticleEmitter"
  12298. * @returns a string containing the class name
  12299. */
  12300. getClassName(): string;
  12301. /**
  12302. * Serializes the particle system to a JSON object.
  12303. * @returns the JSON object
  12304. */
  12305. serialize(): any;
  12306. /**
  12307. * Parse properties from a JSON object
  12308. * @param serializationObject defines the JSON object
  12309. */
  12310. parse(serializationObject: any): void;
  12311. }
  12312. }
  12313. declare module BABYLON {
  12314. /**
  12315. * Particle emitter emitting particles from the inside of a cylinder.
  12316. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12317. */
  12318. export class CylinderParticleEmitter implements IParticleEmitterType {
  12319. /**
  12320. * The radius of the emission cylinder.
  12321. */
  12322. radius: number;
  12323. /**
  12324. * The height of the emission cylinder.
  12325. */
  12326. height: number;
  12327. /**
  12328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12329. */
  12330. radiusRange: number;
  12331. /**
  12332. * How much to randomize the particle direction [0-1].
  12333. */
  12334. directionRandomizer: number;
  12335. /**
  12336. * Creates a new instance CylinderParticleEmitter
  12337. * @param radius the radius of the emission cylinder (1 by default)
  12338. * @param height the height of the emission cylinder (1 by default)
  12339. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12340. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12341. */
  12342. constructor(
  12343. /**
  12344. * The radius of the emission cylinder.
  12345. */
  12346. radius?: number,
  12347. /**
  12348. * The height of the emission cylinder.
  12349. */
  12350. height?: number,
  12351. /**
  12352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12353. */
  12354. radiusRange?: number,
  12355. /**
  12356. * How much to randomize the particle direction [0-1].
  12357. */
  12358. directionRandomizer?: number);
  12359. /**
  12360. * Called by the particle System when the direction is computed for the created particle.
  12361. * @param worldMatrix is the world matrix of the particle system
  12362. * @param directionToUpdate is the direction vector to update with the result
  12363. * @param particle is the particle we are computed the direction for
  12364. * @param isLocal defines if the direction should be set in local space
  12365. */
  12366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12367. /**
  12368. * Called by the particle System when the position is computed for the created particle.
  12369. * @param worldMatrix is the world matrix of the particle system
  12370. * @param positionToUpdate is the position vector to update with the result
  12371. * @param particle is the particle we are computed the position for
  12372. * @param isLocal defines if the position should be set in local space
  12373. */
  12374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12375. /**
  12376. * Clones the current emitter and returns a copy of it
  12377. * @returns the new emitter
  12378. */
  12379. clone(): CylinderParticleEmitter;
  12380. /**
  12381. * Called by the GPUParticleSystem to setup the update shader
  12382. * @param effect defines the update shader
  12383. */
  12384. applyToShader(effect: Effect): void;
  12385. /**
  12386. * Returns a string to use to update the GPU particles update shader
  12387. * @returns a string containng the defines string
  12388. */
  12389. getEffectDefines(): string;
  12390. /**
  12391. * Returns the string "CylinderParticleEmitter"
  12392. * @returns a string containing the class name
  12393. */
  12394. getClassName(): string;
  12395. /**
  12396. * Serializes the particle system to a JSON object.
  12397. * @returns the JSON object
  12398. */
  12399. serialize(): any;
  12400. /**
  12401. * Parse properties from a JSON object
  12402. * @param serializationObject defines the JSON object
  12403. */
  12404. parse(serializationObject: any): void;
  12405. }
  12406. /**
  12407. * Particle emitter emitting particles from the inside of a cylinder.
  12408. * It emits the particles randomly between two vectors.
  12409. */
  12410. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12411. /**
  12412. * The min limit of the emission direction.
  12413. */
  12414. direction1: Vector3;
  12415. /**
  12416. * The max limit of the emission direction.
  12417. */
  12418. direction2: Vector3;
  12419. /**
  12420. * Creates a new instance CylinderDirectedParticleEmitter
  12421. * @param radius the radius of the emission cylinder (1 by default)
  12422. * @param height the height of the emission cylinder (1 by default)
  12423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12424. * @param direction1 the min limit of the emission direction (up vector by default)
  12425. * @param direction2 the max limit of the emission direction (up vector by default)
  12426. */
  12427. constructor(radius?: number, height?: number, radiusRange?: number,
  12428. /**
  12429. * The min limit of the emission direction.
  12430. */
  12431. direction1?: Vector3,
  12432. /**
  12433. * The max limit of the emission direction.
  12434. */
  12435. direction2?: Vector3);
  12436. /**
  12437. * Called by the particle System when the direction is computed for the created particle.
  12438. * @param worldMatrix is the world matrix of the particle system
  12439. * @param directionToUpdate is the direction vector to update with the result
  12440. * @param particle is the particle we are computed the direction for
  12441. */
  12442. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12443. /**
  12444. * Clones the current emitter and returns a copy of it
  12445. * @returns the new emitter
  12446. */
  12447. clone(): CylinderDirectedParticleEmitter;
  12448. /**
  12449. * Called by the GPUParticleSystem to setup the update shader
  12450. * @param effect defines the update shader
  12451. */
  12452. applyToShader(effect: Effect): void;
  12453. /**
  12454. * Returns a string to use to update the GPU particles update shader
  12455. * @returns a string containng the defines string
  12456. */
  12457. getEffectDefines(): string;
  12458. /**
  12459. * Returns the string "CylinderDirectedParticleEmitter"
  12460. * @returns a string containing the class name
  12461. */
  12462. getClassName(): string;
  12463. /**
  12464. * Serializes the particle system to a JSON object.
  12465. * @returns the JSON object
  12466. */
  12467. serialize(): any;
  12468. /**
  12469. * Parse properties from a JSON object
  12470. * @param serializationObject defines the JSON object
  12471. */
  12472. parse(serializationObject: any): void;
  12473. }
  12474. }
  12475. declare module BABYLON {
  12476. /**
  12477. * Particle emitter emitting particles from the inside of a hemisphere.
  12478. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12479. */
  12480. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12481. /**
  12482. * The radius of the emission hemisphere.
  12483. */
  12484. radius: number;
  12485. /**
  12486. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12487. */
  12488. radiusRange: number;
  12489. /**
  12490. * How much to randomize the particle direction [0-1].
  12491. */
  12492. directionRandomizer: number;
  12493. /**
  12494. * Creates a new instance HemisphericParticleEmitter
  12495. * @param radius the radius of the emission hemisphere (1 by default)
  12496. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12498. */
  12499. constructor(
  12500. /**
  12501. * The radius of the emission hemisphere.
  12502. */
  12503. radius?: number,
  12504. /**
  12505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12506. */
  12507. radiusRange?: number,
  12508. /**
  12509. * How much to randomize the particle direction [0-1].
  12510. */
  12511. directionRandomizer?: number);
  12512. /**
  12513. * Called by the particle System when the direction is computed for the created particle.
  12514. * @param worldMatrix is the world matrix of the particle system
  12515. * @param directionToUpdate is the direction vector to update with the result
  12516. * @param particle is the particle we are computed the direction for
  12517. * @param isLocal defines if the direction should be set in local space
  12518. */
  12519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12520. /**
  12521. * Called by the particle System when the position is computed for the created particle.
  12522. * @param worldMatrix is the world matrix of the particle system
  12523. * @param positionToUpdate is the position vector to update with the result
  12524. * @param particle is the particle we are computed the position for
  12525. * @param isLocal defines if the position should be set in local space
  12526. */
  12527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12528. /**
  12529. * Clones the current emitter and returns a copy of it
  12530. * @returns the new emitter
  12531. */
  12532. clone(): HemisphericParticleEmitter;
  12533. /**
  12534. * Called by the GPUParticleSystem to setup the update shader
  12535. * @param effect defines the update shader
  12536. */
  12537. applyToShader(effect: Effect): void;
  12538. /**
  12539. * Returns a string to use to update the GPU particles update shader
  12540. * @returns a string containng the defines string
  12541. */
  12542. getEffectDefines(): string;
  12543. /**
  12544. * Returns the string "HemisphericParticleEmitter"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Serializes the particle system to a JSON object.
  12550. * @returns the JSON object
  12551. */
  12552. serialize(): any;
  12553. /**
  12554. * Parse properties from a JSON object
  12555. * @param serializationObject defines the JSON object
  12556. */
  12557. parse(serializationObject: any): void;
  12558. }
  12559. }
  12560. declare module BABYLON {
  12561. /**
  12562. * Particle emitter emitting particles from a point.
  12563. * It emits the particles randomly between 2 given directions.
  12564. */
  12565. export class PointParticleEmitter implements IParticleEmitterType {
  12566. /**
  12567. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12568. */
  12569. direction1: Vector3;
  12570. /**
  12571. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12572. */
  12573. direction2: Vector3;
  12574. /**
  12575. * Creates a new instance PointParticleEmitter
  12576. */
  12577. constructor();
  12578. /**
  12579. * Called by the particle System when the direction is computed for the created particle.
  12580. * @param worldMatrix is the world matrix of the particle system
  12581. * @param directionToUpdate is the direction vector to update with the result
  12582. * @param particle is the particle we are computed the direction for
  12583. * @param isLocal defines if the direction should be set in local space
  12584. */
  12585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12586. /**
  12587. * Called by the particle System when the position is computed for the created particle.
  12588. * @param worldMatrix is the world matrix of the particle system
  12589. * @param positionToUpdate is the position vector to update with the result
  12590. * @param particle is the particle we are computed the position for
  12591. * @param isLocal defines if the position should be set in local space
  12592. */
  12593. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12594. /**
  12595. * Clones the current emitter and returns a copy of it
  12596. * @returns the new emitter
  12597. */
  12598. clone(): PointParticleEmitter;
  12599. /**
  12600. * Called by the GPUParticleSystem to setup the update shader
  12601. * @param effect defines the update shader
  12602. */
  12603. applyToShader(effect: Effect): void;
  12604. /**
  12605. * Returns a string to use to update the GPU particles update shader
  12606. * @returns a string containng the defines string
  12607. */
  12608. getEffectDefines(): string;
  12609. /**
  12610. * Returns the string "PointParticleEmitter"
  12611. * @returns a string containing the class name
  12612. */
  12613. getClassName(): string;
  12614. /**
  12615. * Serializes the particle system to a JSON object.
  12616. * @returns the JSON object
  12617. */
  12618. serialize(): any;
  12619. /**
  12620. * Parse properties from a JSON object
  12621. * @param serializationObject defines the JSON object
  12622. */
  12623. parse(serializationObject: any): void;
  12624. }
  12625. }
  12626. declare module BABYLON {
  12627. /**
  12628. * Particle emitter emitting particles from the inside of a sphere.
  12629. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12630. */
  12631. export class SphereParticleEmitter implements IParticleEmitterType {
  12632. /**
  12633. * The radius of the emission sphere.
  12634. */
  12635. radius: number;
  12636. /**
  12637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12638. */
  12639. radiusRange: number;
  12640. /**
  12641. * How much to randomize the particle direction [0-1].
  12642. */
  12643. directionRandomizer: number;
  12644. /**
  12645. * Creates a new instance SphereParticleEmitter
  12646. * @param radius the radius of the emission sphere (1 by default)
  12647. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12649. */
  12650. constructor(
  12651. /**
  12652. * The radius of the emission sphere.
  12653. */
  12654. radius?: number,
  12655. /**
  12656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12657. */
  12658. radiusRange?: number,
  12659. /**
  12660. * How much to randomize the particle direction [0-1].
  12661. */
  12662. directionRandomizer?: number);
  12663. /**
  12664. * Called by the particle System when the direction is computed for the created particle.
  12665. * @param worldMatrix is the world matrix of the particle system
  12666. * @param directionToUpdate is the direction vector to update with the result
  12667. * @param particle is the particle we are computed the direction for
  12668. * @param isLocal defines if the direction should be set in local space
  12669. */
  12670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12671. /**
  12672. * Called by the particle System when the position is computed for the created particle.
  12673. * @param worldMatrix is the world matrix of the particle system
  12674. * @param positionToUpdate is the position vector to update with the result
  12675. * @param particle is the particle we are computed the position for
  12676. * @param isLocal defines if the position should be set in local space
  12677. */
  12678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12679. /**
  12680. * Clones the current emitter and returns a copy of it
  12681. * @returns the new emitter
  12682. */
  12683. clone(): SphereParticleEmitter;
  12684. /**
  12685. * Called by the GPUParticleSystem to setup the update shader
  12686. * @param effect defines the update shader
  12687. */
  12688. applyToShader(effect: Effect): void;
  12689. /**
  12690. * Returns a string to use to update the GPU particles update shader
  12691. * @returns a string containng the defines string
  12692. */
  12693. getEffectDefines(): string;
  12694. /**
  12695. * Returns the string "SphereParticleEmitter"
  12696. * @returns a string containing the class name
  12697. */
  12698. getClassName(): string;
  12699. /**
  12700. * Serializes the particle system to a JSON object.
  12701. * @returns the JSON object
  12702. */
  12703. serialize(): any;
  12704. /**
  12705. * Parse properties from a JSON object
  12706. * @param serializationObject defines the JSON object
  12707. */
  12708. parse(serializationObject: any): void;
  12709. }
  12710. /**
  12711. * Particle emitter emitting particles from the inside of a sphere.
  12712. * It emits the particles randomly between two vectors.
  12713. */
  12714. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12715. /**
  12716. * The min limit of the emission direction.
  12717. */
  12718. direction1: Vector3;
  12719. /**
  12720. * The max limit of the emission direction.
  12721. */
  12722. direction2: Vector3;
  12723. /**
  12724. * Creates a new instance SphereDirectedParticleEmitter
  12725. * @param radius the radius of the emission sphere (1 by default)
  12726. * @param direction1 the min limit of the emission direction (up vector by default)
  12727. * @param direction2 the max limit of the emission direction (up vector by default)
  12728. */
  12729. constructor(radius?: number,
  12730. /**
  12731. * The min limit of the emission direction.
  12732. */
  12733. direction1?: Vector3,
  12734. /**
  12735. * The max limit of the emission direction.
  12736. */
  12737. direction2?: Vector3);
  12738. /**
  12739. * Called by the particle System when the direction is computed for the created particle.
  12740. * @param worldMatrix is the world matrix of the particle system
  12741. * @param directionToUpdate is the direction vector to update with the result
  12742. * @param particle is the particle we are computed the direction for
  12743. */
  12744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12745. /**
  12746. * Clones the current emitter and returns a copy of it
  12747. * @returns the new emitter
  12748. */
  12749. clone(): SphereDirectedParticleEmitter;
  12750. /**
  12751. * Called by the GPUParticleSystem to setup the update shader
  12752. * @param effect defines the update shader
  12753. */
  12754. applyToShader(effect: Effect): void;
  12755. /**
  12756. * Returns a string to use to update the GPU particles update shader
  12757. * @returns a string containng the defines string
  12758. */
  12759. getEffectDefines(): string;
  12760. /**
  12761. * Returns the string "SphereDirectedParticleEmitter"
  12762. * @returns a string containing the class name
  12763. */
  12764. getClassName(): string;
  12765. /**
  12766. * Serializes the particle system to a JSON object.
  12767. * @returns the JSON object
  12768. */
  12769. serialize(): any;
  12770. /**
  12771. * Parse properties from a JSON object
  12772. * @param serializationObject defines the JSON object
  12773. */
  12774. parse(serializationObject: any): void;
  12775. }
  12776. }
  12777. declare module BABYLON {
  12778. /**
  12779. * Particle emitter emitting particles from a custom list of positions.
  12780. */
  12781. export class CustomParticleEmitter implements IParticleEmitterType {
  12782. /**
  12783. * Gets or sets the position generator that will create the inital position of each particle.
  12784. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12785. */
  12786. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12787. /**
  12788. * Gets or sets the destination generator that will create the final destination of each particle.
  12789. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12790. */
  12791. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12792. /**
  12793. * Creates a new instance CustomParticleEmitter
  12794. */
  12795. constructor();
  12796. /**
  12797. * Called by the particle System when the direction is computed for the created particle.
  12798. * @param worldMatrix is the world matrix of the particle system
  12799. * @param directionToUpdate is the direction vector to update with the result
  12800. * @param particle is the particle we are computed the direction for
  12801. * @param isLocal defines if the direction should be set in local space
  12802. */
  12803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12804. /**
  12805. * Called by the particle System when the position is computed for the created particle.
  12806. * @param worldMatrix is the world matrix of the particle system
  12807. * @param positionToUpdate is the position vector to update with the result
  12808. * @param particle is the particle we are computed the position for
  12809. * @param isLocal defines if the position should be set in local space
  12810. */
  12811. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12812. /**
  12813. * Clones the current emitter and returns a copy of it
  12814. * @returns the new emitter
  12815. */
  12816. clone(): CustomParticleEmitter;
  12817. /**
  12818. * Called by the GPUParticleSystem to setup the update shader
  12819. * @param effect defines the update shader
  12820. */
  12821. applyToShader(effect: Effect): void;
  12822. /**
  12823. * Returns a string to use to update the GPU particles update shader
  12824. * @returns a string containng the defines string
  12825. */
  12826. getEffectDefines(): string;
  12827. /**
  12828. * Returns the string "PointParticleEmitter"
  12829. * @returns a string containing the class name
  12830. */
  12831. getClassName(): string;
  12832. /**
  12833. * Serializes the particle system to a JSON object.
  12834. * @returns the JSON object
  12835. */
  12836. serialize(): any;
  12837. /**
  12838. * Parse properties from a JSON object
  12839. * @param serializationObject defines the JSON object
  12840. */
  12841. parse(serializationObject: any): void;
  12842. }
  12843. }
  12844. declare module BABYLON {
  12845. /**
  12846. * Particle emitter emitting particles from the inside of a box.
  12847. * It emits the particles randomly between 2 given directions.
  12848. */
  12849. export class MeshParticleEmitter implements IParticleEmitterType {
  12850. private _indices;
  12851. private _positions;
  12852. private _normals;
  12853. private _storedNormal;
  12854. private _mesh;
  12855. /**
  12856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12857. */
  12858. direction1: Vector3;
  12859. /**
  12860. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12861. */
  12862. direction2: Vector3;
  12863. /**
  12864. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12865. */
  12866. useMeshNormalsForDirection: boolean;
  12867. /** Defines the mesh to use as source */
  12868. get mesh(): Nullable<AbstractMesh>;
  12869. set mesh(value: Nullable<AbstractMesh>);
  12870. /**
  12871. * Creates a new instance MeshParticleEmitter
  12872. * @param mesh defines the mesh to use as source
  12873. */
  12874. constructor(mesh?: Nullable<AbstractMesh>);
  12875. /**
  12876. * Called by the particle System when the direction is computed for the created particle.
  12877. * @param worldMatrix is the world matrix of the particle system
  12878. * @param directionToUpdate is the direction vector to update with the result
  12879. * @param particle is the particle we are computed the direction for
  12880. * @param isLocal defines if the direction should be set in local space
  12881. */
  12882. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12883. /**
  12884. * Called by the particle System when the position is computed for the created particle.
  12885. * @param worldMatrix is the world matrix of the particle system
  12886. * @param positionToUpdate is the position vector to update with the result
  12887. * @param particle is the particle we are computed the position for
  12888. * @param isLocal defines if the position should be set in local space
  12889. */
  12890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12891. /**
  12892. * Clones the current emitter and returns a copy of it
  12893. * @returns the new emitter
  12894. */
  12895. clone(): MeshParticleEmitter;
  12896. /**
  12897. * Called by the GPUParticleSystem to setup the update shader
  12898. * @param effect defines the update shader
  12899. */
  12900. applyToShader(effect: Effect): void;
  12901. /**
  12902. * Returns a string to use to update the GPU particles update shader
  12903. * @returns a string containng the defines string
  12904. */
  12905. getEffectDefines(): string;
  12906. /**
  12907. * Returns the string "BoxParticleEmitter"
  12908. * @returns a string containing the class name
  12909. */
  12910. getClassName(): string;
  12911. /**
  12912. * Serializes the particle system to a JSON object.
  12913. * @returns the JSON object
  12914. */
  12915. serialize(): any;
  12916. /**
  12917. * Parse properties from a JSON object
  12918. * @param serializationObject defines the JSON object
  12919. * @param scene defines the hosting scene
  12920. */
  12921. parse(serializationObject: any, scene: Scene): void;
  12922. }
  12923. }
  12924. declare module BABYLON {
  12925. /**
  12926. * Interface representing a particle system in Babylon.js.
  12927. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12928. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12929. */
  12930. export interface IParticleSystem {
  12931. /**
  12932. * List of animations used by the particle system.
  12933. */
  12934. animations: Animation[];
  12935. /**
  12936. * The id of the Particle system.
  12937. */
  12938. id: string;
  12939. /**
  12940. * The name of the Particle system.
  12941. */
  12942. name: string;
  12943. /**
  12944. * The emitter represents the Mesh or position we are attaching the particle system to.
  12945. */
  12946. emitter: Nullable<AbstractMesh | Vector3>;
  12947. /**
  12948. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12949. */
  12950. isBillboardBased: boolean;
  12951. /**
  12952. * The rendering group used by the Particle system to chose when to render.
  12953. */
  12954. renderingGroupId: number;
  12955. /**
  12956. * The layer mask we are rendering the particles through.
  12957. */
  12958. layerMask: number;
  12959. /**
  12960. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12961. */
  12962. updateSpeed: number;
  12963. /**
  12964. * The amount of time the particle system is running (depends of the overall update speed).
  12965. */
  12966. targetStopDuration: number;
  12967. /**
  12968. * The texture used to render each particle. (this can be a spritesheet)
  12969. */
  12970. particleTexture: Nullable<Texture>;
  12971. /**
  12972. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12973. */
  12974. blendMode: number;
  12975. /**
  12976. * Minimum life time of emitting particles.
  12977. */
  12978. minLifeTime: number;
  12979. /**
  12980. * Maximum life time of emitting particles.
  12981. */
  12982. maxLifeTime: number;
  12983. /**
  12984. * Minimum Size of emitting particles.
  12985. */
  12986. minSize: number;
  12987. /**
  12988. * Maximum Size of emitting particles.
  12989. */
  12990. maxSize: number;
  12991. /**
  12992. * Minimum scale of emitting particles on X axis.
  12993. */
  12994. minScaleX: number;
  12995. /**
  12996. * Maximum scale of emitting particles on X axis.
  12997. */
  12998. maxScaleX: number;
  12999. /**
  13000. * Minimum scale of emitting particles on Y axis.
  13001. */
  13002. minScaleY: number;
  13003. /**
  13004. * Maximum scale of emitting particles on Y axis.
  13005. */
  13006. maxScaleY: number;
  13007. /**
  13008. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13009. */
  13010. color1: Color4;
  13011. /**
  13012. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13013. */
  13014. color2: Color4;
  13015. /**
  13016. * Color the particle will have at the end of its lifetime.
  13017. */
  13018. colorDead: Color4;
  13019. /**
  13020. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13021. */
  13022. emitRate: number;
  13023. /**
  13024. * You can use gravity if you want to give an orientation to your particles.
  13025. */
  13026. gravity: Vector3;
  13027. /**
  13028. * Minimum power of emitting particles.
  13029. */
  13030. minEmitPower: number;
  13031. /**
  13032. * Maximum power of emitting particles.
  13033. */
  13034. maxEmitPower: number;
  13035. /**
  13036. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13037. */
  13038. minAngularSpeed: number;
  13039. /**
  13040. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13041. */
  13042. maxAngularSpeed: number;
  13043. /**
  13044. * Gets or sets the minimal initial rotation in radians.
  13045. */
  13046. minInitialRotation: number;
  13047. /**
  13048. * Gets or sets the maximal initial rotation in radians.
  13049. */
  13050. maxInitialRotation: number;
  13051. /**
  13052. * The particle emitter type defines the emitter used by the particle system.
  13053. * It can be for example box, sphere, or cone...
  13054. */
  13055. particleEmitterType: Nullable<IParticleEmitterType>;
  13056. /**
  13057. * Defines the delay in milliseconds before starting the system (0 by default)
  13058. */
  13059. startDelay: number;
  13060. /**
  13061. * 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
  13062. */
  13063. preWarmCycles: number;
  13064. /**
  13065. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13066. */
  13067. preWarmStepOffset: number;
  13068. /**
  13069. * 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)
  13070. */
  13071. spriteCellChangeSpeed: number;
  13072. /**
  13073. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13074. */
  13075. startSpriteCellID: number;
  13076. /**
  13077. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13078. */
  13079. endSpriteCellID: number;
  13080. /**
  13081. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13082. */
  13083. spriteCellWidth: number;
  13084. /**
  13085. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13086. */
  13087. spriteCellHeight: number;
  13088. /**
  13089. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13090. */
  13091. spriteRandomStartCell: boolean;
  13092. /**
  13093. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13094. */
  13095. isAnimationSheetEnabled: boolean;
  13096. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13097. translationPivot: Vector2;
  13098. /**
  13099. * Gets or sets a texture used to add random noise to particle positions
  13100. */
  13101. noiseTexture: Nullable<BaseTexture>;
  13102. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13103. noiseStrength: Vector3;
  13104. /**
  13105. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13106. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13107. */
  13108. billboardMode: number;
  13109. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13110. limitVelocityDamping: number;
  13111. /**
  13112. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13113. */
  13114. beginAnimationOnStart: boolean;
  13115. /**
  13116. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13117. */
  13118. beginAnimationFrom: number;
  13119. /**
  13120. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13121. */
  13122. beginAnimationTo: number;
  13123. /**
  13124. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13125. */
  13126. beginAnimationLoop: boolean;
  13127. /**
  13128. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13129. */
  13130. disposeOnStop: boolean;
  13131. /**
  13132. * Specifies if the particles are updated in emitter local space or world space
  13133. */
  13134. isLocal: boolean;
  13135. /**
  13136. * Gets the maximum number of particles active at the same time.
  13137. * @returns The max number of active particles.
  13138. */
  13139. getCapacity(): number;
  13140. /**
  13141. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13142. * @returns True if it has been started, otherwise false.
  13143. */
  13144. isStarted(): boolean;
  13145. /**
  13146. * Animates the particle system for this frame.
  13147. */
  13148. animate(): void;
  13149. /**
  13150. * Renders the particle system in its current state.
  13151. * @returns the current number of particles
  13152. */
  13153. render(): number;
  13154. /**
  13155. * Dispose the particle system and frees its associated resources.
  13156. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13157. */
  13158. dispose(disposeTexture?: boolean): void;
  13159. /**
  13160. * Clones the particle system.
  13161. * @param name The name of the cloned object
  13162. * @param newEmitter The new emitter to use
  13163. * @returns the cloned particle system
  13164. */
  13165. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13166. /**
  13167. * Serializes the particle system to a JSON object.
  13168. * @returns the JSON object
  13169. */
  13170. serialize(): any;
  13171. /**
  13172. * Rebuild the particle system
  13173. */
  13174. rebuild(): void;
  13175. /**
  13176. * Starts the particle system and begins to emit
  13177. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13178. */
  13179. start(delay?: number): void;
  13180. /**
  13181. * Stops the particle system.
  13182. */
  13183. stop(): void;
  13184. /**
  13185. * Remove all active particles
  13186. */
  13187. reset(): void;
  13188. /**
  13189. * Is this system ready to be used/rendered
  13190. * @return true if the system is ready
  13191. */
  13192. isReady(): boolean;
  13193. /**
  13194. * Returns the string "ParticleSystem"
  13195. * @returns a string containing the class name
  13196. */
  13197. getClassName(): string;
  13198. /**
  13199. * Adds a new color gradient
  13200. * @param gradient defines the gradient to use (between 0 and 1)
  13201. * @param color1 defines the color to affect to the specified gradient
  13202. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13203. * @returns the current particle system
  13204. */
  13205. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13206. /**
  13207. * Remove a specific color gradient
  13208. * @param gradient defines the gradient to remove
  13209. * @returns the current particle system
  13210. */
  13211. removeColorGradient(gradient: number): IParticleSystem;
  13212. /**
  13213. * Adds a new size gradient
  13214. * @param gradient defines the gradient to use (between 0 and 1)
  13215. * @param factor defines the size factor to affect to the specified gradient
  13216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13217. * @returns the current particle system
  13218. */
  13219. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13220. /**
  13221. * Remove a specific size gradient
  13222. * @param gradient defines the gradient to remove
  13223. * @returns the current particle system
  13224. */
  13225. removeSizeGradient(gradient: number): IParticleSystem;
  13226. /**
  13227. * Gets the current list of color gradients.
  13228. * You must use addColorGradient and removeColorGradient to udpate this list
  13229. * @returns the list of color gradients
  13230. */
  13231. getColorGradients(): Nullable<Array<ColorGradient>>;
  13232. /**
  13233. * Gets the current list of size gradients.
  13234. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13235. * @returns the list of size gradients
  13236. */
  13237. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13238. /**
  13239. * Gets the current list of angular speed gradients.
  13240. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13241. * @returns the list of angular speed gradients
  13242. */
  13243. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13244. /**
  13245. * Adds a new angular speed gradient
  13246. * @param gradient defines the gradient to use (between 0 and 1)
  13247. * @param factor defines the angular speed to affect to the specified gradient
  13248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13249. * @returns the current particle system
  13250. */
  13251. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13252. /**
  13253. * Remove a specific angular speed gradient
  13254. * @param gradient defines the gradient to remove
  13255. * @returns the current particle system
  13256. */
  13257. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13258. /**
  13259. * Gets the current list of velocity gradients.
  13260. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13261. * @returns the list of velocity gradients
  13262. */
  13263. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13264. /**
  13265. * Adds a new velocity gradient
  13266. * @param gradient defines the gradient to use (between 0 and 1)
  13267. * @param factor defines the velocity to affect to the specified gradient
  13268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13269. * @returns the current particle system
  13270. */
  13271. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13272. /**
  13273. * Remove a specific velocity gradient
  13274. * @param gradient defines the gradient to remove
  13275. * @returns the current particle system
  13276. */
  13277. removeVelocityGradient(gradient: number): IParticleSystem;
  13278. /**
  13279. * Gets the current list of limit velocity gradients.
  13280. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13281. * @returns the list of limit velocity gradients
  13282. */
  13283. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13284. /**
  13285. * Adds a new limit velocity gradient
  13286. * @param gradient defines the gradient to use (between 0 and 1)
  13287. * @param factor defines the limit velocity to affect to the specified gradient
  13288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13289. * @returns the current particle system
  13290. */
  13291. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13292. /**
  13293. * Remove a specific limit velocity gradient
  13294. * @param gradient defines the gradient to remove
  13295. * @returns the current particle system
  13296. */
  13297. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13298. /**
  13299. * Adds a new drag gradient
  13300. * @param gradient defines the gradient to use (between 0 and 1)
  13301. * @param factor defines the drag to affect to the specified gradient
  13302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13303. * @returns the current particle system
  13304. */
  13305. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13306. /**
  13307. * Remove a specific drag gradient
  13308. * @param gradient defines the gradient to remove
  13309. * @returns the current particle system
  13310. */
  13311. removeDragGradient(gradient: number): IParticleSystem;
  13312. /**
  13313. * Gets the current list of drag gradients.
  13314. * You must use addDragGradient and removeDragGradient to udpate this list
  13315. * @returns the list of drag gradients
  13316. */
  13317. getDragGradients(): Nullable<Array<FactorGradient>>;
  13318. /**
  13319. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13320. * @param gradient defines the gradient to use (between 0 and 1)
  13321. * @param factor defines the emit rate to affect to the specified gradient
  13322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13323. * @returns the current particle system
  13324. */
  13325. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13326. /**
  13327. * Remove a specific emit rate gradient
  13328. * @param gradient defines the gradient to remove
  13329. * @returns the current particle system
  13330. */
  13331. removeEmitRateGradient(gradient: number): IParticleSystem;
  13332. /**
  13333. * Gets the current list of emit rate gradients.
  13334. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13335. * @returns the list of emit rate gradients
  13336. */
  13337. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13338. /**
  13339. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13340. * @param gradient defines the gradient to use (between 0 and 1)
  13341. * @param factor defines the start size to affect to the specified gradient
  13342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13343. * @returns the current particle system
  13344. */
  13345. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13346. /**
  13347. * Remove a specific start size gradient
  13348. * @param gradient defines the gradient to remove
  13349. * @returns the current particle system
  13350. */
  13351. removeStartSizeGradient(gradient: number): IParticleSystem;
  13352. /**
  13353. * Gets the current list of start size gradients.
  13354. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13355. * @returns the list of start size gradients
  13356. */
  13357. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13358. /**
  13359. * Adds a new life time gradient
  13360. * @param gradient defines the gradient to use (between 0 and 1)
  13361. * @param factor defines the life time factor to affect to the specified gradient
  13362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13363. * @returns the current particle system
  13364. */
  13365. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13366. /**
  13367. * Remove a specific life time gradient
  13368. * @param gradient defines the gradient to remove
  13369. * @returns the current particle system
  13370. */
  13371. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13372. /**
  13373. * Gets the current list of life time gradients.
  13374. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13375. * @returns the list of life time gradients
  13376. */
  13377. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13378. /**
  13379. * Gets the current list of color gradients.
  13380. * You must use addColorGradient and removeColorGradient to udpate this list
  13381. * @returns the list of color gradients
  13382. */
  13383. getColorGradients(): Nullable<Array<ColorGradient>>;
  13384. /**
  13385. * Adds a new ramp gradient used to remap particle colors
  13386. * @param gradient defines the gradient to use (between 0 and 1)
  13387. * @param color defines the color to affect to the specified gradient
  13388. * @returns the current particle system
  13389. */
  13390. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13391. /**
  13392. * Gets the current list of ramp gradients.
  13393. * You must use addRampGradient and removeRampGradient to udpate this list
  13394. * @returns the list of ramp gradients
  13395. */
  13396. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13397. /** Gets or sets a boolean indicating that ramp gradients must be used
  13398. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13399. */
  13400. useRampGradients: boolean;
  13401. /**
  13402. * Adds a new color remap gradient
  13403. * @param gradient defines the gradient to use (between 0 and 1)
  13404. * @param min defines the color remap minimal range
  13405. * @param max defines the color remap maximal range
  13406. * @returns the current particle system
  13407. */
  13408. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13409. /**
  13410. * Gets the current list of color remap gradients.
  13411. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13412. * @returns the list of color remap gradients
  13413. */
  13414. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13415. /**
  13416. * Adds a new alpha remap gradient
  13417. * @param gradient defines the gradient to use (between 0 and 1)
  13418. * @param min defines the alpha remap minimal range
  13419. * @param max defines the alpha remap maximal range
  13420. * @returns the current particle system
  13421. */
  13422. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13423. /**
  13424. * Gets the current list of alpha remap gradients.
  13425. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13426. * @returns the list of alpha remap gradients
  13427. */
  13428. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13429. /**
  13430. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13431. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13432. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13433. * @returns the emitter
  13434. */
  13435. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13436. /**
  13437. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13438. * @param radius The radius of the hemisphere to emit from
  13439. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13440. * @returns the emitter
  13441. */
  13442. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13443. /**
  13444. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13445. * @param radius The radius of the sphere to emit from
  13446. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13447. * @returns the emitter
  13448. */
  13449. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13450. /**
  13451. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13452. * @param radius The radius of the sphere to emit from
  13453. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13454. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13455. * @returns the emitter
  13456. */
  13457. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13458. /**
  13459. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13460. * @param radius The radius of the emission cylinder
  13461. * @param height The height of the emission cylinder
  13462. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13463. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13464. * @returns the emitter
  13465. */
  13466. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13467. /**
  13468. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13469. * @param radius The radius of the cylinder to emit from
  13470. * @param height The height of the emission cylinder
  13471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13472. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13473. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13474. * @returns the emitter
  13475. */
  13476. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13477. /**
  13478. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13479. * @param radius The radius of the cone to emit from
  13480. * @param angle The base angle of the cone
  13481. * @returns the emitter
  13482. */
  13483. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13484. /**
  13485. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13488. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13489. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13490. * @returns the emitter
  13491. */
  13492. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13493. /**
  13494. * Get hosting scene
  13495. * @returns the scene
  13496. */
  13497. getScene(): Scene;
  13498. }
  13499. }
  13500. declare module BABYLON {
  13501. /**
  13502. * 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.
  13503. * @see https://doc.babylonjs.com/how_to/transformnode
  13504. */
  13505. export class TransformNode extends Node {
  13506. /**
  13507. * Object will not rotate to face the camera
  13508. */
  13509. static BILLBOARDMODE_NONE: number;
  13510. /**
  13511. * Object will rotate to face the camera but only on the x axis
  13512. */
  13513. static BILLBOARDMODE_X: number;
  13514. /**
  13515. * Object will rotate to face the camera but only on the y axis
  13516. */
  13517. static BILLBOARDMODE_Y: number;
  13518. /**
  13519. * Object will rotate to face the camera but only on the z axis
  13520. */
  13521. static BILLBOARDMODE_Z: number;
  13522. /**
  13523. * Object will rotate to face the camera
  13524. */
  13525. static BILLBOARDMODE_ALL: number;
  13526. /**
  13527. * Object will rotate to face the camera's position instead of orientation
  13528. */
  13529. static BILLBOARDMODE_USE_POSITION: number;
  13530. private _forward;
  13531. private _forwardInverted;
  13532. private _up;
  13533. private _right;
  13534. private _rightInverted;
  13535. private _position;
  13536. private _rotation;
  13537. private _rotationQuaternion;
  13538. protected _scaling: Vector3;
  13539. protected _isDirty: boolean;
  13540. private _transformToBoneReferal;
  13541. private _isAbsoluteSynced;
  13542. private _billboardMode;
  13543. /**
  13544. * Gets or sets the billboard mode. Default is 0.
  13545. *
  13546. * | Value | Type | Description |
  13547. * | --- | --- | --- |
  13548. * | 0 | BILLBOARDMODE_NONE | |
  13549. * | 1 | BILLBOARDMODE_X | |
  13550. * | 2 | BILLBOARDMODE_Y | |
  13551. * | 4 | BILLBOARDMODE_Z | |
  13552. * | 7 | BILLBOARDMODE_ALL | |
  13553. *
  13554. */
  13555. get billboardMode(): number;
  13556. set billboardMode(value: number);
  13557. private _preserveParentRotationForBillboard;
  13558. /**
  13559. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13560. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13561. */
  13562. get preserveParentRotationForBillboard(): boolean;
  13563. set preserveParentRotationForBillboard(value: boolean);
  13564. /**
  13565. * 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
  13566. */
  13567. scalingDeterminant: number;
  13568. private _infiniteDistance;
  13569. /**
  13570. * Gets or sets the distance of the object to max, often used by skybox
  13571. */
  13572. get infiniteDistance(): boolean;
  13573. set infiniteDistance(value: boolean);
  13574. /**
  13575. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13576. * By default the system will update normals to compensate
  13577. */
  13578. ignoreNonUniformScaling: boolean;
  13579. /**
  13580. * 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
  13581. */
  13582. reIntegrateRotationIntoRotationQuaternion: boolean;
  13583. /** @hidden */
  13584. _poseMatrix: Nullable<Matrix>;
  13585. /** @hidden */
  13586. _localMatrix: Matrix;
  13587. private _usePivotMatrix;
  13588. private _absolutePosition;
  13589. private _absoluteScaling;
  13590. private _absoluteRotationQuaternion;
  13591. private _pivotMatrix;
  13592. private _pivotMatrixInverse;
  13593. protected _postMultiplyPivotMatrix: boolean;
  13594. protected _isWorldMatrixFrozen: boolean;
  13595. /** @hidden */
  13596. _indexInSceneTransformNodesArray: number;
  13597. /**
  13598. * An event triggered after the world matrix is updated
  13599. */
  13600. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13601. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13602. /**
  13603. * Gets a string identifying the name of the class
  13604. * @returns "TransformNode" string
  13605. */
  13606. getClassName(): string;
  13607. /**
  13608. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13609. */
  13610. get position(): Vector3;
  13611. set position(newPosition: Vector3);
  13612. /**
  13613. * 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)).
  13614. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13615. */
  13616. get rotation(): Vector3;
  13617. set rotation(newRotation: Vector3);
  13618. /**
  13619. * 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)).
  13620. */
  13621. get scaling(): Vector3;
  13622. set scaling(newScaling: Vector3);
  13623. /**
  13624. * 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).
  13625. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13626. */
  13627. get rotationQuaternion(): Nullable<Quaternion>;
  13628. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13629. /**
  13630. * The forward direction of that transform in world space.
  13631. */
  13632. get forward(): Vector3;
  13633. /**
  13634. * The up direction of that transform in world space.
  13635. */
  13636. get up(): Vector3;
  13637. /**
  13638. * The right direction of that transform in world space.
  13639. */
  13640. get right(): Vector3;
  13641. /**
  13642. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13643. * @param matrix the matrix to copy the pose from
  13644. * @returns this TransformNode.
  13645. */
  13646. updatePoseMatrix(matrix: Matrix): TransformNode;
  13647. /**
  13648. * Returns the mesh Pose matrix.
  13649. * @returns the pose matrix
  13650. */
  13651. getPoseMatrix(): Matrix;
  13652. /** @hidden */
  13653. _isSynchronized(): boolean;
  13654. /** @hidden */
  13655. _initCache(): void;
  13656. /**
  13657. * Flag the transform node as dirty (Forcing it to update everything)
  13658. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13659. * @returns this transform node
  13660. */
  13661. markAsDirty(property: string): TransformNode;
  13662. /**
  13663. * Returns the current mesh absolute position.
  13664. * Returns a Vector3.
  13665. */
  13666. get absolutePosition(): Vector3;
  13667. /**
  13668. * Returns the current mesh absolute scaling.
  13669. * Returns a Vector3.
  13670. */
  13671. get absoluteScaling(): Vector3;
  13672. /**
  13673. * Returns the current mesh absolute rotation.
  13674. * Returns a Quaternion.
  13675. */
  13676. get absoluteRotationQuaternion(): Quaternion;
  13677. /**
  13678. * Sets a new matrix to apply before all other transformation
  13679. * @param matrix defines the transform matrix
  13680. * @returns the current TransformNode
  13681. */
  13682. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13683. /**
  13684. * Sets a new pivot matrix to the current node
  13685. * @param matrix defines the new pivot matrix to use
  13686. * @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
  13687. * @returns the current TransformNode
  13688. */
  13689. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13690. /**
  13691. * Returns the mesh pivot matrix.
  13692. * Default : Identity.
  13693. * @returns the matrix
  13694. */
  13695. getPivotMatrix(): Matrix;
  13696. /**
  13697. * Instantiate (when possible) or clone that node with its hierarchy
  13698. * @param newParent defines the new parent to use for the instance (or clone)
  13699. * @param options defines options to configure how copy is done
  13700. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13701. * @returns an instance (or a clone) of the current node with its hiearchy
  13702. */
  13703. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13704. doNotInstantiate: boolean;
  13705. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13706. /**
  13707. * Prevents the World matrix to be computed any longer
  13708. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13709. * @returns the TransformNode.
  13710. */
  13711. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13712. /**
  13713. * Allows back the World matrix computation.
  13714. * @returns the TransformNode.
  13715. */
  13716. unfreezeWorldMatrix(): this;
  13717. /**
  13718. * True if the World matrix has been frozen.
  13719. */
  13720. get isWorldMatrixFrozen(): boolean;
  13721. /**
  13722. * Retuns the mesh absolute position in the World.
  13723. * @returns a Vector3.
  13724. */
  13725. getAbsolutePosition(): Vector3;
  13726. /**
  13727. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13728. * @param absolutePosition the absolute position to set
  13729. * @returns the TransformNode.
  13730. */
  13731. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13732. /**
  13733. * Sets the mesh position in its local space.
  13734. * @param vector3 the position to set in localspace
  13735. * @returns the TransformNode.
  13736. */
  13737. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13738. /**
  13739. * Returns the mesh position in the local space from the current World matrix values.
  13740. * @returns a new Vector3.
  13741. */
  13742. getPositionExpressedInLocalSpace(): Vector3;
  13743. /**
  13744. * Translates the mesh along the passed Vector3 in its local space.
  13745. * @param vector3 the distance to translate in localspace
  13746. * @returns the TransformNode.
  13747. */
  13748. locallyTranslate(vector3: Vector3): TransformNode;
  13749. private static _lookAtVectorCache;
  13750. /**
  13751. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13752. * @param targetPoint the position (must be in same space as current mesh) to look at
  13753. * @param yawCor optional yaw (y-axis) correction in radians
  13754. * @param pitchCor optional pitch (x-axis) correction in radians
  13755. * @param rollCor optional roll (z-axis) correction in radians
  13756. * @param space the choosen space of the target
  13757. * @returns the TransformNode.
  13758. */
  13759. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13760. /**
  13761. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13762. * This Vector3 is expressed in the World space.
  13763. * @param localAxis axis to rotate
  13764. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13765. */
  13766. getDirection(localAxis: Vector3): Vector3;
  13767. /**
  13768. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13769. * localAxis is expressed in the mesh local space.
  13770. * result is computed in the Wordl space from the mesh World matrix.
  13771. * @param localAxis axis to rotate
  13772. * @param result the resulting transformnode
  13773. * @returns this TransformNode.
  13774. */
  13775. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13776. /**
  13777. * Sets this transform node rotation to the given local axis.
  13778. * @param localAxis the axis in local space
  13779. * @param yawCor optional yaw (y-axis) correction in radians
  13780. * @param pitchCor optional pitch (x-axis) correction in radians
  13781. * @param rollCor optional roll (z-axis) correction in radians
  13782. * @returns this TransformNode
  13783. */
  13784. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13785. /**
  13786. * Sets a new pivot point to the current node
  13787. * @param point defines the new pivot point to use
  13788. * @param space defines if the point is in world or local space (local by default)
  13789. * @returns the current TransformNode
  13790. */
  13791. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13792. /**
  13793. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13794. * @returns the pivot point
  13795. */
  13796. getPivotPoint(): Vector3;
  13797. /**
  13798. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13799. * @param result the vector3 to store the result
  13800. * @returns this TransformNode.
  13801. */
  13802. getPivotPointToRef(result: Vector3): TransformNode;
  13803. /**
  13804. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13805. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13806. */
  13807. getAbsolutePivotPoint(): Vector3;
  13808. /**
  13809. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13810. * @param result vector3 to store the result
  13811. * @returns this TransformNode.
  13812. */
  13813. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13814. /**
  13815. * Defines the passed node as the parent of the current node.
  13816. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13817. * @see https://doc.babylonjs.com/how_to/parenting
  13818. * @param node the node ot set as the parent
  13819. * @returns this TransformNode.
  13820. */
  13821. setParent(node: Nullable<Node>): TransformNode;
  13822. private _nonUniformScaling;
  13823. /**
  13824. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13825. */
  13826. get nonUniformScaling(): boolean;
  13827. /** @hidden */
  13828. _updateNonUniformScalingState(value: boolean): boolean;
  13829. /**
  13830. * Attach the current TransformNode to another TransformNode associated with a bone
  13831. * @param bone Bone affecting the TransformNode
  13832. * @param affectedTransformNode TransformNode associated with the bone
  13833. * @returns this object
  13834. */
  13835. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13836. /**
  13837. * Detach the transform node if its associated with a bone
  13838. * @returns this object
  13839. */
  13840. detachFromBone(): TransformNode;
  13841. private static _rotationAxisCache;
  13842. /**
  13843. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13844. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13845. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13846. * The passed axis is also normalized.
  13847. * @param axis the axis to rotate around
  13848. * @param amount the amount to rotate in radians
  13849. * @param space Space to rotate in (Default: local)
  13850. * @returns the TransformNode.
  13851. */
  13852. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13853. /**
  13854. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13855. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13856. * The passed axis is also normalized. .
  13857. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13858. * @param point the point to rotate around
  13859. * @param axis the axis to rotate around
  13860. * @param amount the amount to rotate in radians
  13861. * @returns the TransformNode
  13862. */
  13863. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13864. /**
  13865. * Translates the mesh along the axis vector for the passed distance in the given space.
  13866. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13867. * @param axis the axis to translate in
  13868. * @param distance the distance to translate
  13869. * @param space Space to rotate in (Default: local)
  13870. * @returns the TransformNode.
  13871. */
  13872. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13873. /**
  13874. * Adds a rotation step to the mesh current rotation.
  13875. * x, y, z are Euler angles expressed in radians.
  13876. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13877. * This means this rotation is made in the mesh local space only.
  13878. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13879. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13880. * ```javascript
  13881. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13882. * ```
  13883. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13884. * 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.
  13885. * @param x Rotation to add
  13886. * @param y Rotation to add
  13887. * @param z Rotation to add
  13888. * @returns the TransformNode.
  13889. */
  13890. addRotation(x: number, y: number, z: number): TransformNode;
  13891. /**
  13892. * @hidden
  13893. */
  13894. protected _getEffectiveParent(): Nullable<Node>;
  13895. /**
  13896. * Computes the world matrix of the node
  13897. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13898. * @returns the world matrix
  13899. */
  13900. computeWorldMatrix(force?: boolean): Matrix;
  13901. /**
  13902. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13903. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13904. */
  13905. resetLocalMatrix(independentOfChildren?: boolean): void;
  13906. protected _afterComputeWorldMatrix(): void;
  13907. /**
  13908. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13909. * @param func callback function to add
  13910. *
  13911. * @returns the TransformNode.
  13912. */
  13913. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13914. /**
  13915. * Removes a registered callback function.
  13916. * @param func callback function to remove
  13917. * @returns the TransformNode.
  13918. */
  13919. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13920. /**
  13921. * Gets the position of the current mesh in camera space
  13922. * @param camera defines the camera to use
  13923. * @returns a position
  13924. */
  13925. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13926. /**
  13927. * Returns the distance from the mesh to the active camera
  13928. * @param camera defines the camera to use
  13929. * @returns the distance
  13930. */
  13931. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13932. /**
  13933. * Clone the current transform node
  13934. * @param name Name of the new clone
  13935. * @param newParent New parent for the clone
  13936. * @param doNotCloneChildren Do not clone children hierarchy
  13937. * @returns the new transform node
  13938. */
  13939. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13940. /**
  13941. * Serializes the objects information.
  13942. * @param currentSerializationObject defines the object to serialize in
  13943. * @returns the serialized object
  13944. */
  13945. serialize(currentSerializationObject?: any): any;
  13946. /**
  13947. * Returns a new TransformNode object parsed from the source provided.
  13948. * @param parsedTransformNode is the source.
  13949. * @param scene the scne the object belongs to
  13950. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13951. * @returns a new TransformNode object parsed from the source provided.
  13952. */
  13953. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13954. /**
  13955. * Get all child-transformNodes of this node
  13956. * @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
  13957. * @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
  13958. * @returns an array of TransformNode
  13959. */
  13960. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13961. /**
  13962. * Releases resources associated with this transform node.
  13963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13965. */
  13966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13967. /**
  13968. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13969. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13970. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13971. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13972. * @returns the current mesh
  13973. */
  13974. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13975. private _syncAbsoluteScalingAndRotation;
  13976. }
  13977. }
  13978. declare module BABYLON {
  13979. /**
  13980. * Class used to override all child animations of a given target
  13981. */
  13982. export class AnimationPropertiesOverride {
  13983. /**
  13984. * Gets or sets a value indicating if animation blending must be used
  13985. */
  13986. enableBlending: boolean;
  13987. /**
  13988. * Gets or sets the blending speed to use when enableBlending is true
  13989. */
  13990. blendingSpeed: number;
  13991. /**
  13992. * Gets or sets the default loop mode to use
  13993. */
  13994. loopMode: number;
  13995. }
  13996. }
  13997. declare module BABYLON {
  13998. /**
  13999. * Class used to store bone information
  14000. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14001. */
  14002. export class Bone extends Node {
  14003. /**
  14004. * defines the bone name
  14005. */
  14006. name: string;
  14007. private static _tmpVecs;
  14008. private static _tmpQuat;
  14009. private static _tmpMats;
  14010. /**
  14011. * Gets the list of child bones
  14012. */
  14013. children: Bone[];
  14014. /** Gets the animations associated with this bone */
  14015. animations: Animation[];
  14016. /**
  14017. * Gets or sets bone length
  14018. */
  14019. length: number;
  14020. /**
  14021. * @hidden Internal only
  14022. * Set this value to map this bone to a different index in the transform matrices
  14023. * Set this value to -1 to exclude the bone from the transform matrices
  14024. */
  14025. _index: Nullable<number>;
  14026. private _skeleton;
  14027. private _localMatrix;
  14028. private _restPose;
  14029. private _baseMatrix;
  14030. private _absoluteTransform;
  14031. private _invertedAbsoluteTransform;
  14032. private _parent;
  14033. private _scalingDeterminant;
  14034. private _worldTransform;
  14035. private _localScaling;
  14036. private _localRotation;
  14037. private _localPosition;
  14038. private _needToDecompose;
  14039. private _needToCompose;
  14040. /** @hidden */
  14041. _linkedTransformNode: Nullable<TransformNode>;
  14042. /** @hidden */
  14043. _waitingTransformNodeId: Nullable<string>;
  14044. /** @hidden */
  14045. get _matrix(): Matrix;
  14046. /** @hidden */
  14047. set _matrix(value: Matrix);
  14048. /**
  14049. * Create a new bone
  14050. * @param name defines the bone name
  14051. * @param skeleton defines the parent skeleton
  14052. * @param parentBone defines the parent (can be null if the bone is the root)
  14053. * @param localMatrix defines the local matrix
  14054. * @param restPose defines the rest pose matrix
  14055. * @param baseMatrix defines the base matrix
  14056. * @param index defines index of the bone in the hiearchy
  14057. */
  14058. constructor(
  14059. /**
  14060. * defines the bone name
  14061. */
  14062. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14063. /**
  14064. * Gets the current object class name.
  14065. * @return the class name
  14066. */
  14067. getClassName(): string;
  14068. /**
  14069. * Gets the parent skeleton
  14070. * @returns a skeleton
  14071. */
  14072. getSkeleton(): Skeleton;
  14073. /**
  14074. * Gets parent bone
  14075. * @returns a bone or null if the bone is the root of the bone hierarchy
  14076. */
  14077. getParent(): Nullable<Bone>;
  14078. /**
  14079. * Returns an array containing the root bones
  14080. * @returns an array containing the root bones
  14081. */
  14082. getChildren(): Array<Bone>;
  14083. /**
  14084. * Gets the node index in matrix array generated for rendering
  14085. * @returns the node index
  14086. */
  14087. getIndex(): number;
  14088. /**
  14089. * Sets the parent bone
  14090. * @param parent defines the parent (can be null if the bone is the root)
  14091. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14092. */
  14093. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14094. /**
  14095. * Gets the local matrix
  14096. * @returns a matrix
  14097. */
  14098. getLocalMatrix(): Matrix;
  14099. /**
  14100. * Gets the base matrix (initial matrix which remains unchanged)
  14101. * @returns a matrix
  14102. */
  14103. getBaseMatrix(): Matrix;
  14104. /**
  14105. * Gets the rest pose matrix
  14106. * @returns a matrix
  14107. */
  14108. getRestPose(): Matrix;
  14109. /**
  14110. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14111. */
  14112. getWorldMatrix(): Matrix;
  14113. /**
  14114. * Sets the local matrix to rest pose matrix
  14115. */
  14116. returnToRest(): void;
  14117. /**
  14118. * Gets the inverse of the absolute transform matrix.
  14119. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14120. * @returns a matrix
  14121. */
  14122. getInvertedAbsoluteTransform(): Matrix;
  14123. /**
  14124. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14125. * @returns a matrix
  14126. */
  14127. getAbsoluteTransform(): Matrix;
  14128. /**
  14129. * Links with the given transform node.
  14130. * The local matrix of this bone is copied from the transform node every frame.
  14131. * @param transformNode defines the transform node to link to
  14132. */
  14133. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14134. /**
  14135. * Gets the node used to drive the bone's transformation
  14136. * @returns a transform node or null
  14137. */
  14138. getTransformNode(): Nullable<TransformNode>;
  14139. /** Gets or sets current position (in local space) */
  14140. get position(): Vector3;
  14141. set position(newPosition: Vector3);
  14142. /** Gets or sets current rotation (in local space) */
  14143. get rotation(): Vector3;
  14144. set rotation(newRotation: Vector3);
  14145. /** Gets or sets current rotation quaternion (in local space) */
  14146. get rotationQuaternion(): Quaternion;
  14147. set rotationQuaternion(newRotation: Quaternion);
  14148. /** Gets or sets current scaling (in local space) */
  14149. get scaling(): Vector3;
  14150. set scaling(newScaling: Vector3);
  14151. /**
  14152. * Gets the animation properties override
  14153. */
  14154. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14155. private _decompose;
  14156. private _compose;
  14157. /**
  14158. * Update the base and local matrices
  14159. * @param matrix defines the new base or local matrix
  14160. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14161. * @param updateLocalMatrix defines if the local matrix should be updated
  14162. */
  14163. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14164. /** @hidden */
  14165. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14166. /**
  14167. * Flag the bone as dirty (Forcing it to update everything)
  14168. */
  14169. markAsDirty(): void;
  14170. /** @hidden */
  14171. _markAsDirtyAndCompose(): void;
  14172. private _markAsDirtyAndDecompose;
  14173. /**
  14174. * Translate the bone in local or world space
  14175. * @param vec The amount to translate the bone
  14176. * @param space The space that the translation is in
  14177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14178. */
  14179. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14180. /**
  14181. * Set the postion of the bone in local or world space
  14182. * @param position The position to set the bone
  14183. * @param space The space that the position is in
  14184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14185. */
  14186. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14187. /**
  14188. * Set the absolute position of the bone (world space)
  14189. * @param position The position to set the bone
  14190. * @param mesh The mesh that this bone is attached to
  14191. */
  14192. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14193. /**
  14194. * Scale the bone on the x, y and z axes (in local space)
  14195. * @param x The amount to scale the bone on the x axis
  14196. * @param y The amount to scale the bone on the y axis
  14197. * @param z The amount to scale the bone on the z axis
  14198. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14199. */
  14200. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14201. /**
  14202. * Set the bone scaling in local space
  14203. * @param scale defines the scaling vector
  14204. */
  14205. setScale(scale: Vector3): void;
  14206. /**
  14207. * Gets the current scaling in local space
  14208. * @returns the current scaling vector
  14209. */
  14210. getScale(): Vector3;
  14211. /**
  14212. * Gets the current scaling in local space and stores it in a target vector
  14213. * @param result defines the target vector
  14214. */
  14215. getScaleToRef(result: Vector3): void;
  14216. /**
  14217. * Set the yaw, pitch, and roll of the bone in local or world space
  14218. * @param yaw The rotation of the bone on the y axis
  14219. * @param pitch The rotation of the bone on the x axis
  14220. * @param roll The rotation of the bone on the z axis
  14221. * @param space The space that the axes of rotation are in
  14222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14223. */
  14224. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14225. /**
  14226. * Add a rotation to the bone on an axis in local or world space
  14227. * @param axis The axis to rotate the bone on
  14228. * @param amount The amount to rotate the bone
  14229. * @param space The space that the axis is in
  14230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14231. */
  14232. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14233. /**
  14234. * Set the rotation of the bone to a particular axis angle in local or world space
  14235. * @param axis The axis to rotate the bone on
  14236. * @param angle The angle that the bone should be rotated to
  14237. * @param space The space that the axis is in
  14238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14239. */
  14240. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14241. /**
  14242. * Set the euler rotation of the bone in local of world space
  14243. * @param rotation The euler rotation that the bone should be set to
  14244. * @param space The space that the rotation is in
  14245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14246. */
  14247. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14248. /**
  14249. * Set the quaternion rotation of the bone in local of world space
  14250. * @param quat The quaternion rotation that the bone should be set to
  14251. * @param space The space that the rotation is in
  14252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14253. */
  14254. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14255. /**
  14256. * Set the rotation matrix of the bone in local of world space
  14257. * @param rotMat The rotation matrix that the bone should be set to
  14258. * @param space The space that the rotation is in
  14259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14260. */
  14261. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14262. private _rotateWithMatrix;
  14263. private _getNegativeRotationToRef;
  14264. /**
  14265. * Get the position of the bone in local or world space
  14266. * @param space The space that the returned position is in
  14267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14268. * @returns The position of the bone
  14269. */
  14270. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14271. /**
  14272. * Copy the position of the bone to a vector3 in local or world space
  14273. * @param space The space that the returned position is in
  14274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14275. * @param result The vector3 to copy the position to
  14276. */
  14277. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14278. /**
  14279. * Get the absolute position of the bone (world space)
  14280. * @param mesh The mesh that this bone is attached to
  14281. * @returns The absolute position of the bone
  14282. */
  14283. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14284. /**
  14285. * Copy the absolute position of the bone (world space) to the result param
  14286. * @param mesh The mesh that this bone is attached to
  14287. * @param result The vector3 to copy the absolute position to
  14288. */
  14289. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14290. /**
  14291. * Compute the absolute transforms of this bone and its children
  14292. */
  14293. computeAbsoluteTransforms(): void;
  14294. /**
  14295. * Get the world direction from an axis that is in the local space of the bone
  14296. * @param localAxis The local direction that is used to compute the world direction
  14297. * @param mesh The mesh that this bone is attached to
  14298. * @returns The world direction
  14299. */
  14300. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14301. /**
  14302. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14303. * @param localAxis The local direction that is used to compute the world direction
  14304. * @param mesh The mesh that this bone is attached to
  14305. * @param result The vector3 that the world direction will be copied to
  14306. */
  14307. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14308. /**
  14309. * Get the euler rotation of the bone in local or world space
  14310. * @param space The space that the rotation should be in
  14311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14312. * @returns The euler rotation
  14313. */
  14314. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14315. /**
  14316. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14317. * @param space The space that the rotation should be in
  14318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14319. * @param result The vector3 that the rotation should be copied to
  14320. */
  14321. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14322. /**
  14323. * Get the quaternion rotation of the bone in either local or world space
  14324. * @param space The space that the rotation should be in
  14325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14326. * @returns The quaternion rotation
  14327. */
  14328. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14329. /**
  14330. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14331. * @param space The space that the rotation should be in
  14332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14333. * @param result The quaternion that the rotation should be copied to
  14334. */
  14335. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14336. /**
  14337. * Get the rotation matrix of the bone in local or world space
  14338. * @param space The space that the rotation should be in
  14339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14340. * @returns The rotation matrix
  14341. */
  14342. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14343. /**
  14344. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14345. * @param space The space that the rotation should be in
  14346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14347. * @param result The quaternion that the rotation should be copied to
  14348. */
  14349. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14350. /**
  14351. * Get the world position of a point that is in the local space of the bone
  14352. * @param position The local position
  14353. * @param mesh The mesh that this bone is attached to
  14354. * @returns The world position
  14355. */
  14356. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14357. /**
  14358. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14359. * @param position The local position
  14360. * @param mesh The mesh that this bone is attached to
  14361. * @param result The vector3 that the world position should be copied to
  14362. */
  14363. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14364. /**
  14365. * Get the local position of a point that is in world space
  14366. * @param position The world position
  14367. * @param mesh The mesh that this bone is attached to
  14368. * @returns The local position
  14369. */
  14370. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14371. /**
  14372. * Get the local position of a point that is in world space and copy it to the result param
  14373. * @param position The world position
  14374. * @param mesh The mesh that this bone is attached to
  14375. * @param result The vector3 that the local position should be copied to
  14376. */
  14377. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14378. }
  14379. }
  14380. declare module BABYLON {
  14381. /**
  14382. * Defines a runtime animation
  14383. */
  14384. export class RuntimeAnimation {
  14385. private _events;
  14386. /**
  14387. * The current frame of the runtime animation
  14388. */
  14389. private _currentFrame;
  14390. /**
  14391. * The animation used by the runtime animation
  14392. */
  14393. private _animation;
  14394. /**
  14395. * The target of the runtime animation
  14396. */
  14397. private _target;
  14398. /**
  14399. * The initiating animatable
  14400. */
  14401. private _host;
  14402. /**
  14403. * The original value of the runtime animation
  14404. */
  14405. private _originalValue;
  14406. /**
  14407. * The original blend value of the runtime animation
  14408. */
  14409. private _originalBlendValue;
  14410. /**
  14411. * The offsets cache of the runtime animation
  14412. */
  14413. private _offsetsCache;
  14414. /**
  14415. * The high limits cache of the runtime animation
  14416. */
  14417. private _highLimitsCache;
  14418. /**
  14419. * Specifies if the runtime animation has been stopped
  14420. */
  14421. private _stopped;
  14422. /**
  14423. * The blending factor of the runtime animation
  14424. */
  14425. private _blendingFactor;
  14426. /**
  14427. * The BabylonJS scene
  14428. */
  14429. private _scene;
  14430. /**
  14431. * The current value of the runtime animation
  14432. */
  14433. private _currentValue;
  14434. /** @hidden */
  14435. _animationState: _IAnimationState;
  14436. /**
  14437. * The active target of the runtime animation
  14438. */
  14439. private _activeTargets;
  14440. private _currentActiveTarget;
  14441. private _directTarget;
  14442. /**
  14443. * The target path of the runtime animation
  14444. */
  14445. private _targetPath;
  14446. /**
  14447. * The weight of the runtime animation
  14448. */
  14449. private _weight;
  14450. /**
  14451. * The ratio offset of the runtime animation
  14452. */
  14453. private _ratioOffset;
  14454. /**
  14455. * The previous delay of the runtime animation
  14456. */
  14457. private _previousDelay;
  14458. /**
  14459. * The previous ratio of the runtime animation
  14460. */
  14461. private _previousRatio;
  14462. private _enableBlending;
  14463. private _keys;
  14464. private _minFrame;
  14465. private _maxFrame;
  14466. private _minValue;
  14467. private _maxValue;
  14468. private _targetIsArray;
  14469. /**
  14470. * Gets the current frame of the runtime animation
  14471. */
  14472. get currentFrame(): number;
  14473. /**
  14474. * Gets the weight of the runtime animation
  14475. */
  14476. get weight(): number;
  14477. /**
  14478. * Gets the current value of the runtime animation
  14479. */
  14480. get currentValue(): any;
  14481. /**
  14482. * Gets the target path of the runtime animation
  14483. */
  14484. get targetPath(): string;
  14485. /**
  14486. * Gets the actual target of the runtime animation
  14487. */
  14488. get target(): any;
  14489. /** @hidden */
  14490. _onLoop: () => void;
  14491. /**
  14492. * Create a new RuntimeAnimation object
  14493. * @param target defines the target of the animation
  14494. * @param animation defines the source animation object
  14495. * @param scene defines the hosting scene
  14496. * @param host defines the initiating Animatable
  14497. */
  14498. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14499. private _preparePath;
  14500. /**
  14501. * Gets the animation from the runtime animation
  14502. */
  14503. get animation(): Animation;
  14504. /**
  14505. * Resets the runtime animation to the beginning
  14506. * @param restoreOriginal defines whether to restore the target property to the original value
  14507. */
  14508. reset(restoreOriginal?: boolean): void;
  14509. /**
  14510. * Specifies if the runtime animation is stopped
  14511. * @returns Boolean specifying if the runtime animation is stopped
  14512. */
  14513. isStopped(): boolean;
  14514. /**
  14515. * Disposes of the runtime animation
  14516. */
  14517. dispose(): void;
  14518. /**
  14519. * Apply the interpolated value to the target
  14520. * @param currentValue defines the value computed by the animation
  14521. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14522. */
  14523. setValue(currentValue: any, weight: number): void;
  14524. private _getOriginalValues;
  14525. private _setValue;
  14526. /**
  14527. * Gets the loop pmode of the runtime animation
  14528. * @returns Loop Mode
  14529. */
  14530. private _getCorrectLoopMode;
  14531. /**
  14532. * Move the current animation to a given frame
  14533. * @param frame defines the frame to move to
  14534. */
  14535. goToFrame(frame: number): void;
  14536. /**
  14537. * @hidden Internal use only
  14538. */
  14539. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14540. /**
  14541. * Execute the current animation
  14542. * @param delay defines the delay to add to the current frame
  14543. * @param from defines the lower bound of the animation range
  14544. * @param to defines the upper bound of the animation range
  14545. * @param loop defines if the current animation must loop
  14546. * @param speedRatio defines the current speed ratio
  14547. * @param weight defines the weight of the animation (default is -1 so no weight)
  14548. * @param onLoop optional callback called when animation loops
  14549. * @returns a boolean indicating if the animation is running
  14550. */
  14551. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14552. }
  14553. }
  14554. declare module BABYLON {
  14555. /**
  14556. * Class used to store an actual running animation
  14557. */
  14558. export class Animatable {
  14559. /** defines the target object */
  14560. target: any;
  14561. /** defines the starting frame number (default is 0) */
  14562. fromFrame: number;
  14563. /** defines the ending frame number (default is 100) */
  14564. toFrame: number;
  14565. /** defines if the animation must loop (default is false) */
  14566. loopAnimation: boolean;
  14567. /** defines a callback to call when animation ends if it is not looping */
  14568. onAnimationEnd?: (() => void) | null | undefined;
  14569. /** defines a callback to call when animation loops */
  14570. onAnimationLoop?: (() => void) | null | undefined;
  14571. private _localDelayOffset;
  14572. private _pausedDelay;
  14573. private _runtimeAnimations;
  14574. private _paused;
  14575. private _scene;
  14576. private _speedRatio;
  14577. private _weight;
  14578. private _syncRoot;
  14579. /**
  14580. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14581. * This will only apply for non looping animation (default is true)
  14582. */
  14583. disposeOnEnd: boolean;
  14584. /**
  14585. * Gets a boolean indicating if the animation has started
  14586. */
  14587. animationStarted: boolean;
  14588. /**
  14589. * Observer raised when the animation ends
  14590. */
  14591. onAnimationEndObservable: Observable<Animatable>;
  14592. /**
  14593. * Observer raised when the animation loops
  14594. */
  14595. onAnimationLoopObservable: Observable<Animatable>;
  14596. /**
  14597. * Gets the root Animatable used to synchronize and normalize animations
  14598. */
  14599. get syncRoot(): Nullable<Animatable>;
  14600. /**
  14601. * Gets the current frame of the first RuntimeAnimation
  14602. * Used to synchronize Animatables
  14603. */
  14604. get masterFrame(): number;
  14605. /**
  14606. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14607. */
  14608. get weight(): number;
  14609. set weight(value: number);
  14610. /**
  14611. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14612. */
  14613. get speedRatio(): number;
  14614. set speedRatio(value: number);
  14615. /**
  14616. * Creates a new Animatable
  14617. * @param scene defines the hosting scene
  14618. * @param target defines the target object
  14619. * @param fromFrame defines the starting frame number (default is 0)
  14620. * @param toFrame defines the ending frame number (default is 100)
  14621. * @param loopAnimation defines if the animation must loop (default is false)
  14622. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14623. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14624. * @param animations defines a group of animation to add to the new Animatable
  14625. * @param onAnimationLoop defines a callback to call when animation loops
  14626. */
  14627. constructor(scene: Scene,
  14628. /** defines the target object */
  14629. target: any,
  14630. /** defines the starting frame number (default is 0) */
  14631. fromFrame?: number,
  14632. /** defines the ending frame number (default is 100) */
  14633. toFrame?: number,
  14634. /** defines if the animation must loop (default is false) */
  14635. loopAnimation?: boolean, speedRatio?: number,
  14636. /** defines a callback to call when animation ends if it is not looping */
  14637. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14638. /** defines a callback to call when animation loops */
  14639. onAnimationLoop?: (() => void) | null | undefined);
  14640. /**
  14641. * Synchronize and normalize current Animatable with a source Animatable
  14642. * This is useful when using animation weights and when animations are not of the same length
  14643. * @param root defines the root Animatable to synchronize with
  14644. * @returns the current Animatable
  14645. */
  14646. syncWith(root: Animatable): Animatable;
  14647. /**
  14648. * Gets the list of runtime animations
  14649. * @returns an array of RuntimeAnimation
  14650. */
  14651. getAnimations(): RuntimeAnimation[];
  14652. /**
  14653. * Adds more animations to the current animatable
  14654. * @param target defines the target of the animations
  14655. * @param animations defines the new animations to add
  14656. */
  14657. appendAnimations(target: any, animations: Animation[]): void;
  14658. /**
  14659. * Gets the source animation for a specific property
  14660. * @param property defines the propertyu to look for
  14661. * @returns null or the source animation for the given property
  14662. */
  14663. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14664. /**
  14665. * Gets the runtime animation for a specific property
  14666. * @param property defines the propertyu to look for
  14667. * @returns null or the runtime animation for the given property
  14668. */
  14669. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14670. /**
  14671. * Resets the animatable to its original state
  14672. */
  14673. reset(): void;
  14674. /**
  14675. * Allows the animatable to blend with current running animations
  14676. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14677. * @param blendingSpeed defines the blending speed to use
  14678. */
  14679. enableBlending(blendingSpeed: number): void;
  14680. /**
  14681. * Disable animation blending
  14682. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14683. */
  14684. disableBlending(): void;
  14685. /**
  14686. * Jump directly to a given frame
  14687. * @param frame defines the frame to jump to
  14688. */
  14689. goToFrame(frame: number): void;
  14690. /**
  14691. * Pause the animation
  14692. */
  14693. pause(): void;
  14694. /**
  14695. * Restart the animation
  14696. */
  14697. restart(): void;
  14698. private _raiseOnAnimationEnd;
  14699. /**
  14700. * Stop and delete the current animation
  14701. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14702. * @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)
  14703. */
  14704. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14705. /**
  14706. * Wait asynchronously for the animation to end
  14707. * @returns a promise which will be fullfilled when the animation ends
  14708. */
  14709. waitAsync(): Promise<Animatable>;
  14710. /** @hidden */
  14711. _animate(delay: number): boolean;
  14712. }
  14713. interface Scene {
  14714. /** @hidden */
  14715. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14716. /** @hidden */
  14717. _processLateAnimationBindingsForMatrices(holder: {
  14718. totalWeight: number;
  14719. animations: RuntimeAnimation[];
  14720. originalValue: Matrix;
  14721. }): any;
  14722. /** @hidden */
  14723. _processLateAnimationBindingsForQuaternions(holder: {
  14724. totalWeight: number;
  14725. animations: RuntimeAnimation[];
  14726. originalValue: Quaternion;
  14727. }, refQuaternion: Quaternion): Quaternion;
  14728. /** @hidden */
  14729. _processLateAnimationBindings(): void;
  14730. /**
  14731. * Will start the animation sequence of a given target
  14732. * @param target defines the target
  14733. * @param from defines from which frame should animation start
  14734. * @param to defines until which frame should animation run.
  14735. * @param weight defines the weight to apply to the animation (1.0 by default)
  14736. * @param loop defines if the animation loops
  14737. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14738. * @param onAnimationEnd defines the function to be executed when the animation ends
  14739. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14740. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14741. * @param onAnimationLoop defines the callback to call when an animation loops
  14742. * @returns the animatable object created for this animation
  14743. */
  14744. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14745. /**
  14746. * Will start the animation sequence of a given target
  14747. * @param target defines the target
  14748. * @param from defines from which frame should animation start
  14749. * @param to defines until which frame should animation run.
  14750. * @param loop defines if the animation loops
  14751. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14752. * @param onAnimationEnd defines the function to be executed when the animation ends
  14753. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14754. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14755. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14756. * @param onAnimationLoop defines the callback to call when an animation loops
  14757. * @returns the animatable object created for this animation
  14758. */
  14759. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14760. /**
  14761. * Will start the animation sequence of a given target and its hierarchy
  14762. * @param target defines the target
  14763. * @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.
  14764. * @param from defines from which frame should animation start
  14765. * @param to defines until which frame should animation run.
  14766. * @param loop defines if the animation loops
  14767. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14768. * @param onAnimationEnd defines the function to be executed when the animation ends
  14769. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14770. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14772. * @param onAnimationLoop defines the callback to call when an animation loops
  14773. * @returns the list of created animatables
  14774. */
  14775. 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[];
  14776. /**
  14777. * Begin a new animation on a given node
  14778. * @param target defines the target where the animation will take place
  14779. * @param animations defines the list of animations to start
  14780. * @param from defines the initial value
  14781. * @param to defines the final value
  14782. * @param loop defines if you want animation to loop (off by default)
  14783. * @param speedRatio defines the speed ratio to apply to all animations
  14784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14785. * @param onAnimationLoop defines the callback to call when an animation loops
  14786. * @returns the list of created animatables
  14787. */
  14788. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14789. /**
  14790. * Begin a new animation on a given node and its hierarchy
  14791. * @param target defines the root node where the animation will take place
  14792. * @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.
  14793. * @param animations defines the list of animations to start
  14794. * @param from defines the initial value
  14795. * @param to defines the final value
  14796. * @param loop defines if you want animation to loop (off by default)
  14797. * @param speedRatio defines the speed ratio to apply to all animations
  14798. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14799. * @param onAnimationLoop defines the callback to call when an animation loops
  14800. * @returns the list of animatables created for all nodes
  14801. */
  14802. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14803. /**
  14804. * Gets the animatable associated with a specific target
  14805. * @param target defines the target of the animatable
  14806. * @returns the required animatable if found
  14807. */
  14808. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14809. /**
  14810. * Gets all animatables associated with a given target
  14811. * @param target defines the target to look animatables for
  14812. * @returns an array of Animatables
  14813. */
  14814. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14815. /**
  14816. * Stops and removes all animations that have been applied to the scene
  14817. */
  14818. stopAllAnimations(): void;
  14819. /**
  14820. * Gets the current delta time used by animation engine
  14821. */
  14822. deltaTime: number;
  14823. }
  14824. interface Bone {
  14825. /**
  14826. * Copy an animation range from another bone
  14827. * @param source defines the source bone
  14828. * @param rangeName defines the range name to copy
  14829. * @param frameOffset defines the frame offset
  14830. * @param rescaleAsRequired defines if rescaling must be applied if required
  14831. * @param skelDimensionsRatio defines the scaling ratio
  14832. * @returns true if operation was successful
  14833. */
  14834. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14835. }
  14836. }
  14837. declare module BABYLON {
  14838. /**
  14839. * Class used to handle skinning animations
  14840. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14841. */
  14842. export class Skeleton implements IAnimatable {
  14843. /** defines the skeleton name */
  14844. name: string;
  14845. /** defines the skeleton Id */
  14846. id: string;
  14847. /**
  14848. * Defines the list of child bones
  14849. */
  14850. bones: Bone[];
  14851. /**
  14852. * Defines an estimate of the dimension of the skeleton at rest
  14853. */
  14854. dimensionsAtRest: Vector3;
  14855. /**
  14856. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14857. */
  14858. needInitialSkinMatrix: boolean;
  14859. /**
  14860. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14861. */
  14862. overrideMesh: Nullable<AbstractMesh>;
  14863. /**
  14864. * Gets the list of animations attached to this skeleton
  14865. */
  14866. animations: Array<Animation>;
  14867. private _scene;
  14868. private _isDirty;
  14869. private _transformMatrices;
  14870. private _transformMatrixTexture;
  14871. private _meshesWithPoseMatrix;
  14872. private _animatables;
  14873. private _identity;
  14874. private _synchronizedWithMesh;
  14875. private _ranges;
  14876. private _lastAbsoluteTransformsUpdateId;
  14877. private _canUseTextureForBones;
  14878. private _uniqueId;
  14879. /** @hidden */
  14880. _numBonesWithLinkedTransformNode: number;
  14881. /** @hidden */
  14882. _hasWaitingData: Nullable<boolean>;
  14883. /**
  14884. * Specifies if the skeleton should be serialized
  14885. */
  14886. doNotSerialize: boolean;
  14887. private _useTextureToStoreBoneMatrices;
  14888. /**
  14889. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14890. * Please note that this option is not available if the hardware does not support it
  14891. */
  14892. get useTextureToStoreBoneMatrices(): boolean;
  14893. set useTextureToStoreBoneMatrices(value: boolean);
  14894. private _animationPropertiesOverride;
  14895. /**
  14896. * Gets or sets the animation properties override
  14897. */
  14898. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14899. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14900. /**
  14901. * List of inspectable custom properties (used by the Inspector)
  14902. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14903. */
  14904. inspectableCustomProperties: IInspectable[];
  14905. /**
  14906. * An observable triggered before computing the skeleton's matrices
  14907. */
  14908. onBeforeComputeObservable: Observable<Skeleton>;
  14909. /**
  14910. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14911. */
  14912. get isUsingTextureForMatrices(): boolean;
  14913. /**
  14914. * Gets the unique ID of this skeleton
  14915. */
  14916. get uniqueId(): number;
  14917. /**
  14918. * Creates a new skeleton
  14919. * @param name defines the skeleton name
  14920. * @param id defines the skeleton Id
  14921. * @param scene defines the hosting scene
  14922. */
  14923. constructor(
  14924. /** defines the skeleton name */
  14925. name: string,
  14926. /** defines the skeleton Id */
  14927. id: string, scene: Scene);
  14928. /**
  14929. * Gets the current object class name.
  14930. * @return the class name
  14931. */
  14932. getClassName(): string;
  14933. /**
  14934. * Returns an array containing the root bones
  14935. * @returns an array containing the root bones
  14936. */
  14937. getChildren(): Array<Bone>;
  14938. /**
  14939. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14940. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14941. * @returns a Float32Array containing matrices data
  14942. */
  14943. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14944. /**
  14945. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14946. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14947. * @returns a raw texture containing the data
  14948. */
  14949. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14950. /**
  14951. * Gets the current hosting scene
  14952. * @returns a scene object
  14953. */
  14954. getScene(): Scene;
  14955. /**
  14956. * Gets a string representing the current skeleton data
  14957. * @param fullDetails defines a boolean indicating if we want a verbose version
  14958. * @returns a string representing the current skeleton data
  14959. */
  14960. toString(fullDetails?: boolean): string;
  14961. /**
  14962. * Get bone's index searching by name
  14963. * @param name defines bone's name to search for
  14964. * @return the indice of the bone. Returns -1 if not found
  14965. */
  14966. getBoneIndexByName(name: string): number;
  14967. /**
  14968. * Creater a new animation range
  14969. * @param name defines the name of the range
  14970. * @param from defines the start key
  14971. * @param to defines the end key
  14972. */
  14973. createAnimationRange(name: string, from: number, to: number): void;
  14974. /**
  14975. * Delete a specific animation range
  14976. * @param name defines the name of the range
  14977. * @param deleteFrames defines if frames must be removed as well
  14978. */
  14979. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14980. /**
  14981. * Gets a specific animation range
  14982. * @param name defines the name of the range to look for
  14983. * @returns the requested animation range or null if not found
  14984. */
  14985. getAnimationRange(name: string): Nullable<AnimationRange>;
  14986. /**
  14987. * Gets the list of all animation ranges defined on this skeleton
  14988. * @returns an array
  14989. */
  14990. getAnimationRanges(): Nullable<AnimationRange>[];
  14991. /**
  14992. * Copy animation range from a source skeleton.
  14993. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14994. * @param source defines the source skeleton
  14995. * @param name defines the name of the range to copy
  14996. * @param rescaleAsRequired defines if rescaling must be applied if required
  14997. * @returns true if operation was successful
  14998. */
  14999. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15000. /**
  15001. * Forces the skeleton to go to rest pose
  15002. */
  15003. returnToRest(): void;
  15004. private _getHighestAnimationFrame;
  15005. /**
  15006. * Begin a specific animation range
  15007. * @param name defines the name of the range to start
  15008. * @param loop defines if looping must be turned on (false by default)
  15009. * @param speedRatio defines the speed ratio to apply (1 by default)
  15010. * @param onAnimationEnd defines a callback which will be called when animation will end
  15011. * @returns a new animatable
  15012. */
  15013. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15014. /** @hidden */
  15015. _markAsDirty(): void;
  15016. /** @hidden */
  15017. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15018. /** @hidden */
  15019. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15020. private _computeTransformMatrices;
  15021. /**
  15022. * Build all resources required to render a skeleton
  15023. */
  15024. prepare(): void;
  15025. /**
  15026. * Gets the list of animatables currently running for this skeleton
  15027. * @returns an array of animatables
  15028. */
  15029. getAnimatables(): IAnimatable[];
  15030. /**
  15031. * Clone the current skeleton
  15032. * @param name defines the name of the new skeleton
  15033. * @param id defines the id of the new skeleton
  15034. * @returns the new skeleton
  15035. */
  15036. clone(name: string, id?: string): Skeleton;
  15037. /**
  15038. * Enable animation blending for this skeleton
  15039. * @param blendingSpeed defines the blending speed to apply
  15040. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15041. */
  15042. enableBlending(blendingSpeed?: number): void;
  15043. /**
  15044. * Releases all resources associated with the current skeleton
  15045. */
  15046. dispose(): void;
  15047. /**
  15048. * Serialize the skeleton in a JSON object
  15049. * @returns a JSON object
  15050. */
  15051. serialize(): any;
  15052. /**
  15053. * Creates a new skeleton from serialized data
  15054. * @param parsedSkeleton defines the serialized data
  15055. * @param scene defines the hosting scene
  15056. * @returns a new skeleton
  15057. */
  15058. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15059. /**
  15060. * Compute all node absolute transforms
  15061. * @param forceUpdate defines if computation must be done even if cache is up to date
  15062. */
  15063. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15064. /**
  15065. * Gets the root pose matrix
  15066. * @returns a matrix
  15067. */
  15068. getPoseMatrix(): Nullable<Matrix>;
  15069. /**
  15070. * Sorts bones per internal index
  15071. */
  15072. sortBones(): void;
  15073. private _sortBones;
  15074. }
  15075. }
  15076. declare module BABYLON {
  15077. /**
  15078. * Creates an instance based on a source mesh.
  15079. */
  15080. export class InstancedMesh extends AbstractMesh {
  15081. private _sourceMesh;
  15082. private _currentLOD;
  15083. /** @hidden */
  15084. _indexInSourceMeshInstanceArray: number;
  15085. constructor(name: string, source: Mesh);
  15086. /**
  15087. * Returns the string "InstancedMesh".
  15088. */
  15089. getClassName(): string;
  15090. /** Gets the list of lights affecting that mesh */
  15091. get lightSources(): Light[];
  15092. _resyncLightSources(): void;
  15093. _resyncLightSource(light: Light): void;
  15094. _removeLightSource(light: Light, dispose: boolean): void;
  15095. /**
  15096. * If the source mesh receives shadows
  15097. */
  15098. get receiveShadows(): boolean;
  15099. /**
  15100. * The material of the source mesh
  15101. */
  15102. get material(): Nullable<Material>;
  15103. /**
  15104. * Visibility of the source mesh
  15105. */
  15106. get visibility(): number;
  15107. /**
  15108. * Skeleton of the source mesh
  15109. */
  15110. get skeleton(): Nullable<Skeleton>;
  15111. /**
  15112. * Rendering ground id of the source mesh
  15113. */
  15114. get renderingGroupId(): number;
  15115. set renderingGroupId(value: number);
  15116. /**
  15117. * Returns the total number of vertices (integer).
  15118. */
  15119. getTotalVertices(): number;
  15120. /**
  15121. * Returns a positive integer : the total number of indices in this mesh geometry.
  15122. * @returns the numner of indices or zero if the mesh has no geometry.
  15123. */
  15124. getTotalIndices(): number;
  15125. /**
  15126. * The source mesh of the instance
  15127. */
  15128. get sourceMesh(): Mesh;
  15129. /**
  15130. * Is this node ready to be used/rendered
  15131. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15132. * @return {boolean} is it ready
  15133. */
  15134. isReady(completeCheck?: boolean): boolean;
  15135. /**
  15136. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15137. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15138. * @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.
  15139. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15140. */
  15141. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15142. /**
  15143. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15144. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15145. * The `data` are either a numeric array either a Float32Array.
  15146. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15147. * 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).
  15148. * Note that a new underlying VertexBuffer object is created each call.
  15149. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15150. *
  15151. * Possible `kind` values :
  15152. * - VertexBuffer.PositionKind
  15153. * - VertexBuffer.UVKind
  15154. * - VertexBuffer.UV2Kind
  15155. * - VertexBuffer.UV3Kind
  15156. * - VertexBuffer.UV4Kind
  15157. * - VertexBuffer.UV5Kind
  15158. * - VertexBuffer.UV6Kind
  15159. * - VertexBuffer.ColorKind
  15160. * - VertexBuffer.MatricesIndicesKind
  15161. * - VertexBuffer.MatricesIndicesExtraKind
  15162. * - VertexBuffer.MatricesWeightsKind
  15163. * - VertexBuffer.MatricesWeightsExtraKind
  15164. *
  15165. * Returns the Mesh.
  15166. */
  15167. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15168. /**
  15169. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15170. * If the mesh has no geometry, it is simply returned as it is.
  15171. * The `data` are either a numeric array either a Float32Array.
  15172. * No new underlying VertexBuffer object is created.
  15173. * 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.
  15174. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15175. *
  15176. * Possible `kind` values :
  15177. * - VertexBuffer.PositionKind
  15178. * - VertexBuffer.UVKind
  15179. * - VertexBuffer.UV2Kind
  15180. * - VertexBuffer.UV3Kind
  15181. * - VertexBuffer.UV4Kind
  15182. * - VertexBuffer.UV5Kind
  15183. * - VertexBuffer.UV6Kind
  15184. * - VertexBuffer.ColorKind
  15185. * - VertexBuffer.MatricesIndicesKind
  15186. * - VertexBuffer.MatricesIndicesExtraKind
  15187. * - VertexBuffer.MatricesWeightsKind
  15188. * - VertexBuffer.MatricesWeightsExtraKind
  15189. *
  15190. * Returns the Mesh.
  15191. */
  15192. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15193. /**
  15194. * Sets the mesh indices.
  15195. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15196. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15197. * This method creates a new index buffer each call.
  15198. * Returns the Mesh.
  15199. */
  15200. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15201. /**
  15202. * Boolean : True if the mesh owns the requested kind of data.
  15203. */
  15204. isVerticesDataPresent(kind: string): boolean;
  15205. /**
  15206. * Returns an array of indices (IndicesArray).
  15207. */
  15208. getIndices(): Nullable<IndicesArray>;
  15209. get _positions(): Nullable<Vector3[]>;
  15210. /**
  15211. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15212. * This means the mesh underlying bounding box and sphere are recomputed.
  15213. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15214. * @returns the current mesh
  15215. */
  15216. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15217. /** @hidden */
  15218. _preActivate(): InstancedMesh;
  15219. /** @hidden */
  15220. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15221. /** @hidden */
  15222. _postActivate(): void;
  15223. getWorldMatrix(): Matrix;
  15224. get isAnInstance(): boolean;
  15225. /**
  15226. * Returns the current associated LOD AbstractMesh.
  15227. */
  15228. getLOD(camera: Camera): AbstractMesh;
  15229. /** @hidden */
  15230. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15231. /** @hidden */
  15232. _syncSubMeshes(): InstancedMesh;
  15233. /** @hidden */
  15234. _generatePointsArray(): boolean;
  15235. /**
  15236. * Creates a new InstancedMesh from the current mesh.
  15237. * - name (string) : the cloned mesh name
  15238. * - newParent (optional Node) : the optional Node to parent the clone to.
  15239. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15240. *
  15241. * Returns the clone.
  15242. */
  15243. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15244. /**
  15245. * Disposes the InstancedMesh.
  15246. * Returns nothing.
  15247. */
  15248. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15249. }
  15250. interface Mesh {
  15251. /**
  15252. * Register a custom buffer that will be instanced
  15253. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15254. * @param kind defines the buffer kind
  15255. * @param stride defines the stride in floats
  15256. */
  15257. registerInstancedBuffer(kind: string, stride: number): void;
  15258. /** @hidden */
  15259. _userInstancedBuffersStorage: {
  15260. data: {
  15261. [key: string]: Float32Array;
  15262. };
  15263. sizes: {
  15264. [key: string]: number;
  15265. };
  15266. vertexBuffers: {
  15267. [key: string]: Nullable<VertexBuffer>;
  15268. };
  15269. strides: {
  15270. [key: string]: number;
  15271. };
  15272. };
  15273. }
  15274. interface AbstractMesh {
  15275. /**
  15276. * Object used to store instanced buffers defined by user
  15277. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15278. */
  15279. instancedBuffers: {
  15280. [key: string]: any;
  15281. };
  15282. }
  15283. }
  15284. declare module BABYLON {
  15285. /**
  15286. * Defines the options associated with the creation of a shader material.
  15287. */
  15288. export interface IShaderMaterialOptions {
  15289. /**
  15290. * Does the material work in alpha blend mode
  15291. */
  15292. needAlphaBlending: boolean;
  15293. /**
  15294. * Does the material work in alpha test mode
  15295. */
  15296. needAlphaTesting: boolean;
  15297. /**
  15298. * The list of attribute names used in the shader
  15299. */
  15300. attributes: string[];
  15301. /**
  15302. * The list of unifrom names used in the shader
  15303. */
  15304. uniforms: string[];
  15305. /**
  15306. * The list of UBO names used in the shader
  15307. */
  15308. uniformBuffers: string[];
  15309. /**
  15310. * The list of sampler names used in the shader
  15311. */
  15312. samplers: string[];
  15313. /**
  15314. * The list of defines used in the shader
  15315. */
  15316. defines: string[];
  15317. }
  15318. /**
  15319. * 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.
  15320. *
  15321. * This returned material effects how the mesh will look based on the code in the shaders.
  15322. *
  15323. * @see http://doc.babylonjs.com/how_to/shader_material
  15324. */
  15325. export class ShaderMaterial extends Material {
  15326. private _shaderPath;
  15327. private _options;
  15328. private _textures;
  15329. private _textureArrays;
  15330. private _floats;
  15331. private _ints;
  15332. private _floatsArrays;
  15333. private _colors3;
  15334. private _colors3Arrays;
  15335. private _colors4;
  15336. private _colors4Arrays;
  15337. private _vectors2;
  15338. private _vectors3;
  15339. private _vectors4;
  15340. private _matrices;
  15341. private _matrixArrays;
  15342. private _matrices3x3;
  15343. private _matrices2x2;
  15344. private _vectors2Arrays;
  15345. private _vectors3Arrays;
  15346. private _vectors4Arrays;
  15347. private _cachedWorldViewMatrix;
  15348. private _cachedWorldViewProjectionMatrix;
  15349. private _renderId;
  15350. private _multiview;
  15351. /**
  15352. * Instantiate a new shader material.
  15353. * 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.
  15354. * This returned material effects how the mesh will look based on the code in the shaders.
  15355. * @see http://doc.babylonjs.com/how_to/shader_material
  15356. * @param name Define the name of the material in the scene
  15357. * @param scene Define the scene the material belongs to
  15358. * @param shaderPath Defines the route to the shader code in one of three ways:
  15359. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15360. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15361. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15362. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15363. * @param options Define the options used to create the shader
  15364. */
  15365. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15366. /**
  15367. * Gets the shader path used to define the shader code
  15368. * It can be modified to trigger a new compilation
  15369. */
  15370. get shaderPath(): any;
  15371. /**
  15372. * Sets the shader path used to define the shader code
  15373. * It can be modified to trigger a new compilation
  15374. */
  15375. set shaderPath(shaderPath: any);
  15376. /**
  15377. * Gets the options used to compile the shader.
  15378. * They can be modified to trigger a new compilation
  15379. */
  15380. get options(): IShaderMaterialOptions;
  15381. /**
  15382. * Gets the current class name of the material e.g. "ShaderMaterial"
  15383. * Mainly use in serialization.
  15384. * @returns the class name
  15385. */
  15386. getClassName(): string;
  15387. /**
  15388. * Specifies if the material will require alpha blending
  15389. * @returns a boolean specifying if alpha blending is needed
  15390. */
  15391. needAlphaBlending(): boolean;
  15392. /**
  15393. * Specifies if this material should be rendered in alpha test mode
  15394. * @returns a boolean specifying if an alpha test is needed.
  15395. */
  15396. needAlphaTesting(): boolean;
  15397. private _checkUniform;
  15398. /**
  15399. * Set a texture in the shader.
  15400. * @param name Define the name of the uniform samplers as defined in the shader
  15401. * @param texture Define the texture to bind to this sampler
  15402. * @return the material itself allowing "fluent" like uniform updates
  15403. */
  15404. setTexture(name: string, texture: Texture): ShaderMaterial;
  15405. /**
  15406. * Set a texture array in the shader.
  15407. * @param name Define the name of the uniform sampler array as defined in the shader
  15408. * @param textures Define the list of textures to bind to this sampler
  15409. * @return the material itself allowing "fluent" like uniform updates
  15410. */
  15411. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15412. /**
  15413. * Set a float in the shader.
  15414. * @param name Define the name of the uniform as defined in the shader
  15415. * @param value Define the value to give to the uniform
  15416. * @return the material itself allowing "fluent" like uniform updates
  15417. */
  15418. setFloat(name: string, value: number): ShaderMaterial;
  15419. /**
  15420. * Set a int in the shader.
  15421. * @param name Define the name of the uniform as defined in the shader
  15422. * @param value Define the value to give to the uniform
  15423. * @return the material itself allowing "fluent" like uniform updates
  15424. */
  15425. setInt(name: string, value: number): ShaderMaterial;
  15426. /**
  15427. * Set an array of floats in the shader.
  15428. * @param name Define the name of the uniform as defined in the shader
  15429. * @param value Define the value to give to the uniform
  15430. * @return the material itself allowing "fluent" like uniform updates
  15431. */
  15432. setFloats(name: string, value: number[]): ShaderMaterial;
  15433. /**
  15434. * Set a vec3 in the shader from a Color3.
  15435. * @param name Define the name of the uniform as defined in the shader
  15436. * @param value Define the value to give to the uniform
  15437. * @return the material itself allowing "fluent" like uniform updates
  15438. */
  15439. setColor3(name: string, value: Color3): ShaderMaterial;
  15440. /**
  15441. * Set a vec3 array in the shader from a Color3 array.
  15442. * @param name Define the name of the uniform as defined in the shader
  15443. * @param value Define the value to give to the uniform
  15444. * @return the material itself allowing "fluent" like uniform updates
  15445. */
  15446. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15447. /**
  15448. * Set a vec4 in the shader from a Color4.
  15449. * @param name Define the name of the uniform as defined in the shader
  15450. * @param value Define the value to give to the uniform
  15451. * @return the material itself allowing "fluent" like uniform updates
  15452. */
  15453. setColor4(name: string, value: Color4): ShaderMaterial;
  15454. /**
  15455. * Set a vec4 array in the shader from a Color4 array.
  15456. * @param name Define the name of the uniform as defined in the shader
  15457. * @param value Define the value to give to the uniform
  15458. * @return the material itself allowing "fluent" like uniform updates
  15459. */
  15460. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15461. /**
  15462. * Set a vec2 in the shader from a Vector2.
  15463. * @param name Define the name of the uniform as defined in the shader
  15464. * @param value Define the value to give to the uniform
  15465. * @return the material itself allowing "fluent" like uniform updates
  15466. */
  15467. setVector2(name: string, value: Vector2): ShaderMaterial;
  15468. /**
  15469. * Set a vec3 in the shader from a Vector3.
  15470. * @param name Define the name of the uniform as defined in the shader
  15471. * @param value Define the value to give to the uniform
  15472. * @return the material itself allowing "fluent" like uniform updates
  15473. */
  15474. setVector3(name: string, value: Vector3): ShaderMaterial;
  15475. /**
  15476. * Set a vec4 in the shader from a Vector4.
  15477. * @param name Define the name of the uniform as defined in the shader
  15478. * @param value Define the value to give to the uniform
  15479. * @return the material itself allowing "fluent" like uniform updates
  15480. */
  15481. setVector4(name: string, value: Vector4): ShaderMaterial;
  15482. /**
  15483. * Set a mat4 in the shader from a Matrix.
  15484. * @param name Define the name of the uniform as defined in the shader
  15485. * @param value Define the value to give to the uniform
  15486. * @return the material itself allowing "fluent" like uniform updates
  15487. */
  15488. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15489. /**
  15490. * Set a float32Array in the shader from a matrix array.
  15491. * @param name Define the name of the uniform as defined in the shader
  15492. * @param value Define the value to give to the uniform
  15493. * @return the material itself allowing "fluent" like uniform updates
  15494. */
  15495. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15496. /**
  15497. * Set a mat3 in the shader from a Float32Array.
  15498. * @param name Define the name of the uniform as defined in the shader
  15499. * @param value Define the value to give to the uniform
  15500. * @return the material itself allowing "fluent" like uniform updates
  15501. */
  15502. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15503. /**
  15504. * Set a mat2 in the shader from a Float32Array.
  15505. * @param name Define the name of the uniform as defined in the shader
  15506. * @param value Define the value to give to the uniform
  15507. * @return the material itself allowing "fluent" like uniform updates
  15508. */
  15509. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15510. /**
  15511. * Set a vec2 array in the shader from a number array.
  15512. * @param name Define the name of the uniform as defined in the shader
  15513. * @param value Define the value to give to the uniform
  15514. * @return the material itself allowing "fluent" like uniform updates
  15515. */
  15516. setArray2(name: string, value: number[]): ShaderMaterial;
  15517. /**
  15518. * Set a vec3 array in the shader from a number array.
  15519. * @param name Define the name of the uniform as defined in the shader
  15520. * @param value Define the value to give to the uniform
  15521. * @return the material itself allowing "fluent" like uniform updates
  15522. */
  15523. setArray3(name: string, value: number[]): ShaderMaterial;
  15524. /**
  15525. * Set a vec4 array in the shader from a number array.
  15526. * @param name Define the name of the uniform as defined in the shader
  15527. * @param value Define the value to give to the uniform
  15528. * @return the material itself allowing "fluent" like uniform updates
  15529. */
  15530. setArray4(name: string, value: number[]): ShaderMaterial;
  15531. private _checkCache;
  15532. /**
  15533. * Specifies that the submesh is ready to be used
  15534. * @param mesh defines the mesh to check
  15535. * @param subMesh defines which submesh to check
  15536. * @param useInstances specifies that instances should be used
  15537. * @returns a boolean indicating that the submesh is ready or not
  15538. */
  15539. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15540. /**
  15541. * Checks if the material is ready to render the requested mesh
  15542. * @param mesh Define the mesh to render
  15543. * @param useInstances Define whether or not the material is used with instances
  15544. * @returns true if ready, otherwise false
  15545. */
  15546. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15547. /**
  15548. * Binds the world matrix to the material
  15549. * @param world defines the world transformation matrix
  15550. */
  15551. bindOnlyWorldMatrix(world: Matrix): void;
  15552. /**
  15553. * Binds the material to the mesh
  15554. * @param world defines the world transformation matrix
  15555. * @param mesh defines the mesh to bind the material to
  15556. */
  15557. bind(world: Matrix, mesh?: Mesh): void;
  15558. /**
  15559. * Gets the active textures from the material
  15560. * @returns an array of textures
  15561. */
  15562. getActiveTextures(): BaseTexture[];
  15563. /**
  15564. * Specifies if the material uses a texture
  15565. * @param texture defines the texture to check against the material
  15566. * @returns a boolean specifying if the material uses the texture
  15567. */
  15568. hasTexture(texture: BaseTexture): boolean;
  15569. /**
  15570. * Makes a duplicate of the material, and gives it a new name
  15571. * @param name defines the new name for the duplicated material
  15572. * @returns the cloned material
  15573. */
  15574. clone(name: string): ShaderMaterial;
  15575. /**
  15576. * Disposes the material
  15577. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15578. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15579. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15580. */
  15581. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15582. /**
  15583. * Serializes this material in a JSON representation
  15584. * @returns the serialized material object
  15585. */
  15586. serialize(): any;
  15587. /**
  15588. * Creates a shader material from parsed shader material data
  15589. * @param source defines the JSON represnetation of the material
  15590. * @param scene defines the hosting scene
  15591. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15592. * @returns a new material
  15593. */
  15594. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15595. }
  15596. }
  15597. declare module BABYLON {
  15598. /** @hidden */
  15599. export var colorPixelShader: {
  15600. name: string;
  15601. shader: string;
  15602. };
  15603. }
  15604. declare module BABYLON {
  15605. /** @hidden */
  15606. export var colorVertexShader: {
  15607. name: string;
  15608. shader: string;
  15609. };
  15610. }
  15611. declare module BABYLON {
  15612. /**
  15613. * Line mesh
  15614. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15615. */
  15616. export class LinesMesh extends Mesh {
  15617. /**
  15618. * If vertex color should be applied to the mesh
  15619. */
  15620. readonly useVertexColor?: boolean | undefined;
  15621. /**
  15622. * If vertex alpha should be applied to the mesh
  15623. */
  15624. readonly useVertexAlpha?: boolean | undefined;
  15625. /**
  15626. * Color of the line (Default: White)
  15627. */
  15628. color: Color3;
  15629. /**
  15630. * Alpha of the line (Default: 1)
  15631. */
  15632. alpha: number;
  15633. /**
  15634. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15635. * This margin is expressed in world space coordinates, so its value may vary.
  15636. * Default value is 0.1
  15637. */
  15638. intersectionThreshold: number;
  15639. private _colorShader;
  15640. private color4;
  15641. /**
  15642. * Creates a new LinesMesh
  15643. * @param name defines the name
  15644. * @param scene defines the hosting scene
  15645. * @param parent defines the parent mesh if any
  15646. * @param source defines the optional source LinesMesh used to clone data from
  15647. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15648. * When false, achieved by calling a clone(), also passing False.
  15649. * This will make creation of children, recursive.
  15650. * @param useVertexColor defines if this LinesMesh supports vertex color
  15651. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15652. */
  15653. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15654. /**
  15655. * If vertex color should be applied to the mesh
  15656. */
  15657. useVertexColor?: boolean | undefined,
  15658. /**
  15659. * If vertex alpha should be applied to the mesh
  15660. */
  15661. useVertexAlpha?: boolean | undefined);
  15662. private _addClipPlaneDefine;
  15663. private _removeClipPlaneDefine;
  15664. isReady(): boolean;
  15665. /**
  15666. * Returns the string "LineMesh"
  15667. */
  15668. getClassName(): string;
  15669. /**
  15670. * @hidden
  15671. */
  15672. get material(): Material;
  15673. /**
  15674. * @hidden
  15675. */
  15676. set material(value: Material);
  15677. /**
  15678. * @hidden
  15679. */
  15680. get checkCollisions(): boolean;
  15681. /** @hidden */
  15682. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15683. /** @hidden */
  15684. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15685. /**
  15686. * Disposes of the line mesh
  15687. * @param doNotRecurse If children should be disposed
  15688. */
  15689. dispose(doNotRecurse?: boolean): void;
  15690. /**
  15691. * Returns a new LineMesh object cloned from the current one.
  15692. */
  15693. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15694. /**
  15695. * Creates a new InstancedLinesMesh object from the mesh model.
  15696. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15697. * @param name defines the name of the new instance
  15698. * @returns a new InstancedLinesMesh
  15699. */
  15700. createInstance(name: string): InstancedLinesMesh;
  15701. }
  15702. /**
  15703. * Creates an instance based on a source LinesMesh
  15704. */
  15705. export class InstancedLinesMesh extends InstancedMesh {
  15706. /**
  15707. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15708. * This margin is expressed in world space coordinates, so its value may vary.
  15709. * Initilized with the intersectionThreshold value of the source LinesMesh
  15710. */
  15711. intersectionThreshold: number;
  15712. constructor(name: string, source: LinesMesh);
  15713. /**
  15714. * Returns the string "InstancedLinesMesh".
  15715. */
  15716. getClassName(): string;
  15717. }
  15718. }
  15719. declare module BABYLON {
  15720. /** @hidden */
  15721. export var linePixelShader: {
  15722. name: string;
  15723. shader: string;
  15724. };
  15725. }
  15726. declare module BABYLON {
  15727. /** @hidden */
  15728. export var lineVertexShader: {
  15729. name: string;
  15730. shader: string;
  15731. };
  15732. }
  15733. declare module BABYLON {
  15734. interface AbstractMesh {
  15735. /**
  15736. * Gets the edgesRenderer associated with the mesh
  15737. */
  15738. edgesRenderer: Nullable<EdgesRenderer>;
  15739. }
  15740. interface LinesMesh {
  15741. /**
  15742. * Enables the edge rendering mode on the mesh.
  15743. * This mode makes the mesh edges visible
  15744. * @param epsilon defines the maximal distance between two angles to detect a face
  15745. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15746. * @returns the currentAbstractMesh
  15747. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15748. */
  15749. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15750. }
  15751. interface InstancedLinesMesh {
  15752. /**
  15753. * Enables the edge rendering mode on the mesh.
  15754. * This mode makes the mesh edges visible
  15755. * @param epsilon defines the maximal distance between two angles to detect a face
  15756. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15757. * @returns the current InstancedLinesMesh
  15758. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15759. */
  15760. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15761. }
  15762. /**
  15763. * Defines the minimum contract an Edges renderer should follow.
  15764. */
  15765. export interface IEdgesRenderer extends IDisposable {
  15766. /**
  15767. * Gets or sets a boolean indicating if the edgesRenderer is active
  15768. */
  15769. isEnabled: boolean;
  15770. /**
  15771. * Renders the edges of the attached mesh,
  15772. */
  15773. render(): void;
  15774. /**
  15775. * Checks wether or not the edges renderer is ready to render.
  15776. * @return true if ready, otherwise false.
  15777. */
  15778. isReady(): boolean;
  15779. }
  15780. /**
  15781. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15782. */
  15783. export class EdgesRenderer implements IEdgesRenderer {
  15784. /**
  15785. * Define the size of the edges with an orthographic camera
  15786. */
  15787. edgesWidthScalerForOrthographic: number;
  15788. /**
  15789. * Define the size of the edges with a perspective camera
  15790. */
  15791. edgesWidthScalerForPerspective: number;
  15792. protected _source: AbstractMesh;
  15793. protected _linesPositions: number[];
  15794. protected _linesNormals: number[];
  15795. protected _linesIndices: number[];
  15796. protected _epsilon: number;
  15797. protected _indicesCount: number;
  15798. protected _lineShader: ShaderMaterial;
  15799. protected _ib: DataBuffer;
  15800. protected _buffers: {
  15801. [key: string]: Nullable<VertexBuffer>;
  15802. };
  15803. protected _checkVerticesInsteadOfIndices: boolean;
  15804. private _meshRebuildObserver;
  15805. private _meshDisposeObserver;
  15806. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15807. isEnabled: boolean;
  15808. /**
  15809. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15810. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15811. * @param source Mesh used to create edges
  15812. * @param epsilon sum of angles in adjacency to check for edge
  15813. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15814. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15815. */
  15816. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15817. protected _prepareRessources(): void;
  15818. /** @hidden */
  15819. _rebuild(): void;
  15820. /**
  15821. * Releases the required resources for the edges renderer
  15822. */
  15823. dispose(): void;
  15824. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15825. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15826. /**
  15827. * Checks if the pair of p0 and p1 is en edge
  15828. * @param faceIndex
  15829. * @param edge
  15830. * @param faceNormals
  15831. * @param p0
  15832. * @param p1
  15833. * @private
  15834. */
  15835. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15836. /**
  15837. * push line into the position, normal and index buffer
  15838. * @protected
  15839. */
  15840. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15841. /**
  15842. * Generates lines edges from adjacencjes
  15843. * @private
  15844. */
  15845. _generateEdgesLines(): void;
  15846. /**
  15847. * Checks wether or not the edges renderer is ready to render.
  15848. * @return true if ready, otherwise false.
  15849. */
  15850. isReady(): boolean;
  15851. /**
  15852. * Renders the edges of the attached mesh,
  15853. */
  15854. render(): void;
  15855. }
  15856. /**
  15857. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15858. */
  15859. export class LineEdgesRenderer extends EdgesRenderer {
  15860. /**
  15861. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15862. * @param source LineMesh used to generate edges
  15863. * @param epsilon not important (specified angle for edge detection)
  15864. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15865. */
  15866. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15867. /**
  15868. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15869. */
  15870. _generateEdgesLines(): void;
  15871. }
  15872. }
  15873. declare module BABYLON {
  15874. /**
  15875. * This represents the object necessary to create a rendering group.
  15876. * This is exclusively used and created by the rendering manager.
  15877. * To modify the behavior, you use the available helpers in your scene or meshes.
  15878. * @hidden
  15879. */
  15880. export class RenderingGroup {
  15881. index: number;
  15882. private static _zeroVector;
  15883. private _scene;
  15884. private _opaqueSubMeshes;
  15885. private _transparentSubMeshes;
  15886. private _alphaTestSubMeshes;
  15887. private _depthOnlySubMeshes;
  15888. private _particleSystems;
  15889. private _spriteManagers;
  15890. private _opaqueSortCompareFn;
  15891. private _alphaTestSortCompareFn;
  15892. private _transparentSortCompareFn;
  15893. private _renderOpaque;
  15894. private _renderAlphaTest;
  15895. private _renderTransparent;
  15896. /** @hidden */
  15897. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15898. onBeforeTransparentRendering: () => void;
  15899. /**
  15900. * Set the opaque sort comparison function.
  15901. * If null the sub meshes will be render in the order they were created
  15902. */
  15903. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15904. /**
  15905. * Set the alpha test sort comparison function.
  15906. * If null the sub meshes will be render in the order they were created
  15907. */
  15908. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15909. /**
  15910. * Set the transparent sort comparison function.
  15911. * If null the sub meshes will be render in the order they were created
  15912. */
  15913. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15914. /**
  15915. * Creates a new rendering group.
  15916. * @param index The rendering group index
  15917. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15918. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15919. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15920. */
  15921. 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>);
  15922. /**
  15923. * Render all the sub meshes contained in the group.
  15924. * @param customRenderFunction Used to override the default render behaviour of the group.
  15925. * @returns true if rendered some submeshes.
  15926. */
  15927. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15928. /**
  15929. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15930. * @param subMeshes The submeshes to render
  15931. */
  15932. private renderOpaqueSorted;
  15933. /**
  15934. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15935. * @param subMeshes The submeshes to render
  15936. */
  15937. private renderAlphaTestSorted;
  15938. /**
  15939. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15940. * @param subMeshes The submeshes to render
  15941. */
  15942. private renderTransparentSorted;
  15943. /**
  15944. * Renders the submeshes in a specified order.
  15945. * @param subMeshes The submeshes to sort before render
  15946. * @param sortCompareFn The comparison function use to sort
  15947. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15948. * @param transparent Specifies to activate blending if true
  15949. */
  15950. private static renderSorted;
  15951. /**
  15952. * Renders the submeshes in the order they were dispatched (no sort applied).
  15953. * @param subMeshes The submeshes to render
  15954. */
  15955. private static renderUnsorted;
  15956. /**
  15957. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15958. * are rendered back to front if in the same alpha index.
  15959. *
  15960. * @param a The first submesh
  15961. * @param b The second submesh
  15962. * @returns The result of the comparison
  15963. */
  15964. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15965. /**
  15966. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15967. * are rendered back to front.
  15968. *
  15969. * @param a The first submesh
  15970. * @param b The second submesh
  15971. * @returns The result of the comparison
  15972. */
  15973. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15974. /**
  15975. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15976. * are rendered front to back (prevent overdraw).
  15977. *
  15978. * @param a The first submesh
  15979. * @param b The second submesh
  15980. * @returns The result of the comparison
  15981. */
  15982. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15983. /**
  15984. * Resets the different lists of submeshes to prepare a new frame.
  15985. */
  15986. prepare(): void;
  15987. dispose(): void;
  15988. /**
  15989. * Inserts the submesh in its correct queue depending on its material.
  15990. * @param subMesh The submesh to dispatch
  15991. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15992. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15993. */
  15994. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15995. dispatchSprites(spriteManager: ISpriteManager): void;
  15996. dispatchParticles(particleSystem: IParticleSystem): void;
  15997. private _renderParticles;
  15998. private _renderSprites;
  15999. }
  16000. }
  16001. declare module BABYLON {
  16002. /**
  16003. * Interface describing the different options available in the rendering manager
  16004. * regarding Auto Clear between groups.
  16005. */
  16006. export interface IRenderingManagerAutoClearSetup {
  16007. /**
  16008. * Defines whether or not autoclear is enable.
  16009. */
  16010. autoClear: boolean;
  16011. /**
  16012. * Defines whether or not to autoclear the depth buffer.
  16013. */
  16014. depth: boolean;
  16015. /**
  16016. * Defines whether or not to autoclear the stencil buffer.
  16017. */
  16018. stencil: boolean;
  16019. }
  16020. /**
  16021. * This class is used by the onRenderingGroupObservable
  16022. */
  16023. export class RenderingGroupInfo {
  16024. /**
  16025. * The Scene that being rendered
  16026. */
  16027. scene: Scene;
  16028. /**
  16029. * The camera currently used for the rendering pass
  16030. */
  16031. camera: Nullable<Camera>;
  16032. /**
  16033. * The ID of the renderingGroup being processed
  16034. */
  16035. renderingGroupId: number;
  16036. }
  16037. /**
  16038. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16039. * It is enable to manage the different groups as well as the different necessary sort functions.
  16040. * This should not be used directly aside of the few static configurations
  16041. */
  16042. export class RenderingManager {
  16043. /**
  16044. * The max id used for rendering groups (not included)
  16045. */
  16046. static MAX_RENDERINGGROUPS: number;
  16047. /**
  16048. * The min id used for rendering groups (included)
  16049. */
  16050. static MIN_RENDERINGGROUPS: number;
  16051. /**
  16052. * Used to globally prevent autoclearing scenes.
  16053. */
  16054. static AUTOCLEAR: boolean;
  16055. /**
  16056. * @hidden
  16057. */
  16058. _useSceneAutoClearSetup: boolean;
  16059. private _scene;
  16060. private _renderingGroups;
  16061. private _depthStencilBufferAlreadyCleaned;
  16062. private _autoClearDepthStencil;
  16063. private _customOpaqueSortCompareFn;
  16064. private _customAlphaTestSortCompareFn;
  16065. private _customTransparentSortCompareFn;
  16066. private _renderingGroupInfo;
  16067. /**
  16068. * Instantiates a new rendering group for a particular scene
  16069. * @param scene Defines the scene the groups belongs to
  16070. */
  16071. constructor(scene: Scene);
  16072. private _clearDepthStencilBuffer;
  16073. /**
  16074. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16075. * @hidden
  16076. */
  16077. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16078. /**
  16079. * Resets the different information of the group to prepare a new frame
  16080. * @hidden
  16081. */
  16082. reset(): void;
  16083. /**
  16084. * Dispose and release the group and its associated resources.
  16085. * @hidden
  16086. */
  16087. dispose(): void;
  16088. /**
  16089. * Clear the info related to rendering groups preventing retention points during dispose.
  16090. */
  16091. freeRenderingGroups(): void;
  16092. private _prepareRenderingGroup;
  16093. /**
  16094. * Add a sprite manager to the rendering manager in order to render it this frame.
  16095. * @param spriteManager Define the sprite manager to render
  16096. */
  16097. dispatchSprites(spriteManager: ISpriteManager): void;
  16098. /**
  16099. * Add a particle system to the rendering manager in order to render it this frame.
  16100. * @param particleSystem Define the particle system to render
  16101. */
  16102. dispatchParticles(particleSystem: IParticleSystem): void;
  16103. /**
  16104. * Add a submesh to the manager in order to render it this frame
  16105. * @param subMesh The submesh to dispatch
  16106. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16107. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16108. */
  16109. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16110. /**
  16111. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16112. * This allowed control for front to back rendering or reversly depending of the special needs.
  16113. *
  16114. * @param renderingGroupId The rendering group id corresponding to its index
  16115. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16116. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16117. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16118. */
  16119. 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;
  16120. /**
  16121. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16122. *
  16123. * @param renderingGroupId The rendering group id corresponding to its index
  16124. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16125. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16126. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16127. */
  16128. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16129. /**
  16130. * Gets the current auto clear configuration for one rendering group of the rendering
  16131. * manager.
  16132. * @param index the rendering group index to get the information for
  16133. * @returns The auto clear setup for the requested rendering group
  16134. */
  16135. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16136. }
  16137. }
  16138. declare module BABYLON {
  16139. /**
  16140. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16141. */
  16142. export interface ICustomShaderOptions {
  16143. /**
  16144. * Gets or sets the custom shader name to use
  16145. */
  16146. shaderName: string;
  16147. /**
  16148. * The list of attribute names used in the shader
  16149. */
  16150. attributes?: string[];
  16151. /**
  16152. * The list of unifrom names used in the shader
  16153. */
  16154. uniforms?: string[];
  16155. /**
  16156. * The list of sampler names used in the shader
  16157. */
  16158. samplers?: string[];
  16159. /**
  16160. * The list of defines used in the shader
  16161. */
  16162. defines?: string[];
  16163. }
  16164. /**
  16165. * Interface to implement to create a shadow generator compatible with BJS.
  16166. */
  16167. export interface IShadowGenerator {
  16168. /**
  16169. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16170. * @returns The render target texture if present otherwise, null
  16171. */
  16172. getShadowMap(): Nullable<RenderTargetTexture>;
  16173. /**
  16174. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16175. * @param subMesh The submesh we want to render in the shadow map
  16176. * @param useInstances Defines wether will draw in the map using instances
  16177. * @returns true if ready otherwise, false
  16178. */
  16179. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16180. /**
  16181. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16182. * @param defines Defines of the material we want to update
  16183. * @param lightIndex Index of the light in the enabled light list of the material
  16184. */
  16185. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16186. /**
  16187. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16188. * defined in the generator but impacting the effect).
  16189. * It implies the unifroms available on the materials are the standard BJS ones.
  16190. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16191. * @param effect The effect we are binfing the information for
  16192. */
  16193. bindShadowLight(lightIndex: string, effect: Effect): void;
  16194. /**
  16195. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16196. * (eq to shadow prjection matrix * light transform matrix)
  16197. * @returns The transform matrix used to create the shadow map
  16198. */
  16199. getTransformMatrix(): Matrix;
  16200. /**
  16201. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16202. * Cube and 2D textures for instance.
  16203. */
  16204. recreateShadowMap(): void;
  16205. /**
  16206. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16207. * @param onCompiled Callback triggered at the and of the effects compilation
  16208. * @param options Sets of optional options forcing the compilation with different modes
  16209. */
  16210. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16211. useInstances: boolean;
  16212. }>): void;
  16213. /**
  16214. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16215. * @param options Sets of optional options forcing the compilation with different modes
  16216. * @returns A promise that resolves when the compilation completes
  16217. */
  16218. forceCompilationAsync(options?: Partial<{
  16219. useInstances: boolean;
  16220. }>): Promise<void>;
  16221. /**
  16222. * Serializes the shadow generator setup to a json object.
  16223. * @returns The serialized JSON object
  16224. */
  16225. serialize(): any;
  16226. /**
  16227. * Disposes the Shadow map and related Textures and effects.
  16228. */
  16229. dispose(): void;
  16230. }
  16231. /**
  16232. * Default implementation IShadowGenerator.
  16233. * This is the main object responsible of generating shadows in the framework.
  16234. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16235. */
  16236. export class ShadowGenerator implements IShadowGenerator {
  16237. /**
  16238. * Name of the shadow generator class
  16239. */
  16240. static CLASSNAME: string;
  16241. /**
  16242. * Shadow generator mode None: no filtering applied.
  16243. */
  16244. static readonly FILTER_NONE: number;
  16245. /**
  16246. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16247. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16248. */
  16249. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16250. /**
  16251. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16252. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16253. */
  16254. static readonly FILTER_POISSONSAMPLING: number;
  16255. /**
  16256. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16257. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16258. */
  16259. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16260. /**
  16261. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16262. * edge artifacts on steep falloff.
  16263. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16264. */
  16265. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16266. /**
  16267. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16268. * edge artifacts on steep falloff.
  16269. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16270. */
  16271. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16272. /**
  16273. * Shadow generator mode PCF: Percentage Closer Filtering
  16274. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16275. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16276. */
  16277. static readonly FILTER_PCF: number;
  16278. /**
  16279. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16280. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16281. * Contact Hardening
  16282. */
  16283. static readonly FILTER_PCSS: number;
  16284. /**
  16285. * Reserved for PCF and PCSS
  16286. * Highest Quality.
  16287. *
  16288. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16289. *
  16290. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16291. */
  16292. static readonly QUALITY_HIGH: number;
  16293. /**
  16294. * Reserved for PCF and PCSS
  16295. * Good tradeoff for quality/perf cross devices
  16296. *
  16297. * Execute PCF on a 3*3 kernel.
  16298. *
  16299. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16300. */
  16301. static readonly QUALITY_MEDIUM: number;
  16302. /**
  16303. * Reserved for PCF and PCSS
  16304. * The lowest quality but the fastest.
  16305. *
  16306. * Execute PCF on a 1*1 kernel.
  16307. *
  16308. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16309. */
  16310. static readonly QUALITY_LOW: number;
  16311. /** Gets or sets the custom shader name to use */
  16312. customShaderOptions: ICustomShaderOptions;
  16313. /**
  16314. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16315. */
  16316. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16317. /**
  16318. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16319. */
  16320. onAfterShadowMapRenderObservable: Observable<Effect>;
  16321. /**
  16322. * Observable triggered before a mesh is rendered in the shadow map.
  16323. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16324. */
  16325. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16326. /**
  16327. * Observable triggered after a mesh is rendered in the shadow map.
  16328. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16329. */
  16330. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16331. protected _bias: number;
  16332. /**
  16333. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16334. */
  16335. get bias(): number;
  16336. /**
  16337. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16338. */
  16339. set bias(bias: number);
  16340. protected _normalBias: number;
  16341. /**
  16342. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16343. */
  16344. get normalBias(): number;
  16345. /**
  16346. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16347. */
  16348. set normalBias(normalBias: number);
  16349. protected _blurBoxOffset: number;
  16350. /**
  16351. * Gets the blur box offset: offset applied during the blur pass.
  16352. * Only useful if useKernelBlur = false
  16353. */
  16354. get blurBoxOffset(): number;
  16355. /**
  16356. * Sets the blur box offset: offset applied during the blur pass.
  16357. * Only useful if useKernelBlur = false
  16358. */
  16359. set blurBoxOffset(value: number);
  16360. protected _blurScale: number;
  16361. /**
  16362. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16363. * 2 means half of the size.
  16364. */
  16365. get blurScale(): number;
  16366. /**
  16367. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16368. * 2 means half of the size.
  16369. */
  16370. set blurScale(value: number);
  16371. protected _blurKernel: number;
  16372. /**
  16373. * Gets the blur kernel: kernel size of the blur pass.
  16374. * Only useful if useKernelBlur = true
  16375. */
  16376. get blurKernel(): number;
  16377. /**
  16378. * Sets the blur kernel: kernel size of the blur pass.
  16379. * Only useful if useKernelBlur = true
  16380. */
  16381. set blurKernel(value: number);
  16382. protected _useKernelBlur: boolean;
  16383. /**
  16384. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16385. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16386. */
  16387. get useKernelBlur(): boolean;
  16388. /**
  16389. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16390. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16391. */
  16392. set useKernelBlur(value: boolean);
  16393. protected _depthScale: number;
  16394. /**
  16395. * Gets the depth scale used in ESM mode.
  16396. */
  16397. get depthScale(): number;
  16398. /**
  16399. * Sets the depth scale used in ESM mode.
  16400. * This can override the scale stored on the light.
  16401. */
  16402. set depthScale(value: number);
  16403. protected _validateFilter(filter: number): number;
  16404. protected _filter: number;
  16405. /**
  16406. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16407. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16408. */
  16409. get filter(): number;
  16410. /**
  16411. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16412. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16413. */
  16414. set filter(value: number);
  16415. /**
  16416. * Gets if the current filter is set to Poisson Sampling.
  16417. */
  16418. get usePoissonSampling(): boolean;
  16419. /**
  16420. * Sets the current filter to Poisson Sampling.
  16421. */
  16422. set usePoissonSampling(value: boolean);
  16423. /**
  16424. * Gets if the current filter is set to ESM.
  16425. */
  16426. get useExponentialShadowMap(): boolean;
  16427. /**
  16428. * Sets the current filter is to ESM.
  16429. */
  16430. set useExponentialShadowMap(value: boolean);
  16431. /**
  16432. * Gets if the current filter is set to filtered ESM.
  16433. */
  16434. get useBlurExponentialShadowMap(): boolean;
  16435. /**
  16436. * Gets if the current filter is set to filtered ESM.
  16437. */
  16438. set useBlurExponentialShadowMap(value: boolean);
  16439. /**
  16440. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16441. * exponential to prevent steep falloff artifacts).
  16442. */
  16443. get useCloseExponentialShadowMap(): boolean;
  16444. /**
  16445. * Sets the current filter to "close ESM" (using the inverse of the
  16446. * exponential to prevent steep falloff artifacts).
  16447. */
  16448. set useCloseExponentialShadowMap(value: boolean);
  16449. /**
  16450. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16451. * exponential to prevent steep falloff artifacts).
  16452. */
  16453. get useBlurCloseExponentialShadowMap(): boolean;
  16454. /**
  16455. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16456. * exponential to prevent steep falloff artifacts).
  16457. */
  16458. set useBlurCloseExponentialShadowMap(value: boolean);
  16459. /**
  16460. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16461. */
  16462. get usePercentageCloserFiltering(): boolean;
  16463. /**
  16464. * Sets the current filter to "PCF" (percentage closer filtering).
  16465. */
  16466. set usePercentageCloserFiltering(value: boolean);
  16467. protected _filteringQuality: number;
  16468. /**
  16469. * Gets the PCF or PCSS Quality.
  16470. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16471. */
  16472. get filteringQuality(): number;
  16473. /**
  16474. * Sets the PCF or PCSS Quality.
  16475. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16476. */
  16477. set filteringQuality(filteringQuality: number);
  16478. /**
  16479. * Gets if the current filter is set to "PCSS" (contact hardening).
  16480. */
  16481. get useContactHardeningShadow(): boolean;
  16482. /**
  16483. * Sets the current filter to "PCSS" (contact hardening).
  16484. */
  16485. set useContactHardeningShadow(value: boolean);
  16486. protected _contactHardeningLightSizeUVRatio: number;
  16487. /**
  16488. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16489. * Using a ratio helps keeping shape stability independently of the map size.
  16490. *
  16491. * It does not account for the light projection as it was having too much
  16492. * instability during the light setup or during light position changes.
  16493. *
  16494. * Only valid if useContactHardeningShadow is true.
  16495. */
  16496. get contactHardeningLightSizeUVRatio(): number;
  16497. /**
  16498. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16499. * Using a ratio helps keeping shape stability independently of the map size.
  16500. *
  16501. * It does not account for the light projection as it was having too much
  16502. * instability during the light setup or during light position changes.
  16503. *
  16504. * Only valid if useContactHardeningShadow is true.
  16505. */
  16506. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16507. protected _darkness: number;
  16508. /** Gets or sets the actual darkness of a shadow */
  16509. get darkness(): number;
  16510. set darkness(value: number);
  16511. /**
  16512. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16513. * 0 means strongest and 1 would means no shadow.
  16514. * @returns the darkness.
  16515. */
  16516. getDarkness(): number;
  16517. /**
  16518. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16519. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16520. * @returns the shadow generator allowing fluent coding.
  16521. */
  16522. setDarkness(darkness: number): ShadowGenerator;
  16523. protected _transparencyShadow: boolean;
  16524. /** Gets or sets the ability to have transparent shadow */
  16525. get transparencyShadow(): boolean;
  16526. set transparencyShadow(value: boolean);
  16527. /**
  16528. * Sets the ability to have transparent shadow (boolean).
  16529. * @param transparent True if transparent else False
  16530. * @returns the shadow generator allowing fluent coding
  16531. */
  16532. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16533. protected _shadowMap: Nullable<RenderTargetTexture>;
  16534. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16535. /**
  16536. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16537. * @returns The render target texture if present otherwise, null
  16538. */
  16539. getShadowMap(): Nullable<RenderTargetTexture>;
  16540. /**
  16541. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16542. * @returns The render target texture if the shadow map is present otherwise, null
  16543. */
  16544. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16545. /**
  16546. * Gets the class name of that object
  16547. * @returns "ShadowGenerator"
  16548. */
  16549. getClassName(): string;
  16550. /**
  16551. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16552. * @param mesh Mesh to add
  16553. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16554. * @returns the Shadow Generator itself
  16555. */
  16556. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16557. /**
  16558. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16559. * @param mesh Mesh to remove
  16560. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16561. * @returns the Shadow Generator itself
  16562. */
  16563. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16564. /**
  16565. * Controls the extent to which the shadows fade out at the edge of the frustum
  16566. */
  16567. frustumEdgeFalloff: number;
  16568. protected _light: IShadowLight;
  16569. /**
  16570. * Returns the associated light object.
  16571. * @returns the light generating the shadow
  16572. */
  16573. getLight(): IShadowLight;
  16574. /**
  16575. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16576. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16577. * It might on the other hand introduce peter panning.
  16578. */
  16579. forceBackFacesOnly: boolean;
  16580. protected _scene: Scene;
  16581. protected _lightDirection: Vector3;
  16582. protected _effect: Effect;
  16583. protected _viewMatrix: Matrix;
  16584. protected _projectionMatrix: Matrix;
  16585. protected _transformMatrix: Matrix;
  16586. protected _cachedPosition: Vector3;
  16587. protected _cachedDirection: Vector3;
  16588. protected _cachedDefines: string;
  16589. protected _currentRenderID: number;
  16590. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16591. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16592. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16593. protected _blurPostProcesses: PostProcess[];
  16594. protected _mapSize: number;
  16595. protected _currentFaceIndex: number;
  16596. protected _currentFaceIndexCache: number;
  16597. protected _textureType: number;
  16598. protected _defaultTextureMatrix: Matrix;
  16599. protected _storedUniqueId: Nullable<number>;
  16600. /** @hidden */
  16601. static _SceneComponentInitialization: (scene: Scene) => void;
  16602. /**
  16603. * Creates a ShadowGenerator object.
  16604. * A ShadowGenerator is the required tool to use the shadows.
  16605. * Each light casting shadows needs to use its own ShadowGenerator.
  16606. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16607. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16608. * @param light The light object generating the shadows.
  16609. * @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.
  16610. */
  16611. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16612. protected _initializeGenerator(): void;
  16613. protected _createTargetRenderTexture(): void;
  16614. protected _initializeShadowMap(): void;
  16615. protected _initializeBlurRTTAndPostProcesses(): void;
  16616. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16617. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16618. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16619. protected _applyFilterValues(): void;
  16620. /**
  16621. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16622. * @param onCompiled Callback triggered at the and of the effects compilation
  16623. * @param options Sets of optional options forcing the compilation with different modes
  16624. */
  16625. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16626. useInstances: boolean;
  16627. }>): void;
  16628. /**
  16629. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16630. * @param options Sets of optional options forcing the compilation with different modes
  16631. * @returns A promise that resolves when the compilation completes
  16632. */
  16633. forceCompilationAsync(options?: Partial<{
  16634. useInstances: boolean;
  16635. }>): Promise<void>;
  16636. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16637. /**
  16638. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16639. * @param subMesh The submesh we want to render in the shadow map
  16640. * @param useInstances Defines wether will draw in the map using instances
  16641. * @returns true if ready otherwise, false
  16642. */
  16643. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16644. /**
  16645. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16646. * @param defines Defines of the material we want to update
  16647. * @param lightIndex Index of the light in the enabled light list of the material
  16648. */
  16649. prepareDefines(defines: any, lightIndex: number): void;
  16650. /**
  16651. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16652. * defined in the generator but impacting the effect).
  16653. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16654. * @param effect The effect we are binfing the information for
  16655. */
  16656. bindShadowLight(lightIndex: string, effect: Effect): void;
  16657. /**
  16658. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16659. * (eq to shadow prjection matrix * light transform matrix)
  16660. * @returns The transform matrix used to create the shadow map
  16661. */
  16662. getTransformMatrix(): Matrix;
  16663. /**
  16664. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16665. * Cube and 2D textures for instance.
  16666. */
  16667. recreateShadowMap(): void;
  16668. protected _disposeBlurPostProcesses(): void;
  16669. protected _disposeRTTandPostProcesses(): void;
  16670. /**
  16671. * Disposes the ShadowGenerator.
  16672. * Returns nothing.
  16673. */
  16674. dispose(): void;
  16675. /**
  16676. * Serializes the shadow generator setup to a json object.
  16677. * @returns The serialized JSON object
  16678. */
  16679. serialize(): any;
  16680. /**
  16681. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16682. * @param parsedShadowGenerator The JSON object to parse
  16683. * @param scene The scene to create the shadow map for
  16684. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16685. * @returns The parsed shadow generator
  16686. */
  16687. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16688. }
  16689. }
  16690. declare module BABYLON {
  16691. /**
  16692. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16693. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16694. * 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.
  16695. */
  16696. export abstract class Light extends Node {
  16697. /**
  16698. * Falloff Default: light is falling off following the material specification:
  16699. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16700. */
  16701. static readonly FALLOFF_DEFAULT: number;
  16702. /**
  16703. * Falloff Physical: light is falling off following the inverse squared distance law.
  16704. */
  16705. static readonly FALLOFF_PHYSICAL: number;
  16706. /**
  16707. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16708. * to enhance interoperability with other engines.
  16709. */
  16710. static readonly FALLOFF_GLTF: number;
  16711. /**
  16712. * Falloff Standard: light is falling off like in the standard material
  16713. * to enhance interoperability with other materials.
  16714. */
  16715. static readonly FALLOFF_STANDARD: number;
  16716. /**
  16717. * If every light affecting the material is in this lightmapMode,
  16718. * material.lightmapTexture adds or multiplies
  16719. * (depends on material.useLightmapAsShadowmap)
  16720. * after every other light calculations.
  16721. */
  16722. static readonly LIGHTMAP_DEFAULT: number;
  16723. /**
  16724. * material.lightmapTexture as only diffuse lighting from this light
  16725. * adds only specular lighting from this light
  16726. * adds dynamic shadows
  16727. */
  16728. static readonly LIGHTMAP_SPECULAR: number;
  16729. /**
  16730. * material.lightmapTexture as only lighting
  16731. * no light calculation from this light
  16732. * only adds dynamic shadows from this light
  16733. */
  16734. static readonly LIGHTMAP_SHADOWSONLY: number;
  16735. /**
  16736. * Each light type uses the default quantity according to its type:
  16737. * point/spot lights use luminous intensity
  16738. * directional lights use illuminance
  16739. */
  16740. static readonly INTENSITYMODE_AUTOMATIC: number;
  16741. /**
  16742. * lumen (lm)
  16743. */
  16744. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16745. /**
  16746. * candela (lm/sr)
  16747. */
  16748. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16749. /**
  16750. * lux (lm/m^2)
  16751. */
  16752. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16753. /**
  16754. * nit (cd/m^2)
  16755. */
  16756. static readonly INTENSITYMODE_LUMINANCE: number;
  16757. /**
  16758. * Light type const id of the point light.
  16759. */
  16760. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16761. /**
  16762. * Light type const id of the directional light.
  16763. */
  16764. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16765. /**
  16766. * Light type const id of the spot light.
  16767. */
  16768. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16769. /**
  16770. * Light type const id of the hemispheric light.
  16771. */
  16772. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16773. /**
  16774. * Diffuse gives the basic color to an object.
  16775. */
  16776. diffuse: Color3;
  16777. /**
  16778. * Specular produces a highlight color on an object.
  16779. * Note: This is note affecting PBR materials.
  16780. */
  16781. specular: Color3;
  16782. /**
  16783. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16784. * falling off base on range or angle.
  16785. * This can be set to any values in Light.FALLOFF_x.
  16786. *
  16787. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16788. * other types of materials.
  16789. */
  16790. falloffType: number;
  16791. /**
  16792. * Strength of the light.
  16793. * Note: By default it is define in the framework own unit.
  16794. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16795. */
  16796. intensity: number;
  16797. private _range;
  16798. protected _inverseSquaredRange: number;
  16799. /**
  16800. * Defines how far from the source the light is impacting in scene units.
  16801. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16802. */
  16803. get range(): number;
  16804. /**
  16805. * Defines how far from the source the light is impacting in scene units.
  16806. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16807. */
  16808. set range(value: number);
  16809. /**
  16810. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16811. * of light.
  16812. */
  16813. private _photometricScale;
  16814. private _intensityMode;
  16815. /**
  16816. * Gets the photometric scale used to interpret the intensity.
  16817. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16818. */
  16819. get intensityMode(): number;
  16820. /**
  16821. * Sets the photometric scale used to interpret the intensity.
  16822. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16823. */
  16824. set intensityMode(value: number);
  16825. private _radius;
  16826. /**
  16827. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16828. */
  16829. get radius(): number;
  16830. /**
  16831. * sets the light radius used by PBR Materials to simulate soft area lights.
  16832. */
  16833. set radius(value: number);
  16834. private _renderPriority;
  16835. /**
  16836. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16837. * exceeding the number allowed of the materials.
  16838. */
  16839. renderPriority: number;
  16840. private _shadowEnabled;
  16841. /**
  16842. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16843. * the current shadow generator.
  16844. */
  16845. get shadowEnabled(): boolean;
  16846. /**
  16847. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16848. * the current shadow generator.
  16849. */
  16850. set shadowEnabled(value: boolean);
  16851. private _includedOnlyMeshes;
  16852. /**
  16853. * Gets the only meshes impacted by this light.
  16854. */
  16855. get includedOnlyMeshes(): AbstractMesh[];
  16856. /**
  16857. * Sets the only meshes impacted by this light.
  16858. */
  16859. set includedOnlyMeshes(value: AbstractMesh[]);
  16860. private _excludedMeshes;
  16861. /**
  16862. * Gets the meshes not impacted by this light.
  16863. */
  16864. get excludedMeshes(): AbstractMesh[];
  16865. /**
  16866. * Sets the meshes not impacted by this light.
  16867. */
  16868. set excludedMeshes(value: AbstractMesh[]);
  16869. private _excludeWithLayerMask;
  16870. /**
  16871. * Gets the layer id use to find what meshes are not impacted by the light.
  16872. * Inactive if 0
  16873. */
  16874. get excludeWithLayerMask(): number;
  16875. /**
  16876. * Sets the layer id use to find what meshes are not impacted by the light.
  16877. * Inactive if 0
  16878. */
  16879. set excludeWithLayerMask(value: number);
  16880. private _includeOnlyWithLayerMask;
  16881. /**
  16882. * Gets the layer id use to find what meshes are impacted by the light.
  16883. * Inactive if 0
  16884. */
  16885. get includeOnlyWithLayerMask(): number;
  16886. /**
  16887. * Sets the layer id use to find what meshes are impacted by the light.
  16888. * Inactive if 0
  16889. */
  16890. set includeOnlyWithLayerMask(value: number);
  16891. private _lightmapMode;
  16892. /**
  16893. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16894. */
  16895. get lightmapMode(): number;
  16896. /**
  16897. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16898. */
  16899. set lightmapMode(value: number);
  16900. /**
  16901. * Shadow generator associted to the light.
  16902. * @hidden Internal use only.
  16903. */
  16904. _shadowGenerator: Nullable<IShadowGenerator>;
  16905. /**
  16906. * @hidden Internal use only.
  16907. */
  16908. _excludedMeshesIds: string[];
  16909. /**
  16910. * @hidden Internal use only.
  16911. */
  16912. _includedOnlyMeshesIds: string[];
  16913. /**
  16914. * The current light unifom buffer.
  16915. * @hidden Internal use only.
  16916. */
  16917. _uniformBuffer: UniformBuffer;
  16918. /** @hidden */
  16919. _renderId: number;
  16920. /**
  16921. * Creates a Light object in the scene.
  16922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16923. * @param name The firendly name of the light
  16924. * @param scene The scene the light belongs too
  16925. */
  16926. constructor(name: string, scene: Scene);
  16927. protected abstract _buildUniformLayout(): void;
  16928. /**
  16929. * Sets the passed Effect "effect" with the Light information.
  16930. * @param effect The effect to update
  16931. * @param lightIndex The index of the light in the effect to update
  16932. * @returns The light
  16933. */
  16934. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16935. /**
  16936. * Sets the passed Effect "effect" with the Light textures.
  16937. * @param effect The effect to update
  16938. * @param lightIndex The index of the light in the effect to update
  16939. * @returns The light
  16940. */
  16941. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16942. /**
  16943. * Binds the lights information from the scene to the effect for the given mesh.
  16944. * @param lightIndex Light index
  16945. * @param scene The scene where the light belongs to
  16946. * @param effect The effect we are binding the data to
  16947. * @param useSpecular Defines if specular is supported
  16948. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16949. */
  16950. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16951. /**
  16952. * Sets the passed Effect "effect" with the Light information.
  16953. * @param effect The effect to update
  16954. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16955. * @returns The light
  16956. */
  16957. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16958. /**
  16959. * Returns the string "Light".
  16960. * @returns the class name
  16961. */
  16962. getClassName(): string;
  16963. /** @hidden */
  16964. readonly _isLight: boolean;
  16965. /**
  16966. * Converts the light information to a readable string for debug purpose.
  16967. * @param fullDetails Supports for multiple levels of logging within scene loading
  16968. * @returns the human readable light info
  16969. */
  16970. toString(fullDetails?: boolean): string;
  16971. /** @hidden */
  16972. protected _syncParentEnabledState(): void;
  16973. /**
  16974. * Set the enabled state of this node.
  16975. * @param value - the new enabled state
  16976. */
  16977. setEnabled(value: boolean): void;
  16978. /**
  16979. * Returns the Light associated shadow generator if any.
  16980. * @return the associated shadow generator.
  16981. */
  16982. getShadowGenerator(): Nullable<IShadowGenerator>;
  16983. /**
  16984. * Returns a Vector3, the absolute light position in the World.
  16985. * @returns the world space position of the light
  16986. */
  16987. getAbsolutePosition(): Vector3;
  16988. /**
  16989. * Specifies if the light will affect the passed mesh.
  16990. * @param mesh The mesh to test against the light
  16991. * @return true the mesh is affected otherwise, false.
  16992. */
  16993. canAffectMesh(mesh: AbstractMesh): boolean;
  16994. /**
  16995. * Sort function to order lights for rendering.
  16996. * @param a First Light object to compare to second.
  16997. * @param b Second Light object to compare first.
  16998. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16999. */
  17000. static CompareLightsPriority(a: Light, b: Light): number;
  17001. /**
  17002. * Releases resources associated with this node.
  17003. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17004. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17005. */
  17006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17007. /**
  17008. * Returns the light type ID (integer).
  17009. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17010. */
  17011. getTypeID(): number;
  17012. /**
  17013. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17014. * @returns the scaled intensity in intensity mode unit
  17015. */
  17016. getScaledIntensity(): number;
  17017. /**
  17018. * Returns a new Light object, named "name", from the current one.
  17019. * @param name The name of the cloned light
  17020. * @returns the new created light
  17021. */
  17022. clone(name: string): Nullable<Light>;
  17023. /**
  17024. * Serializes the current light into a Serialization object.
  17025. * @returns the serialized object.
  17026. */
  17027. serialize(): any;
  17028. /**
  17029. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17030. * This new light is named "name" and added to the passed scene.
  17031. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17032. * @param name The friendly name of the light
  17033. * @param scene The scene the new light will belong to
  17034. * @returns the constructor function
  17035. */
  17036. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17037. /**
  17038. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17039. * @param parsedLight The JSON representation of the light
  17040. * @param scene The scene to create the parsed light in
  17041. * @returns the created light after parsing
  17042. */
  17043. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17044. private _hookArrayForExcluded;
  17045. private _hookArrayForIncludedOnly;
  17046. private _resyncMeshes;
  17047. /**
  17048. * Forces the meshes to update their light related information in their rendering used effects
  17049. * @hidden Internal Use Only
  17050. */
  17051. _markMeshesAsLightDirty(): void;
  17052. /**
  17053. * Recomputes the cached photometric scale if needed.
  17054. */
  17055. private _computePhotometricScale;
  17056. /**
  17057. * Returns the Photometric Scale according to the light type and intensity mode.
  17058. */
  17059. private _getPhotometricScale;
  17060. /**
  17061. * Reorder the light in the scene according to their defined priority.
  17062. * @hidden Internal Use Only
  17063. */
  17064. _reorderLightsInScene(): void;
  17065. /**
  17066. * Prepares the list of defines specific to the light type.
  17067. * @param defines the list of defines
  17068. * @param lightIndex defines the index of the light for the effect
  17069. */
  17070. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17071. }
  17072. }
  17073. declare module BABYLON {
  17074. /**
  17075. * Interface used to define Action
  17076. */
  17077. export interface IAction {
  17078. /**
  17079. * Trigger for the action
  17080. */
  17081. trigger: number;
  17082. /** Options of the trigger */
  17083. triggerOptions: any;
  17084. /**
  17085. * Gets the trigger parameters
  17086. * @returns the trigger parameters
  17087. */
  17088. getTriggerParameter(): any;
  17089. /**
  17090. * Internal only - executes current action event
  17091. * @hidden
  17092. */
  17093. _executeCurrent(evt?: ActionEvent): void;
  17094. /**
  17095. * Serialize placeholder for child classes
  17096. * @param parent of child
  17097. * @returns the serialized object
  17098. */
  17099. serialize(parent: any): any;
  17100. /**
  17101. * Internal only
  17102. * @hidden
  17103. */
  17104. _prepare(): void;
  17105. /**
  17106. * Internal only - manager for action
  17107. * @hidden
  17108. */
  17109. _actionManager: AbstractActionManager;
  17110. /**
  17111. * Adds action to chain of actions, may be a DoNothingAction
  17112. * @param action defines the next action to execute
  17113. * @returns The action passed in
  17114. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17115. */
  17116. then(action: IAction): IAction;
  17117. }
  17118. /**
  17119. * The action to be carried out following a trigger
  17120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17121. */
  17122. export class Action implements IAction {
  17123. /** the trigger, with or without parameters, for the action */
  17124. triggerOptions: any;
  17125. /**
  17126. * Trigger for the action
  17127. */
  17128. trigger: number;
  17129. /**
  17130. * Internal only - manager for action
  17131. * @hidden
  17132. */
  17133. _actionManager: ActionManager;
  17134. private _nextActiveAction;
  17135. private _child;
  17136. private _condition?;
  17137. private _triggerParameter;
  17138. /**
  17139. * An event triggered prior to action being executed.
  17140. */
  17141. onBeforeExecuteObservable: Observable<Action>;
  17142. /**
  17143. * Creates a new Action
  17144. * @param triggerOptions the trigger, with or without parameters, for the action
  17145. * @param condition an optional determinant of action
  17146. */
  17147. constructor(
  17148. /** the trigger, with or without parameters, for the action */
  17149. triggerOptions: any, condition?: Condition);
  17150. /**
  17151. * Internal only
  17152. * @hidden
  17153. */
  17154. _prepare(): void;
  17155. /**
  17156. * Gets the trigger parameters
  17157. * @returns the trigger parameters
  17158. */
  17159. getTriggerParameter(): any;
  17160. /**
  17161. * Internal only - executes current action event
  17162. * @hidden
  17163. */
  17164. _executeCurrent(evt?: ActionEvent): void;
  17165. /**
  17166. * Execute placeholder for child classes
  17167. * @param evt optional action event
  17168. */
  17169. execute(evt?: ActionEvent): void;
  17170. /**
  17171. * Skips to next active action
  17172. */
  17173. skipToNextActiveAction(): void;
  17174. /**
  17175. * Adds action to chain of actions, may be a DoNothingAction
  17176. * @param action defines the next action to execute
  17177. * @returns The action passed in
  17178. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17179. */
  17180. then(action: Action): Action;
  17181. /**
  17182. * Internal only
  17183. * @hidden
  17184. */
  17185. _getProperty(propertyPath: string): string;
  17186. /**
  17187. * Internal only
  17188. * @hidden
  17189. */
  17190. _getEffectiveTarget(target: any, propertyPath: string): any;
  17191. /**
  17192. * Serialize placeholder for child classes
  17193. * @param parent of child
  17194. * @returns the serialized object
  17195. */
  17196. serialize(parent: any): any;
  17197. /**
  17198. * Internal only called by serialize
  17199. * @hidden
  17200. */
  17201. protected _serialize(serializedAction: any, parent?: any): any;
  17202. /**
  17203. * Internal only
  17204. * @hidden
  17205. */
  17206. static _SerializeValueAsString: (value: any) => string;
  17207. /**
  17208. * Internal only
  17209. * @hidden
  17210. */
  17211. static _GetTargetProperty: (target: Node | Scene) => {
  17212. name: string;
  17213. targetType: string;
  17214. value: string;
  17215. };
  17216. }
  17217. }
  17218. declare module BABYLON {
  17219. /**
  17220. * A Condition applied to an Action
  17221. */
  17222. export class Condition {
  17223. /**
  17224. * Internal only - manager for action
  17225. * @hidden
  17226. */
  17227. _actionManager: ActionManager;
  17228. /**
  17229. * Internal only
  17230. * @hidden
  17231. */
  17232. _evaluationId: number;
  17233. /**
  17234. * Internal only
  17235. * @hidden
  17236. */
  17237. _currentResult: boolean;
  17238. /**
  17239. * Creates a new Condition
  17240. * @param actionManager the manager of the action the condition is applied to
  17241. */
  17242. constructor(actionManager: ActionManager);
  17243. /**
  17244. * Check if the current condition is valid
  17245. * @returns a boolean
  17246. */
  17247. isValid(): boolean;
  17248. /**
  17249. * Internal only
  17250. * @hidden
  17251. */
  17252. _getProperty(propertyPath: string): string;
  17253. /**
  17254. * Internal only
  17255. * @hidden
  17256. */
  17257. _getEffectiveTarget(target: any, propertyPath: string): any;
  17258. /**
  17259. * Serialize placeholder for child classes
  17260. * @returns the serialized object
  17261. */
  17262. serialize(): any;
  17263. /**
  17264. * Internal only
  17265. * @hidden
  17266. */
  17267. protected _serialize(serializedCondition: any): any;
  17268. }
  17269. /**
  17270. * Defines specific conditional operators as extensions of Condition
  17271. */
  17272. export class ValueCondition extends Condition {
  17273. /** path to specify the property of the target the conditional operator uses */
  17274. propertyPath: string;
  17275. /** the value compared by the conditional operator against the current value of the property */
  17276. value: any;
  17277. /** the conditional operator, default ValueCondition.IsEqual */
  17278. operator: number;
  17279. /**
  17280. * Internal only
  17281. * @hidden
  17282. */
  17283. private static _IsEqual;
  17284. /**
  17285. * Internal only
  17286. * @hidden
  17287. */
  17288. private static _IsDifferent;
  17289. /**
  17290. * Internal only
  17291. * @hidden
  17292. */
  17293. private static _IsGreater;
  17294. /**
  17295. * Internal only
  17296. * @hidden
  17297. */
  17298. private static _IsLesser;
  17299. /**
  17300. * returns the number for IsEqual
  17301. */
  17302. static get IsEqual(): number;
  17303. /**
  17304. * Returns the number for IsDifferent
  17305. */
  17306. static get IsDifferent(): number;
  17307. /**
  17308. * Returns the number for IsGreater
  17309. */
  17310. static get IsGreater(): number;
  17311. /**
  17312. * Returns the number for IsLesser
  17313. */
  17314. static get IsLesser(): number;
  17315. /**
  17316. * Internal only The action manager for the condition
  17317. * @hidden
  17318. */
  17319. _actionManager: ActionManager;
  17320. /**
  17321. * Internal only
  17322. * @hidden
  17323. */
  17324. private _target;
  17325. /**
  17326. * Internal only
  17327. * @hidden
  17328. */
  17329. private _effectiveTarget;
  17330. /**
  17331. * Internal only
  17332. * @hidden
  17333. */
  17334. private _property;
  17335. /**
  17336. * Creates a new ValueCondition
  17337. * @param actionManager manager for the action the condition applies to
  17338. * @param target for the action
  17339. * @param propertyPath path to specify the property of the target the conditional operator uses
  17340. * @param value the value compared by the conditional operator against the current value of the property
  17341. * @param operator the conditional operator, default ValueCondition.IsEqual
  17342. */
  17343. constructor(actionManager: ActionManager, target: any,
  17344. /** path to specify the property of the target the conditional operator uses */
  17345. propertyPath: string,
  17346. /** the value compared by the conditional operator against the current value of the property */
  17347. value: any,
  17348. /** the conditional operator, default ValueCondition.IsEqual */
  17349. operator?: number);
  17350. /**
  17351. * Compares the given value with the property value for the specified conditional operator
  17352. * @returns the result of the comparison
  17353. */
  17354. isValid(): boolean;
  17355. /**
  17356. * Serialize the ValueCondition into a JSON compatible object
  17357. * @returns serialization object
  17358. */
  17359. serialize(): any;
  17360. /**
  17361. * Gets the name of the conditional operator for the ValueCondition
  17362. * @param operator the conditional operator
  17363. * @returns the name
  17364. */
  17365. static GetOperatorName(operator: number): string;
  17366. }
  17367. /**
  17368. * Defines a predicate condition as an extension of Condition
  17369. */
  17370. export class PredicateCondition extends Condition {
  17371. /** defines the predicate function used to validate the condition */
  17372. predicate: () => boolean;
  17373. /**
  17374. * Internal only - manager for action
  17375. * @hidden
  17376. */
  17377. _actionManager: ActionManager;
  17378. /**
  17379. * Creates a new PredicateCondition
  17380. * @param actionManager manager for the action the condition applies to
  17381. * @param predicate defines the predicate function used to validate the condition
  17382. */
  17383. constructor(actionManager: ActionManager,
  17384. /** defines the predicate function used to validate the condition */
  17385. predicate: () => boolean);
  17386. /**
  17387. * @returns the validity of the predicate condition
  17388. */
  17389. isValid(): boolean;
  17390. }
  17391. /**
  17392. * Defines a state condition as an extension of Condition
  17393. */
  17394. export class StateCondition extends Condition {
  17395. /** Value to compare with target state */
  17396. value: string;
  17397. /**
  17398. * Internal only - manager for action
  17399. * @hidden
  17400. */
  17401. _actionManager: ActionManager;
  17402. /**
  17403. * Internal only
  17404. * @hidden
  17405. */
  17406. private _target;
  17407. /**
  17408. * Creates a new StateCondition
  17409. * @param actionManager manager for the action the condition applies to
  17410. * @param target of the condition
  17411. * @param value to compare with target state
  17412. */
  17413. constructor(actionManager: ActionManager, target: any,
  17414. /** Value to compare with target state */
  17415. value: string);
  17416. /**
  17417. * Gets a boolean indicating if the current condition is met
  17418. * @returns the validity of the state
  17419. */
  17420. isValid(): boolean;
  17421. /**
  17422. * Serialize the StateCondition into a JSON compatible object
  17423. * @returns serialization object
  17424. */
  17425. serialize(): any;
  17426. }
  17427. }
  17428. declare module BABYLON {
  17429. /**
  17430. * This defines an action responsible to toggle a boolean once triggered.
  17431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17432. */
  17433. export class SwitchBooleanAction extends Action {
  17434. /**
  17435. * The path to the boolean property in the target object
  17436. */
  17437. propertyPath: string;
  17438. private _target;
  17439. private _effectiveTarget;
  17440. private _property;
  17441. /**
  17442. * Instantiate the action
  17443. * @param triggerOptions defines the trigger options
  17444. * @param target defines the object containing the boolean
  17445. * @param propertyPath defines the path to the boolean property in the target object
  17446. * @param condition defines the trigger related conditions
  17447. */
  17448. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17449. /** @hidden */
  17450. _prepare(): void;
  17451. /**
  17452. * Execute the action toggle the boolean value.
  17453. */
  17454. execute(): void;
  17455. /**
  17456. * Serializes the actions and its related information.
  17457. * @param parent defines the object to serialize in
  17458. * @returns the serialized object
  17459. */
  17460. serialize(parent: any): any;
  17461. }
  17462. /**
  17463. * This defines an action responsible to set a the state field of the target
  17464. * to a desired value once triggered.
  17465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17466. */
  17467. export class SetStateAction extends Action {
  17468. /**
  17469. * The value to store in the state field.
  17470. */
  17471. value: string;
  17472. private _target;
  17473. /**
  17474. * Instantiate the action
  17475. * @param triggerOptions defines the trigger options
  17476. * @param target defines the object containing the state property
  17477. * @param value defines the value to store in the state field
  17478. * @param condition defines the trigger related conditions
  17479. */
  17480. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17481. /**
  17482. * Execute the action and store the value on the target state property.
  17483. */
  17484. execute(): void;
  17485. /**
  17486. * Serializes the actions and its related information.
  17487. * @param parent defines the object to serialize in
  17488. * @returns the serialized object
  17489. */
  17490. serialize(parent: any): any;
  17491. }
  17492. /**
  17493. * This defines an action responsible to set a property of the target
  17494. * to a desired value once triggered.
  17495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17496. */
  17497. export class SetValueAction extends Action {
  17498. /**
  17499. * The path of the property to set in the target.
  17500. */
  17501. propertyPath: string;
  17502. /**
  17503. * The value to set in the property
  17504. */
  17505. value: any;
  17506. private _target;
  17507. private _effectiveTarget;
  17508. private _property;
  17509. /**
  17510. * Instantiate the action
  17511. * @param triggerOptions defines the trigger options
  17512. * @param target defines the object containing the property
  17513. * @param propertyPath defines the path of the property to set in the target
  17514. * @param value defines the value to set in the property
  17515. * @param condition defines the trigger related conditions
  17516. */
  17517. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17518. /** @hidden */
  17519. _prepare(): void;
  17520. /**
  17521. * Execute the action and set the targetted property to the desired value.
  17522. */
  17523. execute(): void;
  17524. /**
  17525. * Serializes the actions and its related information.
  17526. * @param parent defines the object to serialize in
  17527. * @returns the serialized object
  17528. */
  17529. serialize(parent: any): any;
  17530. }
  17531. /**
  17532. * This defines an action responsible to increment the target value
  17533. * to a desired value once triggered.
  17534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17535. */
  17536. export class IncrementValueAction extends Action {
  17537. /**
  17538. * The path of the property to increment in the target.
  17539. */
  17540. propertyPath: string;
  17541. /**
  17542. * The value we should increment the property by.
  17543. */
  17544. value: any;
  17545. private _target;
  17546. private _effectiveTarget;
  17547. private _property;
  17548. /**
  17549. * Instantiate the action
  17550. * @param triggerOptions defines the trigger options
  17551. * @param target defines the object containing the property
  17552. * @param propertyPath defines the path of the property to increment in the target
  17553. * @param value defines the value value we should increment the property by
  17554. * @param condition defines the trigger related conditions
  17555. */
  17556. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17557. /** @hidden */
  17558. _prepare(): void;
  17559. /**
  17560. * Execute the action and increment the target of the value amount.
  17561. */
  17562. execute(): void;
  17563. /**
  17564. * Serializes the actions and its related information.
  17565. * @param parent defines the object to serialize in
  17566. * @returns the serialized object
  17567. */
  17568. serialize(parent: any): any;
  17569. }
  17570. /**
  17571. * This defines an action responsible to start an animation once triggered.
  17572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17573. */
  17574. export class PlayAnimationAction extends Action {
  17575. /**
  17576. * Where the animation should start (animation frame)
  17577. */
  17578. from: number;
  17579. /**
  17580. * Where the animation should stop (animation frame)
  17581. */
  17582. to: number;
  17583. /**
  17584. * Define if the animation should loop or stop after the first play.
  17585. */
  17586. loop?: boolean;
  17587. private _target;
  17588. /**
  17589. * Instantiate the action
  17590. * @param triggerOptions defines the trigger options
  17591. * @param target defines the target animation or animation name
  17592. * @param from defines from where the animation should start (animation frame)
  17593. * @param end defines where the animation should stop (animation frame)
  17594. * @param loop defines if the animation should loop or stop after the first play
  17595. * @param condition defines the trigger related conditions
  17596. */
  17597. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17598. /** @hidden */
  17599. _prepare(): void;
  17600. /**
  17601. * Execute the action and play the animation.
  17602. */
  17603. execute(): void;
  17604. /**
  17605. * Serializes the actions and its related information.
  17606. * @param parent defines the object to serialize in
  17607. * @returns the serialized object
  17608. */
  17609. serialize(parent: any): any;
  17610. }
  17611. /**
  17612. * This defines an action responsible to stop an animation once triggered.
  17613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17614. */
  17615. export class StopAnimationAction extends Action {
  17616. private _target;
  17617. /**
  17618. * Instantiate the action
  17619. * @param triggerOptions defines the trigger options
  17620. * @param target defines the target animation or animation name
  17621. * @param condition defines the trigger related conditions
  17622. */
  17623. constructor(triggerOptions: any, target: any, condition?: Condition);
  17624. /** @hidden */
  17625. _prepare(): void;
  17626. /**
  17627. * Execute the action and stop the animation.
  17628. */
  17629. execute(): void;
  17630. /**
  17631. * Serializes the actions and its related information.
  17632. * @param parent defines the object to serialize in
  17633. * @returns the serialized object
  17634. */
  17635. serialize(parent: any): any;
  17636. }
  17637. /**
  17638. * This defines an action responsible that does nothing once triggered.
  17639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17640. */
  17641. export class DoNothingAction extends Action {
  17642. /**
  17643. * Instantiate the action
  17644. * @param triggerOptions defines the trigger options
  17645. * @param condition defines the trigger related conditions
  17646. */
  17647. constructor(triggerOptions?: any, condition?: Condition);
  17648. /**
  17649. * Execute the action and do nothing.
  17650. */
  17651. execute(): void;
  17652. /**
  17653. * Serializes the actions and its related information.
  17654. * @param parent defines the object to serialize in
  17655. * @returns the serialized object
  17656. */
  17657. serialize(parent: any): any;
  17658. }
  17659. /**
  17660. * This defines an action responsible to trigger several actions once triggered.
  17661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17662. */
  17663. export class CombineAction extends Action {
  17664. /**
  17665. * The list of aggregated animations to run.
  17666. */
  17667. children: Action[];
  17668. /**
  17669. * Instantiate the action
  17670. * @param triggerOptions defines the trigger options
  17671. * @param children defines the list of aggregated animations to run
  17672. * @param condition defines the trigger related conditions
  17673. */
  17674. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17675. /** @hidden */
  17676. _prepare(): void;
  17677. /**
  17678. * Execute the action and executes all the aggregated actions.
  17679. */
  17680. execute(evt: ActionEvent): void;
  17681. /**
  17682. * Serializes the actions and its related information.
  17683. * @param parent defines the object to serialize in
  17684. * @returns the serialized object
  17685. */
  17686. serialize(parent: any): any;
  17687. }
  17688. /**
  17689. * This defines an action responsible to run code (external event) once triggered.
  17690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17691. */
  17692. export class ExecuteCodeAction extends Action {
  17693. /**
  17694. * The callback function to run.
  17695. */
  17696. func: (evt: ActionEvent) => void;
  17697. /**
  17698. * Instantiate the action
  17699. * @param triggerOptions defines the trigger options
  17700. * @param func defines the callback function to run
  17701. * @param condition defines the trigger related conditions
  17702. */
  17703. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17704. /**
  17705. * Execute the action and run the attached code.
  17706. */
  17707. execute(evt: ActionEvent): void;
  17708. }
  17709. /**
  17710. * This defines an action responsible to set the parent property of the target once triggered.
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17712. */
  17713. export class SetParentAction extends Action {
  17714. private _parent;
  17715. private _target;
  17716. /**
  17717. * Instantiate the action
  17718. * @param triggerOptions defines the trigger options
  17719. * @param target defines the target containing the parent property
  17720. * @param parent defines from where the animation should start (animation frame)
  17721. * @param condition defines the trigger related conditions
  17722. */
  17723. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17724. /** @hidden */
  17725. _prepare(): void;
  17726. /**
  17727. * Execute the action and set the parent property.
  17728. */
  17729. execute(): void;
  17730. /**
  17731. * Serializes the actions and its related information.
  17732. * @param parent defines the object to serialize in
  17733. * @returns the serialized object
  17734. */
  17735. serialize(parent: any): any;
  17736. }
  17737. }
  17738. declare module BABYLON {
  17739. /**
  17740. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17741. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17743. */
  17744. export class ActionManager extends AbstractActionManager {
  17745. /**
  17746. * Nothing
  17747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17748. */
  17749. static readonly NothingTrigger: number;
  17750. /**
  17751. * On pick
  17752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17753. */
  17754. static readonly OnPickTrigger: number;
  17755. /**
  17756. * On left pick
  17757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17758. */
  17759. static readonly OnLeftPickTrigger: number;
  17760. /**
  17761. * On right pick
  17762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17763. */
  17764. static readonly OnRightPickTrigger: number;
  17765. /**
  17766. * On center pick
  17767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17768. */
  17769. static readonly OnCenterPickTrigger: number;
  17770. /**
  17771. * On pick down
  17772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17773. */
  17774. static readonly OnPickDownTrigger: number;
  17775. /**
  17776. * On double pick
  17777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17778. */
  17779. static readonly OnDoublePickTrigger: number;
  17780. /**
  17781. * On pick up
  17782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17783. */
  17784. static readonly OnPickUpTrigger: number;
  17785. /**
  17786. * On pick out.
  17787. * This trigger will only be raised if you also declared a OnPickDown
  17788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17789. */
  17790. static readonly OnPickOutTrigger: number;
  17791. /**
  17792. * On long press
  17793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17794. */
  17795. static readonly OnLongPressTrigger: number;
  17796. /**
  17797. * On pointer over
  17798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17799. */
  17800. static readonly OnPointerOverTrigger: number;
  17801. /**
  17802. * On pointer out
  17803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17804. */
  17805. static readonly OnPointerOutTrigger: number;
  17806. /**
  17807. * On every frame
  17808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17809. */
  17810. static readonly OnEveryFrameTrigger: number;
  17811. /**
  17812. * On intersection enter
  17813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17814. */
  17815. static readonly OnIntersectionEnterTrigger: number;
  17816. /**
  17817. * On intersection exit
  17818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17819. */
  17820. static readonly OnIntersectionExitTrigger: number;
  17821. /**
  17822. * On key down
  17823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17824. */
  17825. static readonly OnKeyDownTrigger: number;
  17826. /**
  17827. * On key up
  17828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17829. */
  17830. static readonly OnKeyUpTrigger: number;
  17831. private _scene;
  17832. /**
  17833. * Creates a new action manager
  17834. * @param scene defines the hosting scene
  17835. */
  17836. constructor(scene: Scene);
  17837. /**
  17838. * Releases all associated resources
  17839. */
  17840. dispose(): void;
  17841. /**
  17842. * Gets hosting scene
  17843. * @returns the hosting scene
  17844. */
  17845. getScene(): Scene;
  17846. /**
  17847. * Does this action manager handles actions of any of the given triggers
  17848. * @param triggers defines the triggers to be tested
  17849. * @return a boolean indicating whether one (or more) of the triggers is handled
  17850. */
  17851. hasSpecificTriggers(triggers: number[]): boolean;
  17852. /**
  17853. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17854. * speed.
  17855. * @param triggerA defines the trigger to be tested
  17856. * @param triggerB defines the trigger to be tested
  17857. * @return a boolean indicating whether one (or more) of the triggers is handled
  17858. */
  17859. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17860. /**
  17861. * Does this action manager handles actions of a given trigger
  17862. * @param trigger defines the trigger to be tested
  17863. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17864. * @return whether the trigger is handled
  17865. */
  17866. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17867. /**
  17868. * Does this action manager has pointer triggers
  17869. */
  17870. get hasPointerTriggers(): boolean;
  17871. /**
  17872. * Does this action manager has pick triggers
  17873. */
  17874. get hasPickTriggers(): boolean;
  17875. /**
  17876. * Registers an action to this action manager
  17877. * @param action defines the action to be registered
  17878. * @return the action amended (prepared) after registration
  17879. */
  17880. registerAction(action: IAction): Nullable<IAction>;
  17881. /**
  17882. * Unregisters an action to this action manager
  17883. * @param action defines the action to be unregistered
  17884. * @return a boolean indicating whether the action has been unregistered
  17885. */
  17886. unregisterAction(action: IAction): Boolean;
  17887. /**
  17888. * Process a specific trigger
  17889. * @param trigger defines the trigger to process
  17890. * @param evt defines the event details to be processed
  17891. */
  17892. processTrigger(trigger: number, evt?: IActionEvent): void;
  17893. /** @hidden */
  17894. _getEffectiveTarget(target: any, propertyPath: string): any;
  17895. /** @hidden */
  17896. _getProperty(propertyPath: string): string;
  17897. /**
  17898. * Serialize this manager to a JSON object
  17899. * @param name defines the property name to store this manager
  17900. * @returns a JSON representation of this manager
  17901. */
  17902. serialize(name: string): any;
  17903. /**
  17904. * Creates a new ActionManager from a JSON data
  17905. * @param parsedActions defines the JSON data to read from
  17906. * @param object defines the hosting mesh
  17907. * @param scene defines the hosting scene
  17908. */
  17909. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17910. /**
  17911. * Get a trigger name by index
  17912. * @param trigger defines the trigger index
  17913. * @returns a trigger name
  17914. */
  17915. static GetTriggerName(trigger: number): string;
  17916. }
  17917. }
  17918. declare module BABYLON {
  17919. /**
  17920. * Class used to represent a sprite
  17921. * @see http://doc.babylonjs.com/babylon101/sprites
  17922. */
  17923. export class Sprite {
  17924. /** defines the name */
  17925. name: string;
  17926. /** Gets or sets the current world position */
  17927. position: Vector3;
  17928. /** Gets or sets the main color */
  17929. color: Color4;
  17930. /** Gets or sets the width */
  17931. width: number;
  17932. /** Gets or sets the height */
  17933. height: number;
  17934. /** Gets or sets rotation angle */
  17935. angle: number;
  17936. /** Gets or sets the cell index in the sprite sheet */
  17937. cellIndex: number;
  17938. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17939. cellRef: string;
  17940. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17941. invertU: number;
  17942. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17943. invertV: number;
  17944. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17945. disposeWhenFinishedAnimating: boolean;
  17946. /** Gets the list of attached animations */
  17947. animations: Animation[];
  17948. /** Gets or sets a boolean indicating if the sprite can be picked */
  17949. isPickable: boolean;
  17950. /**
  17951. * Gets or sets the associated action manager
  17952. */
  17953. actionManager: Nullable<ActionManager>;
  17954. private _animationStarted;
  17955. private _loopAnimation;
  17956. private _fromIndex;
  17957. private _toIndex;
  17958. private _delay;
  17959. private _direction;
  17960. private _manager;
  17961. private _time;
  17962. private _onAnimationEnd;
  17963. /**
  17964. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17965. */
  17966. isVisible: boolean;
  17967. /**
  17968. * Gets or sets the sprite size
  17969. */
  17970. get size(): number;
  17971. set size(value: number);
  17972. /**
  17973. * Creates a new Sprite
  17974. * @param name defines the name
  17975. * @param manager defines the manager
  17976. */
  17977. constructor(
  17978. /** defines the name */
  17979. name: string, manager: ISpriteManager);
  17980. /**
  17981. * Starts an animation
  17982. * @param from defines the initial key
  17983. * @param to defines the end key
  17984. * @param loop defines if the animation must loop
  17985. * @param delay defines the start delay (in ms)
  17986. * @param onAnimationEnd defines a callback to call when animation ends
  17987. */
  17988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17989. /** Stops current animation (if any) */
  17990. stopAnimation(): void;
  17991. /** @hidden */
  17992. _animate(deltaTime: number): void;
  17993. /** Release associated resources */
  17994. dispose(): void;
  17995. }
  17996. }
  17997. declare module BABYLON {
  17998. /**
  17999. * Information about the result of picking within a scene
  18000. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18001. */
  18002. export class PickingInfo {
  18003. /** @hidden */
  18004. _pickingUnavailable: boolean;
  18005. /**
  18006. * If the pick collided with an object
  18007. */
  18008. hit: boolean;
  18009. /**
  18010. * Distance away where the pick collided
  18011. */
  18012. distance: number;
  18013. /**
  18014. * The location of pick collision
  18015. */
  18016. pickedPoint: Nullable<Vector3>;
  18017. /**
  18018. * The mesh corresponding the the pick collision
  18019. */
  18020. pickedMesh: Nullable<AbstractMesh>;
  18021. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18022. bu: number;
  18023. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18024. bv: number;
  18025. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18026. faceId: number;
  18027. /** Id of the the submesh that was picked */
  18028. subMeshId: number;
  18029. /** If a sprite was picked, this will be the sprite the pick collided with */
  18030. pickedSprite: Nullable<Sprite>;
  18031. /**
  18032. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18033. */
  18034. originMesh: Nullable<AbstractMesh>;
  18035. /**
  18036. * The ray that was used to perform the picking.
  18037. */
  18038. ray: Nullable<Ray>;
  18039. /**
  18040. * Gets the normal correspodning to the face the pick collided with
  18041. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18042. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18043. * @returns The normal correspodning to the face the pick collided with
  18044. */
  18045. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18046. /**
  18047. * Gets the texture coordinates of where the pick occured
  18048. * @returns the vector containing the coordnates of the texture
  18049. */
  18050. getTextureCoordinates(): Nullable<Vector2>;
  18051. }
  18052. }
  18053. declare module BABYLON {
  18054. /**
  18055. * Gather the list of pointer event types as constants.
  18056. */
  18057. export class PointerEventTypes {
  18058. /**
  18059. * 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.
  18060. */
  18061. static readonly POINTERDOWN: number;
  18062. /**
  18063. * The pointerup event is fired when a pointer is no longer active.
  18064. */
  18065. static readonly POINTERUP: number;
  18066. /**
  18067. * The pointermove event is fired when a pointer changes coordinates.
  18068. */
  18069. static readonly POINTERMOVE: number;
  18070. /**
  18071. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18072. */
  18073. static readonly POINTERWHEEL: number;
  18074. /**
  18075. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18076. */
  18077. static readonly POINTERPICK: number;
  18078. /**
  18079. * The pointertap event is fired when a the object has been touched and released without drag.
  18080. */
  18081. static readonly POINTERTAP: number;
  18082. /**
  18083. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18084. */
  18085. static readonly POINTERDOUBLETAP: number;
  18086. }
  18087. /**
  18088. * Base class of pointer info types.
  18089. */
  18090. export class PointerInfoBase {
  18091. /**
  18092. * Defines the type of event (PointerEventTypes)
  18093. */
  18094. type: number;
  18095. /**
  18096. * Defines the related dom event
  18097. */
  18098. event: PointerEvent | MouseWheelEvent;
  18099. /**
  18100. * Instantiates the base class of pointers info.
  18101. * @param type Defines the type of event (PointerEventTypes)
  18102. * @param event Defines the related dom event
  18103. */
  18104. constructor(
  18105. /**
  18106. * Defines the type of event (PointerEventTypes)
  18107. */
  18108. type: number,
  18109. /**
  18110. * Defines the related dom event
  18111. */
  18112. event: PointerEvent | MouseWheelEvent);
  18113. }
  18114. /**
  18115. * This class is used to store pointer related info for the onPrePointerObservable event.
  18116. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18117. */
  18118. export class PointerInfoPre extends PointerInfoBase {
  18119. /**
  18120. * Ray from a pointer if availible (eg. 6dof controller)
  18121. */
  18122. ray: Nullable<Ray>;
  18123. /**
  18124. * Defines the local position of the pointer on the canvas.
  18125. */
  18126. localPosition: Vector2;
  18127. /**
  18128. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18129. */
  18130. skipOnPointerObservable: boolean;
  18131. /**
  18132. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18133. * @param type Defines the type of event (PointerEventTypes)
  18134. * @param event Defines the related dom event
  18135. * @param localX Defines the local x coordinates of the pointer when the event occured
  18136. * @param localY Defines the local y coordinates of the pointer when the event occured
  18137. */
  18138. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18139. }
  18140. /**
  18141. * This type contains all the data related to a pointer event in Babylon.js.
  18142. * 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.
  18143. */
  18144. export class PointerInfo extends PointerInfoBase {
  18145. /**
  18146. * Defines the picking info associated to the info (if any)\
  18147. */
  18148. pickInfo: Nullable<PickingInfo>;
  18149. /**
  18150. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18151. * @param type Defines the type of event (PointerEventTypes)
  18152. * @param event Defines the related dom event
  18153. * @param pickInfo Defines the picking info associated to the info (if any)\
  18154. */
  18155. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18156. /**
  18157. * Defines the picking info associated to the info (if any)\
  18158. */
  18159. pickInfo: Nullable<PickingInfo>);
  18160. }
  18161. /**
  18162. * Data relating to a touch event on the screen.
  18163. */
  18164. export interface PointerTouch {
  18165. /**
  18166. * X coordinate of touch.
  18167. */
  18168. x: number;
  18169. /**
  18170. * Y coordinate of touch.
  18171. */
  18172. y: number;
  18173. /**
  18174. * Id of touch. Unique for each finger.
  18175. */
  18176. pointerId: number;
  18177. /**
  18178. * Event type passed from DOM.
  18179. */
  18180. type: any;
  18181. }
  18182. }
  18183. declare module BABYLON {
  18184. /**
  18185. * Manage the mouse inputs to control the movement of a free camera.
  18186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18187. */
  18188. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18189. /**
  18190. * Define if touch is enabled in the mouse input
  18191. */
  18192. touchEnabled: boolean;
  18193. /**
  18194. * Defines the camera the input is attached to.
  18195. */
  18196. camera: FreeCamera;
  18197. /**
  18198. * Defines the buttons associated with the input to handle camera move.
  18199. */
  18200. buttons: number[];
  18201. /**
  18202. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18203. */
  18204. angularSensibility: number;
  18205. private _pointerInput;
  18206. private _onMouseMove;
  18207. private _observer;
  18208. private previousPosition;
  18209. /**
  18210. * Observable for when a pointer move event occurs containing the move offset
  18211. */
  18212. onPointerMovedObservable: Observable<{
  18213. offsetX: number;
  18214. offsetY: number;
  18215. }>;
  18216. /**
  18217. * @hidden
  18218. * If the camera should be rotated automatically based on pointer movement
  18219. */
  18220. _allowCameraRotation: boolean;
  18221. /**
  18222. * Manage the mouse inputs to control the movement of a free camera.
  18223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18224. * @param touchEnabled Defines if touch is enabled or not
  18225. */
  18226. constructor(
  18227. /**
  18228. * Define if touch is enabled in the mouse input
  18229. */
  18230. touchEnabled?: boolean);
  18231. /**
  18232. * Attach the input controls to a specific dom element to get the input from.
  18233. * @param element Defines the element the controls should be listened from
  18234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18235. */
  18236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18237. /**
  18238. * Called on JS contextmenu event.
  18239. * Override this method to provide functionality.
  18240. */
  18241. protected onContextMenu(evt: PointerEvent): void;
  18242. /**
  18243. * Detach the current controls from the specified dom element.
  18244. * @param element Defines the element to stop listening the inputs from
  18245. */
  18246. detachControl(element: Nullable<HTMLElement>): void;
  18247. /**
  18248. * Gets the class name of the current intput.
  18249. * @returns the class name
  18250. */
  18251. getClassName(): string;
  18252. /**
  18253. * Get the friendly name associated with the input class.
  18254. * @returns the input friendly name
  18255. */
  18256. getSimpleName(): string;
  18257. }
  18258. }
  18259. declare module BABYLON {
  18260. /**
  18261. * Manage the touch inputs to control the movement of a free camera.
  18262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18263. */
  18264. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18265. /**
  18266. * Defines the camera the input is attached to.
  18267. */
  18268. camera: FreeCamera;
  18269. /**
  18270. * Defines the touch sensibility for rotation.
  18271. * The higher the faster.
  18272. */
  18273. touchAngularSensibility: number;
  18274. /**
  18275. * Defines the touch sensibility for move.
  18276. * The higher the faster.
  18277. */
  18278. touchMoveSensibility: number;
  18279. private _offsetX;
  18280. private _offsetY;
  18281. private _pointerPressed;
  18282. private _pointerInput;
  18283. private _observer;
  18284. private _onLostFocus;
  18285. /**
  18286. * Attach the input controls to a specific dom element to get the input from.
  18287. * @param element Defines the element the controls should be listened from
  18288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18289. */
  18290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18291. /**
  18292. * Detach the current controls from the specified dom element.
  18293. * @param element Defines the element to stop listening the inputs from
  18294. */
  18295. detachControl(element: Nullable<HTMLElement>): void;
  18296. /**
  18297. * Update the current camera state depending on the inputs that have been used this frame.
  18298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18299. */
  18300. checkInputs(): void;
  18301. /**
  18302. * Gets the class name of the current intput.
  18303. * @returns the class name
  18304. */
  18305. getClassName(): string;
  18306. /**
  18307. * Get the friendly name associated with the input class.
  18308. * @returns the input friendly name
  18309. */
  18310. getSimpleName(): string;
  18311. }
  18312. }
  18313. declare module BABYLON {
  18314. /**
  18315. * Default Inputs manager for the FreeCamera.
  18316. * It groups all the default supported inputs for ease of use.
  18317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18318. */
  18319. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18320. /**
  18321. * @hidden
  18322. */
  18323. _mouseInput: Nullable<FreeCameraMouseInput>;
  18324. /**
  18325. * Instantiates a new FreeCameraInputsManager.
  18326. * @param camera Defines the camera the inputs belong to
  18327. */
  18328. constructor(camera: FreeCamera);
  18329. /**
  18330. * Add keyboard input support to the input manager.
  18331. * @returns the current input manager
  18332. */
  18333. addKeyboard(): FreeCameraInputsManager;
  18334. /**
  18335. * Add mouse input support to the input manager.
  18336. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18337. * @returns the current input manager
  18338. */
  18339. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18340. /**
  18341. * Removes the mouse input support from the manager
  18342. * @returns the current input manager
  18343. */
  18344. removeMouse(): FreeCameraInputsManager;
  18345. /**
  18346. * Add touch input support to the input manager.
  18347. * @returns the current input manager
  18348. */
  18349. addTouch(): FreeCameraInputsManager;
  18350. /**
  18351. * Remove all attached input methods from a camera
  18352. */
  18353. clear(): void;
  18354. }
  18355. }
  18356. declare module BABYLON {
  18357. /**
  18358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18359. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18360. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18361. */
  18362. export class FreeCamera extends TargetCamera {
  18363. /**
  18364. * Define the collision ellipsoid of the camera.
  18365. * This is helpful to simulate a camera body like the player body around the camera
  18366. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18367. */
  18368. ellipsoid: Vector3;
  18369. /**
  18370. * Define an offset for the position of the ellipsoid around the camera.
  18371. * This can be helpful to determine the center of the body near the gravity center of the body
  18372. * instead of its head.
  18373. */
  18374. ellipsoidOffset: Vector3;
  18375. /**
  18376. * Enable or disable collisions of the camera with the rest of the scene objects.
  18377. */
  18378. checkCollisions: boolean;
  18379. /**
  18380. * Enable or disable gravity on the camera.
  18381. */
  18382. applyGravity: boolean;
  18383. /**
  18384. * Define the input manager associated to the camera.
  18385. */
  18386. inputs: FreeCameraInputsManager;
  18387. /**
  18388. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18389. * Higher values reduce sensitivity.
  18390. */
  18391. get angularSensibility(): number;
  18392. /**
  18393. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18394. * Higher values reduce sensitivity.
  18395. */
  18396. set angularSensibility(value: number);
  18397. /**
  18398. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18399. */
  18400. get keysUp(): number[];
  18401. set keysUp(value: number[]);
  18402. /**
  18403. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18404. */
  18405. get keysUpward(): number[];
  18406. set keysUpward(value: number[]);
  18407. /**
  18408. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18409. */
  18410. get keysDown(): number[];
  18411. set keysDown(value: number[]);
  18412. /**
  18413. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18414. */
  18415. get keysDownward(): number[];
  18416. set keysDownward(value: number[]);
  18417. /**
  18418. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18419. */
  18420. get keysLeft(): number[];
  18421. set keysLeft(value: number[]);
  18422. /**
  18423. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18424. */
  18425. get keysRight(): number[];
  18426. set keysRight(value: number[]);
  18427. /**
  18428. * Event raised when the camera collide with a mesh in the scene.
  18429. */
  18430. onCollide: (collidedMesh: AbstractMesh) => void;
  18431. private _collider;
  18432. private _needMoveForGravity;
  18433. private _oldPosition;
  18434. private _diffPosition;
  18435. private _newPosition;
  18436. /** @hidden */
  18437. _localDirection: Vector3;
  18438. /** @hidden */
  18439. _transformedDirection: Vector3;
  18440. /**
  18441. * Instantiates a Free Camera.
  18442. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18443. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18444. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18445. * @param name Define the name of the camera in the scene
  18446. * @param position Define the start position of the camera in the scene
  18447. * @param scene Define the scene the camera belongs to
  18448. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18449. */
  18450. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18451. /**
  18452. * Attached controls to the current camera.
  18453. * @param element Defines the element the controls should be listened from
  18454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18455. */
  18456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18457. /**
  18458. * Detach the current controls from the camera.
  18459. * The camera will stop reacting to inputs.
  18460. * @param element Defines the element to stop listening the inputs from
  18461. */
  18462. detachControl(element: HTMLElement): void;
  18463. private _collisionMask;
  18464. /**
  18465. * Define a collision mask to limit the list of object the camera can collide with
  18466. */
  18467. get collisionMask(): number;
  18468. set collisionMask(mask: number);
  18469. /** @hidden */
  18470. _collideWithWorld(displacement: Vector3): void;
  18471. private _onCollisionPositionChange;
  18472. /** @hidden */
  18473. _checkInputs(): void;
  18474. /** @hidden */
  18475. _decideIfNeedsToMove(): boolean;
  18476. /** @hidden */
  18477. _updatePosition(): void;
  18478. /**
  18479. * Destroy the camera and release the current resources hold by it.
  18480. */
  18481. dispose(): void;
  18482. /**
  18483. * Gets the current object class name.
  18484. * @return the class name
  18485. */
  18486. getClassName(): string;
  18487. }
  18488. }
  18489. declare module BABYLON {
  18490. /**
  18491. * Represents a gamepad control stick position
  18492. */
  18493. export class StickValues {
  18494. /**
  18495. * The x component of the control stick
  18496. */
  18497. x: number;
  18498. /**
  18499. * The y component of the control stick
  18500. */
  18501. y: number;
  18502. /**
  18503. * Initializes the gamepad x and y control stick values
  18504. * @param x The x component of the gamepad control stick value
  18505. * @param y The y component of the gamepad control stick value
  18506. */
  18507. constructor(
  18508. /**
  18509. * The x component of the control stick
  18510. */
  18511. x: number,
  18512. /**
  18513. * The y component of the control stick
  18514. */
  18515. y: number);
  18516. }
  18517. /**
  18518. * An interface which manages callbacks for gamepad button changes
  18519. */
  18520. export interface GamepadButtonChanges {
  18521. /**
  18522. * Called when a gamepad has been changed
  18523. */
  18524. changed: boolean;
  18525. /**
  18526. * Called when a gamepad press event has been triggered
  18527. */
  18528. pressChanged: boolean;
  18529. /**
  18530. * Called when a touch event has been triggered
  18531. */
  18532. touchChanged: boolean;
  18533. /**
  18534. * Called when a value has changed
  18535. */
  18536. valueChanged: boolean;
  18537. }
  18538. /**
  18539. * Represents a gamepad
  18540. */
  18541. export class Gamepad {
  18542. /**
  18543. * The id of the gamepad
  18544. */
  18545. id: string;
  18546. /**
  18547. * The index of the gamepad
  18548. */
  18549. index: number;
  18550. /**
  18551. * The browser gamepad
  18552. */
  18553. browserGamepad: any;
  18554. /**
  18555. * Specifies what type of gamepad this represents
  18556. */
  18557. type: number;
  18558. private _leftStick;
  18559. private _rightStick;
  18560. /** @hidden */
  18561. _isConnected: boolean;
  18562. private _leftStickAxisX;
  18563. private _leftStickAxisY;
  18564. private _rightStickAxisX;
  18565. private _rightStickAxisY;
  18566. /**
  18567. * Triggered when the left control stick has been changed
  18568. */
  18569. private _onleftstickchanged;
  18570. /**
  18571. * Triggered when the right control stick has been changed
  18572. */
  18573. private _onrightstickchanged;
  18574. /**
  18575. * Represents a gamepad controller
  18576. */
  18577. static GAMEPAD: number;
  18578. /**
  18579. * Represents a generic controller
  18580. */
  18581. static GENERIC: number;
  18582. /**
  18583. * Represents an XBox controller
  18584. */
  18585. static XBOX: number;
  18586. /**
  18587. * Represents a pose-enabled controller
  18588. */
  18589. static POSE_ENABLED: number;
  18590. /**
  18591. * Represents an Dual Shock controller
  18592. */
  18593. static DUALSHOCK: number;
  18594. /**
  18595. * Specifies whether the left control stick should be Y-inverted
  18596. */
  18597. protected _invertLeftStickY: boolean;
  18598. /**
  18599. * Specifies if the gamepad has been connected
  18600. */
  18601. get isConnected(): boolean;
  18602. /**
  18603. * Initializes the gamepad
  18604. * @param id The id of the gamepad
  18605. * @param index The index of the gamepad
  18606. * @param browserGamepad The browser gamepad
  18607. * @param leftStickX The x component of the left joystick
  18608. * @param leftStickY The y component of the left joystick
  18609. * @param rightStickX The x component of the right joystick
  18610. * @param rightStickY The y component of the right joystick
  18611. */
  18612. constructor(
  18613. /**
  18614. * The id of the gamepad
  18615. */
  18616. id: string,
  18617. /**
  18618. * The index of the gamepad
  18619. */
  18620. index: number,
  18621. /**
  18622. * The browser gamepad
  18623. */
  18624. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18625. /**
  18626. * Callback triggered when the left joystick has changed
  18627. * @param callback
  18628. */
  18629. onleftstickchanged(callback: (values: StickValues) => void): void;
  18630. /**
  18631. * Callback triggered when the right joystick has changed
  18632. * @param callback
  18633. */
  18634. onrightstickchanged(callback: (values: StickValues) => void): void;
  18635. /**
  18636. * Gets the left joystick
  18637. */
  18638. get leftStick(): StickValues;
  18639. /**
  18640. * Sets the left joystick values
  18641. */
  18642. set leftStick(newValues: StickValues);
  18643. /**
  18644. * Gets the right joystick
  18645. */
  18646. get rightStick(): StickValues;
  18647. /**
  18648. * Sets the right joystick value
  18649. */
  18650. set rightStick(newValues: StickValues);
  18651. /**
  18652. * Updates the gamepad joystick positions
  18653. */
  18654. update(): void;
  18655. /**
  18656. * Disposes the gamepad
  18657. */
  18658. dispose(): void;
  18659. }
  18660. /**
  18661. * Represents a generic gamepad
  18662. */
  18663. export class GenericPad extends Gamepad {
  18664. private _buttons;
  18665. private _onbuttondown;
  18666. private _onbuttonup;
  18667. /**
  18668. * Observable triggered when a button has been pressed
  18669. */
  18670. onButtonDownObservable: Observable<number>;
  18671. /**
  18672. * Observable triggered when a button has been released
  18673. */
  18674. onButtonUpObservable: Observable<number>;
  18675. /**
  18676. * Callback triggered when a button has been pressed
  18677. * @param callback Called when a button has been pressed
  18678. */
  18679. onbuttondown(callback: (buttonPressed: number) => void): void;
  18680. /**
  18681. * Callback triggered when a button has been released
  18682. * @param callback Called when a button has been released
  18683. */
  18684. onbuttonup(callback: (buttonReleased: number) => void): void;
  18685. /**
  18686. * Initializes the generic gamepad
  18687. * @param id The id of the generic gamepad
  18688. * @param index The index of the generic gamepad
  18689. * @param browserGamepad The browser gamepad
  18690. */
  18691. constructor(id: string, index: number, browserGamepad: any);
  18692. private _setButtonValue;
  18693. /**
  18694. * Updates the generic gamepad
  18695. */
  18696. update(): void;
  18697. /**
  18698. * Disposes the generic gamepad
  18699. */
  18700. dispose(): void;
  18701. }
  18702. }
  18703. declare module BABYLON {
  18704. /**
  18705. * Defines the types of pose enabled controllers that are supported
  18706. */
  18707. export enum PoseEnabledControllerType {
  18708. /**
  18709. * HTC Vive
  18710. */
  18711. VIVE = 0,
  18712. /**
  18713. * Oculus Rift
  18714. */
  18715. OCULUS = 1,
  18716. /**
  18717. * Windows mixed reality
  18718. */
  18719. WINDOWS = 2,
  18720. /**
  18721. * Samsung gear VR
  18722. */
  18723. GEAR_VR = 3,
  18724. /**
  18725. * Google Daydream
  18726. */
  18727. DAYDREAM = 4,
  18728. /**
  18729. * Generic
  18730. */
  18731. GENERIC = 5
  18732. }
  18733. /**
  18734. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18735. */
  18736. export interface MutableGamepadButton {
  18737. /**
  18738. * Value of the button/trigger
  18739. */
  18740. value: number;
  18741. /**
  18742. * If the button/trigger is currently touched
  18743. */
  18744. touched: boolean;
  18745. /**
  18746. * If the button/trigger is currently pressed
  18747. */
  18748. pressed: boolean;
  18749. }
  18750. /**
  18751. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18752. * @hidden
  18753. */
  18754. export interface ExtendedGamepadButton extends GamepadButton {
  18755. /**
  18756. * If the button/trigger is currently pressed
  18757. */
  18758. readonly pressed: boolean;
  18759. /**
  18760. * If the button/trigger is currently touched
  18761. */
  18762. readonly touched: boolean;
  18763. /**
  18764. * Value of the button/trigger
  18765. */
  18766. readonly value: number;
  18767. }
  18768. /** @hidden */
  18769. export interface _GamePadFactory {
  18770. /**
  18771. * Returns whether or not the current gamepad can be created for this type of controller.
  18772. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18773. * @returns true if it can be created, otherwise false
  18774. */
  18775. canCreate(gamepadInfo: any): boolean;
  18776. /**
  18777. * Creates a new instance of the Gamepad.
  18778. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18779. * @returns the new gamepad instance
  18780. */
  18781. create(gamepadInfo: any): Gamepad;
  18782. }
  18783. /**
  18784. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18785. */
  18786. export class PoseEnabledControllerHelper {
  18787. /** @hidden */
  18788. static _ControllerFactories: _GamePadFactory[];
  18789. /** @hidden */
  18790. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18791. /**
  18792. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18793. * @param vrGamepad the gamepad to initialized
  18794. * @returns a vr controller of the type the gamepad identified as
  18795. */
  18796. static InitiateController(vrGamepad: any): Gamepad;
  18797. }
  18798. /**
  18799. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18800. */
  18801. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18802. /**
  18803. * If the controller is used in a webXR session
  18804. */
  18805. isXR: boolean;
  18806. private _deviceRoomPosition;
  18807. private _deviceRoomRotationQuaternion;
  18808. /**
  18809. * The device position in babylon space
  18810. */
  18811. devicePosition: Vector3;
  18812. /**
  18813. * The device rotation in babylon space
  18814. */
  18815. deviceRotationQuaternion: Quaternion;
  18816. /**
  18817. * The scale factor of the device in babylon space
  18818. */
  18819. deviceScaleFactor: number;
  18820. /**
  18821. * (Likely devicePosition should be used instead) The device position in its room space
  18822. */
  18823. position: Vector3;
  18824. /**
  18825. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18826. */
  18827. rotationQuaternion: Quaternion;
  18828. /**
  18829. * The type of controller (Eg. Windows mixed reality)
  18830. */
  18831. controllerType: PoseEnabledControllerType;
  18832. protected _calculatedPosition: Vector3;
  18833. private _calculatedRotation;
  18834. /**
  18835. * The raw pose from the device
  18836. */
  18837. rawPose: DevicePose;
  18838. private _trackPosition;
  18839. private _maxRotationDistFromHeadset;
  18840. private _draggedRoomRotation;
  18841. /**
  18842. * @hidden
  18843. */
  18844. _disableTrackPosition(fixedPosition: Vector3): void;
  18845. /**
  18846. * Internal, the mesh attached to the controller
  18847. * @hidden
  18848. */
  18849. _mesh: Nullable<AbstractMesh>;
  18850. private _poseControlledCamera;
  18851. private _leftHandSystemQuaternion;
  18852. /**
  18853. * Internal, matrix used to convert room space to babylon space
  18854. * @hidden
  18855. */
  18856. _deviceToWorld: Matrix;
  18857. /**
  18858. * Node to be used when casting a ray from the controller
  18859. * @hidden
  18860. */
  18861. _pointingPoseNode: Nullable<TransformNode>;
  18862. /**
  18863. * Name of the child mesh that can be used to cast a ray from the controller
  18864. */
  18865. static readonly POINTING_POSE: string;
  18866. /**
  18867. * Creates a new PoseEnabledController from a gamepad
  18868. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18869. */
  18870. constructor(browserGamepad: any);
  18871. private _workingMatrix;
  18872. /**
  18873. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18874. */
  18875. update(): void;
  18876. /**
  18877. * Updates only the pose device and mesh without doing any button event checking
  18878. */
  18879. protected _updatePoseAndMesh(): void;
  18880. /**
  18881. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18882. * @param poseData raw pose fromthe device
  18883. */
  18884. updateFromDevice(poseData: DevicePose): void;
  18885. /**
  18886. * @hidden
  18887. */
  18888. _meshAttachedObservable: Observable<AbstractMesh>;
  18889. /**
  18890. * Attaches a mesh to the controller
  18891. * @param mesh the mesh to be attached
  18892. */
  18893. attachToMesh(mesh: AbstractMesh): void;
  18894. /**
  18895. * Attaches the controllers mesh to a camera
  18896. * @param camera the camera the mesh should be attached to
  18897. */
  18898. attachToPoseControlledCamera(camera: TargetCamera): void;
  18899. /**
  18900. * Disposes of the controller
  18901. */
  18902. dispose(): void;
  18903. /**
  18904. * The mesh that is attached to the controller
  18905. */
  18906. get mesh(): Nullable<AbstractMesh>;
  18907. /**
  18908. * Gets the ray of the controller in the direction the controller is pointing
  18909. * @param length the length the resulting ray should be
  18910. * @returns a ray in the direction the controller is pointing
  18911. */
  18912. getForwardRay(length?: number): Ray;
  18913. }
  18914. }
  18915. declare module BABYLON {
  18916. /**
  18917. * Defines the WebVRController object that represents controllers tracked in 3D space
  18918. */
  18919. export abstract class WebVRController extends PoseEnabledController {
  18920. /**
  18921. * Internal, the default controller model for the controller
  18922. */
  18923. protected _defaultModel: Nullable<AbstractMesh>;
  18924. /**
  18925. * Fired when the trigger state has changed
  18926. */
  18927. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18928. /**
  18929. * Fired when the main button state has changed
  18930. */
  18931. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18932. /**
  18933. * Fired when the secondary button state has changed
  18934. */
  18935. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18936. /**
  18937. * Fired when the pad state has changed
  18938. */
  18939. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18940. /**
  18941. * Fired when controllers stick values have changed
  18942. */
  18943. onPadValuesChangedObservable: Observable<StickValues>;
  18944. /**
  18945. * Array of button availible on the controller
  18946. */
  18947. protected _buttons: Array<MutableGamepadButton>;
  18948. private _onButtonStateChange;
  18949. /**
  18950. * Fired when a controller button's state has changed
  18951. * @param callback the callback containing the button that was modified
  18952. */
  18953. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18954. /**
  18955. * X and Y axis corresponding to the controllers joystick
  18956. */
  18957. pad: StickValues;
  18958. /**
  18959. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18960. */
  18961. hand: string;
  18962. /**
  18963. * The default controller model for the controller
  18964. */
  18965. get defaultModel(): Nullable<AbstractMesh>;
  18966. /**
  18967. * Creates a new WebVRController from a gamepad
  18968. * @param vrGamepad the gamepad that the WebVRController should be created from
  18969. */
  18970. constructor(vrGamepad: any);
  18971. /**
  18972. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18973. */
  18974. update(): void;
  18975. /**
  18976. * Function to be called when a button is modified
  18977. */
  18978. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18979. /**
  18980. * Loads a mesh and attaches it to the controller
  18981. * @param scene the scene the mesh should be added to
  18982. * @param meshLoaded callback for when the mesh has been loaded
  18983. */
  18984. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18985. private _setButtonValue;
  18986. private _changes;
  18987. private _checkChanges;
  18988. /**
  18989. * Disposes of th webVRCOntroller
  18990. */
  18991. dispose(): void;
  18992. }
  18993. }
  18994. declare module BABYLON {
  18995. /**
  18996. * The HemisphericLight simulates the ambient environment light,
  18997. * so the passed direction is the light reflection direction, not the incoming direction.
  18998. */
  18999. export class HemisphericLight extends Light {
  19000. /**
  19001. * The groundColor is the light in the opposite direction to the one specified during creation.
  19002. * 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.
  19003. */
  19004. groundColor: Color3;
  19005. /**
  19006. * The light reflection direction, not the incoming direction.
  19007. */
  19008. direction: Vector3;
  19009. /**
  19010. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19011. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19012. * The HemisphericLight can't cast shadows.
  19013. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19014. * @param name The friendly name of the light
  19015. * @param direction The direction of the light reflection
  19016. * @param scene The scene the light belongs to
  19017. */
  19018. constructor(name: string, direction: Vector3, scene: Scene);
  19019. protected _buildUniformLayout(): void;
  19020. /**
  19021. * Returns the string "HemisphericLight".
  19022. * @return The class name
  19023. */
  19024. getClassName(): string;
  19025. /**
  19026. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19027. * Returns the updated direction.
  19028. * @param target The target the direction should point to
  19029. * @return The computed direction
  19030. */
  19031. setDirectionToTarget(target: Vector3): Vector3;
  19032. /**
  19033. * Returns the shadow generator associated to the light.
  19034. * @returns Always null for hemispheric lights because it does not support shadows.
  19035. */
  19036. getShadowGenerator(): Nullable<IShadowGenerator>;
  19037. /**
  19038. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19039. * @param effect The effect to update
  19040. * @param lightIndex The index of the light in the effect to update
  19041. * @returns The hemispheric light
  19042. */
  19043. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19044. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19045. /**
  19046. * Computes the world matrix of the node
  19047. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19048. * @param useWasUpdatedFlag defines a reserved property
  19049. * @returns the world matrix
  19050. */
  19051. computeWorldMatrix(): Matrix;
  19052. /**
  19053. * Returns the integer 3.
  19054. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19055. */
  19056. getTypeID(): number;
  19057. /**
  19058. * Prepares the list of defines specific to the light type.
  19059. * @param defines the list of defines
  19060. * @param lightIndex defines the index of the light for the effect
  19061. */
  19062. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19063. }
  19064. }
  19065. declare module BABYLON {
  19066. /** @hidden */
  19067. export var vrMultiviewToSingleviewPixelShader: {
  19068. name: string;
  19069. shader: string;
  19070. };
  19071. }
  19072. declare module BABYLON {
  19073. /**
  19074. * Renders to multiple views with a single draw call
  19075. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19076. */
  19077. export class MultiviewRenderTarget extends RenderTargetTexture {
  19078. /**
  19079. * Creates a multiview render target
  19080. * @param scene scene used with the render target
  19081. * @param size the size of the render target (used for each view)
  19082. */
  19083. constructor(scene: Scene, size?: number | {
  19084. width: number;
  19085. height: number;
  19086. } | {
  19087. ratio: number;
  19088. });
  19089. /**
  19090. * @hidden
  19091. * @param faceIndex the face index, if its a cube texture
  19092. */
  19093. _bindFrameBuffer(faceIndex?: number): void;
  19094. /**
  19095. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19096. * @returns the view count
  19097. */
  19098. getViewCount(): number;
  19099. }
  19100. }
  19101. declare module BABYLON {
  19102. /**
  19103. * Represents a camera frustum
  19104. */
  19105. export class Frustum {
  19106. /**
  19107. * Gets the planes representing the frustum
  19108. * @param transform matrix to be applied to the returned planes
  19109. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19110. */
  19111. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19112. /**
  19113. * Gets the near frustum plane transformed by the transform matrix
  19114. * @param transform transformation matrix to be applied to the resulting frustum plane
  19115. * @param frustumPlane the resuling frustum plane
  19116. */
  19117. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19118. /**
  19119. * Gets the far frustum plane transformed by the transform matrix
  19120. * @param transform transformation matrix to be applied to the resulting frustum plane
  19121. * @param frustumPlane the resuling frustum plane
  19122. */
  19123. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19124. /**
  19125. * Gets the left frustum plane transformed by the transform matrix
  19126. * @param transform transformation matrix to be applied to the resulting frustum plane
  19127. * @param frustumPlane the resuling frustum plane
  19128. */
  19129. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19130. /**
  19131. * Gets the right frustum plane transformed by the transform matrix
  19132. * @param transform transformation matrix to be applied to the resulting frustum plane
  19133. * @param frustumPlane the resuling frustum plane
  19134. */
  19135. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19136. /**
  19137. * Gets the top frustum plane transformed by the transform matrix
  19138. * @param transform transformation matrix to be applied to the resulting frustum plane
  19139. * @param frustumPlane the resuling frustum plane
  19140. */
  19141. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19142. /**
  19143. * Gets the bottom frustum plane transformed by the transform matrix
  19144. * @param transform transformation matrix to be applied to the resulting frustum plane
  19145. * @param frustumPlane the resuling frustum plane
  19146. */
  19147. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19148. /**
  19149. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19150. * @param transform transformation matrix to be applied to the resulting frustum planes
  19151. * @param frustumPlanes the resuling frustum planes
  19152. */
  19153. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19154. }
  19155. }
  19156. declare module BABYLON {
  19157. interface Engine {
  19158. /**
  19159. * Creates a new multiview render target
  19160. * @param width defines the width of the texture
  19161. * @param height defines the height of the texture
  19162. * @returns the created multiview texture
  19163. */
  19164. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19165. /**
  19166. * Binds a multiview framebuffer to be drawn to
  19167. * @param multiviewTexture texture to bind
  19168. */
  19169. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19170. }
  19171. interface Camera {
  19172. /**
  19173. * @hidden
  19174. * 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)
  19175. */
  19176. _useMultiviewToSingleView: boolean;
  19177. /**
  19178. * @hidden
  19179. * 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)
  19180. */
  19181. _multiviewTexture: Nullable<RenderTargetTexture>;
  19182. /**
  19183. * @hidden
  19184. * ensures the multiview texture of the camera exists and has the specified width/height
  19185. * @param width height to set on the multiview texture
  19186. * @param height width to set on the multiview texture
  19187. */
  19188. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19189. }
  19190. interface Scene {
  19191. /** @hidden */
  19192. _transformMatrixR: Matrix;
  19193. /** @hidden */
  19194. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19195. /** @hidden */
  19196. _createMultiviewUbo(): void;
  19197. /** @hidden */
  19198. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19199. /** @hidden */
  19200. _renderMultiviewToSingleView(camera: Camera): void;
  19201. }
  19202. }
  19203. declare module BABYLON {
  19204. /**
  19205. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19206. * This will not be used for webXR as it supports displaying texture arrays directly
  19207. */
  19208. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19209. /**
  19210. * Initializes a VRMultiviewToSingleview
  19211. * @param name name of the post process
  19212. * @param camera camera to be applied to
  19213. * @param scaleFactor scaling factor to the size of the output texture
  19214. */
  19215. constructor(name: string, camera: Camera, scaleFactor: number);
  19216. }
  19217. }
  19218. declare module BABYLON {
  19219. /**
  19220. * Interface used to define additional presentation attributes
  19221. */
  19222. export interface IVRPresentationAttributes {
  19223. /**
  19224. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19225. */
  19226. highRefreshRate: boolean;
  19227. /**
  19228. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19229. */
  19230. foveationLevel: number;
  19231. }
  19232. interface Engine {
  19233. /** @hidden */
  19234. _vrDisplay: any;
  19235. /** @hidden */
  19236. _vrSupported: boolean;
  19237. /** @hidden */
  19238. _oldSize: Size;
  19239. /** @hidden */
  19240. _oldHardwareScaleFactor: number;
  19241. /** @hidden */
  19242. _vrExclusivePointerMode: boolean;
  19243. /** @hidden */
  19244. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19245. /** @hidden */
  19246. _onVRDisplayPointerRestricted: () => void;
  19247. /** @hidden */
  19248. _onVRDisplayPointerUnrestricted: () => void;
  19249. /** @hidden */
  19250. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19251. /** @hidden */
  19252. _onVrDisplayDisconnect: Nullable<() => void>;
  19253. /** @hidden */
  19254. _onVrDisplayPresentChange: Nullable<() => void>;
  19255. /**
  19256. * Observable signaled when VR display mode changes
  19257. */
  19258. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19259. /**
  19260. * Observable signaled when VR request present is complete
  19261. */
  19262. onVRRequestPresentComplete: Observable<boolean>;
  19263. /**
  19264. * Observable signaled when VR request present starts
  19265. */
  19266. onVRRequestPresentStart: Observable<Engine>;
  19267. /**
  19268. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19269. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19270. */
  19271. isInVRExclusivePointerMode: boolean;
  19272. /**
  19273. * Gets a boolean indicating if a webVR device was detected
  19274. * @returns true if a webVR device was detected
  19275. */
  19276. isVRDevicePresent(): boolean;
  19277. /**
  19278. * Gets the current webVR device
  19279. * @returns the current webVR device (or null)
  19280. */
  19281. getVRDevice(): any;
  19282. /**
  19283. * Initializes a webVR display and starts listening to display change events
  19284. * The onVRDisplayChangedObservable will be notified upon these changes
  19285. * @returns A promise containing a VRDisplay and if vr is supported
  19286. */
  19287. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19288. /** @hidden */
  19289. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19290. /**
  19291. * Gets or sets the presentation attributes used to configure VR rendering
  19292. */
  19293. vrPresentationAttributes?: IVRPresentationAttributes;
  19294. /**
  19295. * Call this function to switch to webVR mode
  19296. * Will do nothing if webVR is not supported or if there is no webVR device
  19297. * @param options the webvr options provided to the camera. mainly used for multiview
  19298. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19299. */
  19300. enableVR(options: WebVROptions): void;
  19301. /** @hidden */
  19302. _onVRFullScreenTriggered(): void;
  19303. }
  19304. }
  19305. declare module BABYLON {
  19306. /**
  19307. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19308. * IMPORTANT!! The data is right-hand data.
  19309. * @export
  19310. * @interface DevicePose
  19311. */
  19312. export interface DevicePose {
  19313. /**
  19314. * The position of the device, values in array are [x,y,z].
  19315. */
  19316. readonly position: Nullable<Float32Array>;
  19317. /**
  19318. * The linearVelocity of the device, values in array are [x,y,z].
  19319. */
  19320. readonly linearVelocity: Nullable<Float32Array>;
  19321. /**
  19322. * The linearAcceleration of the device, values in array are [x,y,z].
  19323. */
  19324. readonly linearAcceleration: Nullable<Float32Array>;
  19325. /**
  19326. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19327. */
  19328. readonly orientation: Nullable<Float32Array>;
  19329. /**
  19330. * The angularVelocity of the device, values in array are [x,y,z].
  19331. */
  19332. readonly angularVelocity: Nullable<Float32Array>;
  19333. /**
  19334. * The angularAcceleration of the device, values in array are [x,y,z].
  19335. */
  19336. readonly angularAcceleration: Nullable<Float32Array>;
  19337. }
  19338. /**
  19339. * Interface representing a pose controlled object in Babylon.
  19340. * A pose controlled object has both regular pose values as well as pose values
  19341. * from an external device such as a VR head mounted display
  19342. */
  19343. export interface PoseControlled {
  19344. /**
  19345. * The position of the object in babylon space.
  19346. */
  19347. position: Vector3;
  19348. /**
  19349. * The rotation quaternion of the object in babylon space.
  19350. */
  19351. rotationQuaternion: Quaternion;
  19352. /**
  19353. * The position of the device in babylon space.
  19354. */
  19355. devicePosition?: Vector3;
  19356. /**
  19357. * The rotation quaternion of the device in babylon space.
  19358. */
  19359. deviceRotationQuaternion: Quaternion;
  19360. /**
  19361. * The raw pose coming from the device.
  19362. */
  19363. rawPose: Nullable<DevicePose>;
  19364. /**
  19365. * The scale of the device to be used when translating from device space to babylon space.
  19366. */
  19367. deviceScaleFactor: number;
  19368. /**
  19369. * Updates the poseControlled values based on the input device pose.
  19370. * @param poseData the pose data to update the object with
  19371. */
  19372. updateFromDevice(poseData: DevicePose): void;
  19373. }
  19374. /**
  19375. * Set of options to customize the webVRCamera
  19376. */
  19377. export interface WebVROptions {
  19378. /**
  19379. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19380. */
  19381. trackPosition?: boolean;
  19382. /**
  19383. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19384. */
  19385. positionScale?: number;
  19386. /**
  19387. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19388. */
  19389. displayName?: string;
  19390. /**
  19391. * Should the native controller meshes be initialized. (default: true)
  19392. */
  19393. controllerMeshes?: boolean;
  19394. /**
  19395. * Creating a default HemiLight only on controllers. (default: true)
  19396. */
  19397. defaultLightingOnControllers?: boolean;
  19398. /**
  19399. * If you don't want to use the default VR button of the helper. (default: false)
  19400. */
  19401. useCustomVRButton?: boolean;
  19402. /**
  19403. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19404. */
  19405. customVRButton?: HTMLButtonElement;
  19406. /**
  19407. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19408. */
  19409. rayLength?: number;
  19410. /**
  19411. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19412. */
  19413. defaultHeight?: number;
  19414. /**
  19415. * If multiview should be used if availible (default: false)
  19416. */
  19417. useMultiview?: boolean;
  19418. }
  19419. /**
  19420. * This represents a WebVR camera.
  19421. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19422. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19423. */
  19424. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19425. private webVROptions;
  19426. /**
  19427. * @hidden
  19428. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19429. */
  19430. _vrDevice: any;
  19431. /**
  19432. * The rawPose of the vrDevice.
  19433. */
  19434. rawPose: Nullable<DevicePose>;
  19435. private _onVREnabled;
  19436. private _specsVersion;
  19437. private _attached;
  19438. private _frameData;
  19439. protected _descendants: Array<Node>;
  19440. private _deviceRoomPosition;
  19441. /** @hidden */
  19442. _deviceRoomRotationQuaternion: Quaternion;
  19443. private _standingMatrix;
  19444. /**
  19445. * Represents device position in babylon space.
  19446. */
  19447. devicePosition: Vector3;
  19448. /**
  19449. * Represents device rotation in babylon space.
  19450. */
  19451. deviceRotationQuaternion: Quaternion;
  19452. /**
  19453. * The scale of the device to be used when translating from device space to babylon space.
  19454. */
  19455. deviceScaleFactor: number;
  19456. private _deviceToWorld;
  19457. private _worldToDevice;
  19458. /**
  19459. * References to the webVR controllers for the vrDevice.
  19460. */
  19461. controllers: Array<WebVRController>;
  19462. /**
  19463. * Emits an event when a controller is attached.
  19464. */
  19465. onControllersAttachedObservable: Observable<WebVRController[]>;
  19466. /**
  19467. * Emits an event when a controller's mesh has been loaded;
  19468. */
  19469. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19470. /**
  19471. * Emits an event when the HMD's pose has been updated.
  19472. */
  19473. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19474. private _poseSet;
  19475. /**
  19476. * If the rig cameras be used as parent instead of this camera.
  19477. */
  19478. rigParenting: boolean;
  19479. private _lightOnControllers;
  19480. private _defaultHeight?;
  19481. /**
  19482. * Instantiates a WebVRFreeCamera.
  19483. * @param name The name of the WebVRFreeCamera
  19484. * @param position The starting anchor position for the camera
  19485. * @param scene The scene the camera belongs to
  19486. * @param webVROptions a set of customizable options for the webVRCamera
  19487. */
  19488. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19489. /**
  19490. * Gets the device distance from the ground in meters.
  19491. * @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.
  19492. */
  19493. deviceDistanceToRoomGround(): number;
  19494. /**
  19495. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19496. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19497. */
  19498. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19499. /**
  19500. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19501. * @returns A promise with a boolean set to if the standing matrix is supported.
  19502. */
  19503. useStandingMatrixAsync(): Promise<boolean>;
  19504. /**
  19505. * Disposes the camera
  19506. */
  19507. dispose(): void;
  19508. /**
  19509. * Gets a vrController by name.
  19510. * @param name The name of the controller to retreive
  19511. * @returns the controller matching the name specified or null if not found
  19512. */
  19513. getControllerByName(name: string): Nullable<WebVRController>;
  19514. private _leftController;
  19515. /**
  19516. * The controller corresponding to the users left hand.
  19517. */
  19518. get leftController(): Nullable<WebVRController>;
  19519. private _rightController;
  19520. /**
  19521. * The controller corresponding to the users right hand.
  19522. */
  19523. get rightController(): Nullable<WebVRController>;
  19524. /**
  19525. * Casts a ray forward from the vrCamera's gaze.
  19526. * @param length Length of the ray (default: 100)
  19527. * @returns the ray corresponding to the gaze
  19528. */
  19529. getForwardRay(length?: number): Ray;
  19530. /**
  19531. * @hidden
  19532. * Updates the camera based on device's frame data
  19533. */
  19534. _checkInputs(): void;
  19535. /**
  19536. * Updates the poseControlled values based on the input device pose.
  19537. * @param poseData Pose coming from the device
  19538. */
  19539. updateFromDevice(poseData: DevicePose): void;
  19540. private _htmlElementAttached;
  19541. private _detachIfAttached;
  19542. /**
  19543. * WebVR's attach control will start broadcasting frames to the device.
  19544. * Note that in certain browsers (chrome for example) this function must be called
  19545. * within a user-interaction callback. Example:
  19546. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19547. *
  19548. * @param element html element to attach the vrDevice to
  19549. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19550. */
  19551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19552. /**
  19553. * Detaches the camera from the html element and disables VR
  19554. *
  19555. * @param element html element to detach from
  19556. */
  19557. detachControl(element: HTMLElement): void;
  19558. /**
  19559. * @returns the name of this class
  19560. */
  19561. getClassName(): string;
  19562. /**
  19563. * Calls resetPose on the vrDisplay
  19564. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19565. */
  19566. resetToCurrentRotation(): void;
  19567. /**
  19568. * @hidden
  19569. * Updates the rig cameras (left and right eye)
  19570. */
  19571. _updateRigCameras(): void;
  19572. private _workingVector;
  19573. private _oneVector;
  19574. private _workingMatrix;
  19575. private updateCacheCalled;
  19576. private _correctPositionIfNotTrackPosition;
  19577. /**
  19578. * @hidden
  19579. * Updates the cached values of the camera
  19580. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19581. */
  19582. _updateCache(ignoreParentClass?: boolean): void;
  19583. /**
  19584. * @hidden
  19585. * Get current device position in babylon world
  19586. */
  19587. _computeDevicePosition(): void;
  19588. /**
  19589. * Updates the current device position and rotation in the babylon world
  19590. */
  19591. update(): void;
  19592. /**
  19593. * @hidden
  19594. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19595. * @returns an identity matrix
  19596. */
  19597. _getViewMatrix(): Matrix;
  19598. private _tmpMatrix;
  19599. /**
  19600. * This function is called by the two RIG cameras.
  19601. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19602. * @hidden
  19603. */
  19604. _getWebVRViewMatrix(): Matrix;
  19605. /** @hidden */
  19606. _getWebVRProjectionMatrix(): Matrix;
  19607. private _onGamepadConnectedObserver;
  19608. private _onGamepadDisconnectedObserver;
  19609. private _updateCacheWhenTrackingDisabledObserver;
  19610. /**
  19611. * Initializes the controllers and their meshes
  19612. */
  19613. initControllers(): void;
  19614. }
  19615. }
  19616. declare module BABYLON {
  19617. /**
  19618. * Size options for a post process
  19619. */
  19620. export type PostProcessOptions = {
  19621. width: number;
  19622. height: number;
  19623. };
  19624. /**
  19625. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19626. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19627. */
  19628. export class PostProcess {
  19629. /** Name of the PostProcess. */
  19630. name: string;
  19631. /**
  19632. * Gets or sets the unique id of the post process
  19633. */
  19634. uniqueId: number;
  19635. /**
  19636. * Width of the texture to apply the post process on
  19637. */
  19638. width: number;
  19639. /**
  19640. * Height of the texture to apply the post process on
  19641. */
  19642. height: number;
  19643. /**
  19644. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19645. * @hidden
  19646. */
  19647. _outputTexture: Nullable<InternalTexture>;
  19648. /**
  19649. * Sampling mode used by the shader
  19650. * See https://doc.babylonjs.com/classes/3.1/texture
  19651. */
  19652. renderTargetSamplingMode: number;
  19653. /**
  19654. * Clear color to use when screen clearing
  19655. */
  19656. clearColor: Color4;
  19657. /**
  19658. * If the buffer needs to be cleared before applying the post process. (default: true)
  19659. * Should be set to false if shader will overwrite all previous pixels.
  19660. */
  19661. autoClear: boolean;
  19662. /**
  19663. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19664. */
  19665. alphaMode: number;
  19666. /**
  19667. * Sets the setAlphaBlendConstants of the babylon engine
  19668. */
  19669. alphaConstants: Color4;
  19670. /**
  19671. * Animations to be used for the post processing
  19672. */
  19673. animations: Animation[];
  19674. /**
  19675. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19676. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19677. */
  19678. enablePixelPerfectMode: boolean;
  19679. /**
  19680. * Force the postprocess to be applied without taking in account viewport
  19681. */
  19682. forceFullscreenViewport: boolean;
  19683. /**
  19684. * List of inspectable custom properties (used by the Inspector)
  19685. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19686. */
  19687. inspectableCustomProperties: IInspectable[];
  19688. /**
  19689. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19690. *
  19691. * | Value | Type | Description |
  19692. * | ----- | ----------------------------------- | ----------- |
  19693. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19694. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19695. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19696. *
  19697. */
  19698. scaleMode: number;
  19699. /**
  19700. * Force textures to be a power of two (default: false)
  19701. */
  19702. alwaysForcePOT: boolean;
  19703. private _samples;
  19704. /**
  19705. * Number of sample textures (default: 1)
  19706. */
  19707. get samples(): number;
  19708. set samples(n: number);
  19709. /**
  19710. * Modify the scale of the post process to be the same as the viewport (default: false)
  19711. */
  19712. adaptScaleToCurrentViewport: boolean;
  19713. private _camera;
  19714. private _scene;
  19715. private _engine;
  19716. private _options;
  19717. private _reusable;
  19718. private _textureType;
  19719. private _textureFormat;
  19720. /**
  19721. * Smart array of input and output textures for the post process.
  19722. * @hidden
  19723. */
  19724. _textures: SmartArray<InternalTexture>;
  19725. /**
  19726. * The index in _textures that corresponds to the output texture.
  19727. * @hidden
  19728. */
  19729. _currentRenderTextureInd: number;
  19730. private _effect;
  19731. private _samplers;
  19732. private _fragmentUrl;
  19733. private _vertexUrl;
  19734. private _parameters;
  19735. private _scaleRatio;
  19736. protected _indexParameters: any;
  19737. private _shareOutputWithPostProcess;
  19738. private _texelSize;
  19739. private _forcedOutputTexture;
  19740. /**
  19741. * Returns the fragment url or shader name used in the post process.
  19742. * @returns the fragment url or name in the shader store.
  19743. */
  19744. getEffectName(): string;
  19745. /**
  19746. * An event triggered when the postprocess is activated.
  19747. */
  19748. onActivateObservable: Observable<Camera>;
  19749. private _onActivateObserver;
  19750. /**
  19751. * A function that is added to the onActivateObservable
  19752. */
  19753. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19754. /**
  19755. * An event triggered when the postprocess changes its size.
  19756. */
  19757. onSizeChangedObservable: Observable<PostProcess>;
  19758. private _onSizeChangedObserver;
  19759. /**
  19760. * A function that is added to the onSizeChangedObservable
  19761. */
  19762. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19763. /**
  19764. * An event triggered when the postprocess applies its effect.
  19765. */
  19766. onApplyObservable: Observable<Effect>;
  19767. private _onApplyObserver;
  19768. /**
  19769. * A function that is added to the onApplyObservable
  19770. */
  19771. set onApply(callback: (effect: Effect) => void);
  19772. /**
  19773. * An event triggered before rendering the postprocess
  19774. */
  19775. onBeforeRenderObservable: Observable<Effect>;
  19776. private _onBeforeRenderObserver;
  19777. /**
  19778. * A function that is added to the onBeforeRenderObservable
  19779. */
  19780. set onBeforeRender(callback: (effect: Effect) => void);
  19781. /**
  19782. * An event triggered after rendering the postprocess
  19783. */
  19784. onAfterRenderObservable: Observable<Effect>;
  19785. private _onAfterRenderObserver;
  19786. /**
  19787. * A function that is added to the onAfterRenderObservable
  19788. */
  19789. set onAfterRender(callback: (efect: Effect) => void);
  19790. /**
  19791. * 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
  19792. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19793. */
  19794. get inputTexture(): InternalTexture;
  19795. set inputTexture(value: InternalTexture);
  19796. /**
  19797. * Gets the camera which post process is applied to.
  19798. * @returns The camera the post process is applied to.
  19799. */
  19800. getCamera(): Camera;
  19801. /**
  19802. * Gets the texel size of the postprocess.
  19803. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19804. */
  19805. get texelSize(): Vector2;
  19806. /**
  19807. * Creates a new instance PostProcess
  19808. * @param name The name of the PostProcess.
  19809. * @param fragmentUrl The url of the fragment shader to be used.
  19810. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19811. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19812. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19813. * @param camera The camera to apply the render pass to.
  19814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19815. * @param engine The engine which the post process will be applied. (default: current engine)
  19816. * @param reusable If the post process can be reused on the same frame. (default: false)
  19817. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19818. * @param textureType Type of textures used when performing the post process. (default: 0)
  19819. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19820. * @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
  19821. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19822. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19823. */
  19824. constructor(
  19825. /** Name of the PostProcess. */
  19826. 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, textureFormat?: number);
  19827. /**
  19828. * Gets a string idenfifying the name of the class
  19829. * @returns "PostProcess" string
  19830. */
  19831. getClassName(): string;
  19832. /**
  19833. * Gets the engine which this post process belongs to.
  19834. * @returns The engine the post process was enabled with.
  19835. */
  19836. getEngine(): Engine;
  19837. /**
  19838. * The effect that is created when initializing the post process.
  19839. * @returns The created effect corresponding the the postprocess.
  19840. */
  19841. getEffect(): Effect;
  19842. /**
  19843. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19844. * @param postProcess The post process to share the output with.
  19845. * @returns This post process.
  19846. */
  19847. shareOutputWith(postProcess: PostProcess): PostProcess;
  19848. /**
  19849. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19850. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19851. */
  19852. useOwnOutput(): void;
  19853. /**
  19854. * Updates the effect with the current post process compile time values and recompiles the shader.
  19855. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19856. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19857. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19858. * @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
  19859. * @param onCompiled Called when the shader has been compiled.
  19860. * @param onError Called if there is an error when compiling a shader.
  19861. */
  19862. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19863. /**
  19864. * The post process is reusable if it can be used multiple times within one frame.
  19865. * @returns If the post process is reusable
  19866. */
  19867. isReusable(): boolean;
  19868. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19869. markTextureDirty(): void;
  19870. /**
  19871. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19872. * 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.
  19873. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19874. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19875. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19876. * @returns The target texture that was bound to be written to.
  19877. */
  19878. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19879. /**
  19880. * If the post process is supported.
  19881. */
  19882. get isSupported(): boolean;
  19883. /**
  19884. * The aspect ratio of the output texture.
  19885. */
  19886. get aspectRatio(): number;
  19887. /**
  19888. * Get a value indicating if the post-process is ready to be used
  19889. * @returns true if the post-process is ready (shader is compiled)
  19890. */
  19891. isReady(): boolean;
  19892. /**
  19893. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19894. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19895. */
  19896. apply(): Nullable<Effect>;
  19897. private _disposeTextures;
  19898. /**
  19899. * Disposes the post process.
  19900. * @param camera The camera to dispose the post process on.
  19901. */
  19902. dispose(camera?: Camera): void;
  19903. }
  19904. }
  19905. declare module BABYLON {
  19906. /** @hidden */
  19907. export var kernelBlurVaryingDeclaration: {
  19908. name: string;
  19909. shader: string;
  19910. };
  19911. }
  19912. declare module BABYLON {
  19913. /** @hidden */
  19914. export var kernelBlurFragment: {
  19915. name: string;
  19916. shader: string;
  19917. };
  19918. }
  19919. declare module BABYLON {
  19920. /** @hidden */
  19921. export var kernelBlurFragment2: {
  19922. name: string;
  19923. shader: string;
  19924. };
  19925. }
  19926. declare module BABYLON {
  19927. /** @hidden */
  19928. export var kernelBlurPixelShader: {
  19929. name: string;
  19930. shader: string;
  19931. };
  19932. }
  19933. declare module BABYLON {
  19934. /** @hidden */
  19935. export var kernelBlurVertex: {
  19936. name: string;
  19937. shader: string;
  19938. };
  19939. }
  19940. declare module BABYLON {
  19941. /** @hidden */
  19942. export var kernelBlurVertexShader: {
  19943. name: string;
  19944. shader: string;
  19945. };
  19946. }
  19947. declare module BABYLON {
  19948. /**
  19949. * The Blur Post Process which blurs an image based on a kernel and direction.
  19950. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19951. */
  19952. export class BlurPostProcess extends PostProcess {
  19953. /** The direction in which to blur the image. */
  19954. direction: Vector2;
  19955. private blockCompilation;
  19956. protected _kernel: number;
  19957. protected _idealKernel: number;
  19958. protected _packedFloat: boolean;
  19959. private _staticDefines;
  19960. /**
  19961. * Sets the length in pixels of the blur sample region
  19962. */
  19963. set kernel(v: number);
  19964. /**
  19965. * Gets the length in pixels of the blur sample region
  19966. */
  19967. get kernel(): number;
  19968. /**
  19969. * Sets wether or not the blur needs to unpack/repack floats
  19970. */
  19971. set packedFloat(v: boolean);
  19972. /**
  19973. * Gets wether or not the blur is unpacking/repacking floats
  19974. */
  19975. get packedFloat(): boolean;
  19976. /**
  19977. * Creates a new instance BlurPostProcess
  19978. * @param name The name of the effect.
  19979. * @param direction The direction in which to blur the image.
  19980. * @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.
  19981. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19982. * @param camera The camera to apply the render pass to.
  19983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19984. * @param engine The engine which the post process will be applied. (default: current engine)
  19985. * @param reusable If the post process can be reused on the same frame. (default: false)
  19986. * @param textureType Type of textures used when performing the post process. (default: 0)
  19987. * @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)
  19988. */
  19989. constructor(name: string,
  19990. /** The direction in which to blur the image. */
  19991. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19992. /**
  19993. * Updates the effect with the current post process compile time values and recompiles the shader.
  19994. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19995. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19996. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19997. * @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
  19998. * @param onCompiled Called when the shader has been compiled.
  19999. * @param onError Called if there is an error when compiling a shader.
  20000. */
  20001. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20002. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20003. /**
  20004. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20005. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20006. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20007. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20008. * The gaps between physical kernels are compensated for in the weighting of the samples
  20009. * @param idealKernel Ideal blur kernel.
  20010. * @return Nearest best kernel.
  20011. */
  20012. protected _nearestBestKernel(idealKernel: number): number;
  20013. /**
  20014. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20015. * @param x The point on the Gaussian distribution to sample.
  20016. * @return the value of the Gaussian function at x.
  20017. */
  20018. protected _gaussianWeight(x: number): number;
  20019. /**
  20020. * Generates a string that can be used as a floating point number in GLSL.
  20021. * @param x Value to print.
  20022. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20023. * @return GLSL float string.
  20024. */
  20025. protected _glslFloat(x: number, decimalFigures?: number): string;
  20026. }
  20027. }
  20028. declare module BABYLON {
  20029. /**
  20030. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20031. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20032. * You can then easily use it as a reflectionTexture on a flat surface.
  20033. * In case the surface is not a plane, please consider relying on reflection probes.
  20034. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20035. */
  20036. export class MirrorTexture extends RenderTargetTexture {
  20037. private scene;
  20038. /**
  20039. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20040. * 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.
  20041. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20042. */
  20043. mirrorPlane: Plane;
  20044. /**
  20045. * Define the blur ratio used to blur the reflection if needed.
  20046. */
  20047. set blurRatio(value: number);
  20048. get blurRatio(): number;
  20049. /**
  20050. * Define the adaptive blur kernel used to blur the reflection if needed.
  20051. * This will autocompute the closest best match for the `blurKernel`
  20052. */
  20053. set adaptiveBlurKernel(value: number);
  20054. /**
  20055. * Define the blur kernel used to blur the reflection if needed.
  20056. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20057. */
  20058. set blurKernel(value: number);
  20059. /**
  20060. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20061. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20062. */
  20063. set blurKernelX(value: number);
  20064. get blurKernelX(): number;
  20065. /**
  20066. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20067. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20068. */
  20069. set blurKernelY(value: number);
  20070. get blurKernelY(): number;
  20071. private _autoComputeBlurKernel;
  20072. protected _onRatioRescale(): void;
  20073. private _updateGammaSpace;
  20074. private _imageProcessingConfigChangeObserver;
  20075. private _transformMatrix;
  20076. private _mirrorMatrix;
  20077. private _savedViewMatrix;
  20078. private _blurX;
  20079. private _blurY;
  20080. private _adaptiveBlurKernel;
  20081. private _blurKernelX;
  20082. private _blurKernelY;
  20083. private _blurRatio;
  20084. /**
  20085. * Instantiates a Mirror Texture.
  20086. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20087. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20088. * You can then easily use it as a reflectionTexture on a flat surface.
  20089. * In case the surface is not a plane, please consider relying on reflection probes.
  20090. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20091. * @param name
  20092. * @param size
  20093. * @param scene
  20094. * @param generateMipMaps
  20095. * @param type
  20096. * @param samplingMode
  20097. * @param generateDepthBuffer
  20098. */
  20099. constructor(name: string, size: number | {
  20100. width: number;
  20101. height: number;
  20102. } | {
  20103. ratio: number;
  20104. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20105. private _preparePostProcesses;
  20106. /**
  20107. * Clone the mirror texture.
  20108. * @returns the cloned texture
  20109. */
  20110. clone(): MirrorTexture;
  20111. /**
  20112. * Serialize the texture to a JSON representation you could use in Parse later on
  20113. * @returns the serialized JSON representation
  20114. */
  20115. serialize(): any;
  20116. /**
  20117. * Dispose the texture and release its associated resources.
  20118. */
  20119. dispose(): void;
  20120. }
  20121. }
  20122. declare module BABYLON {
  20123. /**
  20124. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20125. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20126. */
  20127. export class Texture extends BaseTexture {
  20128. /**
  20129. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20130. */
  20131. static SerializeBuffers: boolean;
  20132. /** @hidden */
  20133. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20134. /** @hidden */
  20135. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20136. /** @hidden */
  20137. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20138. /** nearest is mag = nearest and min = nearest and mip = linear */
  20139. static readonly NEAREST_SAMPLINGMODE: number;
  20140. /** nearest is mag = nearest and min = nearest and mip = linear */
  20141. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20142. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20143. static readonly BILINEAR_SAMPLINGMODE: number;
  20144. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20145. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20146. /** Trilinear is mag = linear and min = linear and mip = linear */
  20147. static readonly TRILINEAR_SAMPLINGMODE: number;
  20148. /** Trilinear is mag = linear and min = linear and mip = linear */
  20149. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20150. /** mag = nearest and min = nearest and mip = nearest */
  20151. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20152. /** mag = nearest and min = linear and mip = nearest */
  20153. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20154. /** mag = nearest and min = linear and mip = linear */
  20155. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20156. /** mag = nearest and min = linear and mip = none */
  20157. static readonly NEAREST_LINEAR: number;
  20158. /** mag = nearest and min = nearest and mip = none */
  20159. static readonly NEAREST_NEAREST: number;
  20160. /** mag = linear and min = nearest and mip = nearest */
  20161. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20162. /** mag = linear and min = nearest and mip = linear */
  20163. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20164. /** mag = linear and min = linear and mip = none */
  20165. static readonly LINEAR_LINEAR: number;
  20166. /** mag = linear and min = nearest and mip = none */
  20167. static readonly LINEAR_NEAREST: number;
  20168. /** Explicit coordinates mode */
  20169. static readonly EXPLICIT_MODE: number;
  20170. /** Spherical coordinates mode */
  20171. static readonly SPHERICAL_MODE: number;
  20172. /** Planar coordinates mode */
  20173. static readonly PLANAR_MODE: number;
  20174. /** Cubic coordinates mode */
  20175. static readonly CUBIC_MODE: number;
  20176. /** Projection coordinates mode */
  20177. static readonly PROJECTION_MODE: number;
  20178. /** Inverse Cubic coordinates mode */
  20179. static readonly SKYBOX_MODE: number;
  20180. /** Inverse Cubic coordinates mode */
  20181. static readonly INVCUBIC_MODE: number;
  20182. /** Equirectangular coordinates mode */
  20183. static readonly EQUIRECTANGULAR_MODE: number;
  20184. /** Equirectangular Fixed coordinates mode */
  20185. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20186. /** Equirectangular Fixed Mirrored coordinates mode */
  20187. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20188. /** Texture is not repeating outside of 0..1 UVs */
  20189. static readonly CLAMP_ADDRESSMODE: number;
  20190. /** Texture is repeating outside of 0..1 UVs */
  20191. static readonly WRAP_ADDRESSMODE: number;
  20192. /** Texture is repeating and mirrored */
  20193. static readonly MIRROR_ADDRESSMODE: number;
  20194. /**
  20195. * 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
  20196. */
  20197. static UseSerializedUrlIfAny: boolean;
  20198. /**
  20199. * Define the url of the texture.
  20200. */
  20201. url: Nullable<string>;
  20202. /**
  20203. * Define an offset on the texture to offset the u coordinates of the UVs
  20204. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20205. */
  20206. uOffset: number;
  20207. /**
  20208. * Define an offset on the texture to offset the v coordinates of the UVs
  20209. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20210. */
  20211. vOffset: number;
  20212. /**
  20213. * Define an offset on the texture to scale the u coordinates of the UVs
  20214. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20215. */
  20216. uScale: number;
  20217. /**
  20218. * Define an offset on the texture to scale the v coordinates of the UVs
  20219. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20220. */
  20221. vScale: number;
  20222. /**
  20223. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20224. * @see http://doc.babylonjs.com/how_to/more_materials
  20225. */
  20226. uAng: number;
  20227. /**
  20228. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20229. * @see http://doc.babylonjs.com/how_to/more_materials
  20230. */
  20231. vAng: number;
  20232. /**
  20233. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20234. * @see http://doc.babylonjs.com/how_to/more_materials
  20235. */
  20236. wAng: number;
  20237. /**
  20238. * Defines the center of rotation (U)
  20239. */
  20240. uRotationCenter: number;
  20241. /**
  20242. * Defines the center of rotation (V)
  20243. */
  20244. vRotationCenter: number;
  20245. /**
  20246. * Defines the center of rotation (W)
  20247. */
  20248. wRotationCenter: number;
  20249. /**
  20250. * Are mip maps generated for this texture or not.
  20251. */
  20252. get noMipmap(): boolean;
  20253. /**
  20254. * List of inspectable custom properties (used by the Inspector)
  20255. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20256. */
  20257. inspectableCustomProperties: Nullable<IInspectable[]>;
  20258. private _noMipmap;
  20259. /** @hidden */
  20260. _invertY: boolean;
  20261. private _rowGenerationMatrix;
  20262. private _cachedTextureMatrix;
  20263. private _projectionModeMatrix;
  20264. private _t0;
  20265. private _t1;
  20266. private _t2;
  20267. private _cachedUOffset;
  20268. private _cachedVOffset;
  20269. private _cachedUScale;
  20270. private _cachedVScale;
  20271. private _cachedUAng;
  20272. private _cachedVAng;
  20273. private _cachedWAng;
  20274. private _cachedProjectionMatrixId;
  20275. private _cachedCoordinatesMode;
  20276. /** @hidden */
  20277. protected _initialSamplingMode: number;
  20278. /** @hidden */
  20279. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20280. private _deleteBuffer;
  20281. protected _format: Nullable<number>;
  20282. private _delayedOnLoad;
  20283. private _delayedOnError;
  20284. private _mimeType?;
  20285. /**
  20286. * Observable triggered once the texture has been loaded.
  20287. */
  20288. onLoadObservable: Observable<Texture>;
  20289. protected _isBlocking: boolean;
  20290. /**
  20291. * Is the texture preventing material to render while loading.
  20292. * If false, a default texture will be used instead of the loading one during the preparation step.
  20293. */
  20294. set isBlocking(value: boolean);
  20295. get isBlocking(): boolean;
  20296. /**
  20297. * Get the current sampling mode associated with the texture.
  20298. */
  20299. get samplingMode(): number;
  20300. /**
  20301. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20302. */
  20303. get invertY(): boolean;
  20304. /**
  20305. * Instantiates a new texture.
  20306. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20307. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20308. * @param url defines the url of the picture to load as a texture
  20309. * @param scene defines the scene or engine the texture will belong to
  20310. * @param noMipmap defines if the texture will require mip maps or not
  20311. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20312. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20313. * @param onLoad defines a callback triggered when the texture has been loaded
  20314. * @param onError defines a callback triggered when an error occurred during the loading session
  20315. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20316. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20317. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20318. * @param mimeType defines an optional mime type information
  20319. */
  20320. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20321. /**
  20322. * Update the url (and optional buffer) of this texture if url was null during construction.
  20323. * @param url the url of the texture
  20324. * @param buffer the buffer of the texture (defaults to null)
  20325. * @param onLoad callback called when the texture is loaded (defaults to null)
  20326. */
  20327. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20328. /**
  20329. * Finish the loading sequence of a texture flagged as delayed load.
  20330. * @hidden
  20331. */
  20332. delayLoad(): void;
  20333. private _prepareRowForTextureGeneration;
  20334. /**
  20335. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20336. * @returns the transform matrix of the texture.
  20337. */
  20338. getTextureMatrix(uBase?: number): Matrix;
  20339. /**
  20340. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20341. * @returns The reflection texture transform
  20342. */
  20343. getReflectionTextureMatrix(): Matrix;
  20344. /**
  20345. * Clones the texture.
  20346. * @returns the cloned texture
  20347. */
  20348. clone(): Texture;
  20349. /**
  20350. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20351. * @returns The JSON representation of the texture
  20352. */
  20353. serialize(): any;
  20354. /**
  20355. * Get the current class name of the texture useful for serialization or dynamic coding.
  20356. * @returns "Texture"
  20357. */
  20358. getClassName(): string;
  20359. /**
  20360. * Dispose the texture and release its associated resources.
  20361. */
  20362. dispose(): void;
  20363. /**
  20364. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20365. * @param parsedTexture Define the JSON representation of the texture
  20366. * @param scene Define the scene the parsed texture should be instantiated in
  20367. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20368. * @returns The parsed texture if successful
  20369. */
  20370. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20371. /**
  20372. * Creates a texture from its base 64 representation.
  20373. * @param data Define the base64 payload without the data: prefix
  20374. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20375. * @param scene Define the scene the texture should belong to
  20376. * @param noMipmap Forces the texture to not create mip map information if true
  20377. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20378. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20379. * @param onLoad define a callback triggered when the texture has been loaded
  20380. * @param onError define a callback triggered when an error occurred during the loading session
  20381. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20382. * @returns the created texture
  20383. */
  20384. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20385. /**
  20386. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20387. * @param data Define the base64 payload without the data: prefix
  20388. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20389. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20390. * @param scene Define the scene the texture should belong to
  20391. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20392. * @param noMipmap Forces the texture to not create mip map information if true
  20393. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20394. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20395. * @param onLoad define a callback triggered when the texture has been loaded
  20396. * @param onError define a callback triggered when an error occurred during the loading session
  20397. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20398. * @returns the created texture
  20399. */
  20400. 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;
  20401. }
  20402. }
  20403. declare module BABYLON {
  20404. /**
  20405. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20406. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20407. */
  20408. export class PostProcessManager {
  20409. private _scene;
  20410. private _indexBuffer;
  20411. private _vertexBuffers;
  20412. /**
  20413. * Creates a new instance PostProcess
  20414. * @param scene The scene that the post process is associated with.
  20415. */
  20416. constructor(scene: Scene);
  20417. private _prepareBuffers;
  20418. private _buildIndexBuffer;
  20419. /**
  20420. * Rebuilds the vertex buffers of the manager.
  20421. * @hidden
  20422. */
  20423. _rebuild(): void;
  20424. /**
  20425. * Prepares a frame to be run through a post process.
  20426. * @param sourceTexture The input texture to the post procesess. (default: null)
  20427. * @param postProcesses An array of post processes to be run. (default: null)
  20428. * @returns True if the post processes were able to be run.
  20429. * @hidden
  20430. */
  20431. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20432. /**
  20433. * Manually render a set of post processes to a texture.
  20434. * @param postProcesses An array of post processes to be run.
  20435. * @param targetTexture The target texture to render to.
  20436. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20437. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20438. * @param lodLevel defines which lod of the texture to render to
  20439. */
  20440. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20441. /**
  20442. * Finalize the result of the output of the postprocesses.
  20443. * @param doNotPresent If true the result will not be displayed to the screen.
  20444. * @param targetTexture The target texture to render to.
  20445. * @param faceIndex The index of the face to bind the target texture to.
  20446. * @param postProcesses The array of post processes to render.
  20447. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20448. * @hidden
  20449. */
  20450. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20451. /**
  20452. * Disposes of the post process manager.
  20453. */
  20454. dispose(): void;
  20455. }
  20456. }
  20457. declare module BABYLON {
  20458. /**
  20459. * This Helps creating a texture that will be created from a camera in your scene.
  20460. * It is basically a dynamic texture that could be used to create special effects for instance.
  20461. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20462. */
  20463. export class RenderTargetTexture extends Texture {
  20464. isCube: boolean;
  20465. /**
  20466. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20467. */
  20468. static readonly REFRESHRATE_RENDER_ONCE: number;
  20469. /**
  20470. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20471. */
  20472. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20473. /**
  20474. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20475. * the central point of your effect and can save a lot of performances.
  20476. */
  20477. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20478. /**
  20479. * Use this predicate to dynamically define the list of mesh you want to render.
  20480. * If set, the renderList property will be overwritten.
  20481. */
  20482. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20483. private _renderList;
  20484. /**
  20485. * Use this list to define the list of mesh you want to render.
  20486. */
  20487. get renderList(): Nullable<Array<AbstractMesh>>;
  20488. set renderList(value: Nullable<Array<AbstractMesh>>);
  20489. /**
  20490. * Use this function to overload the renderList array at rendering time.
  20491. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20492. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20493. * the cube (if the RTT is a cube, else layerOrFace=0).
  20494. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20495. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20496. * hold dummy elements!
  20497. */
  20498. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20499. private _hookArray;
  20500. /**
  20501. * Define if particles should be rendered in your texture.
  20502. */
  20503. renderParticles: boolean;
  20504. /**
  20505. * Define if sprites should be rendered in your texture.
  20506. */
  20507. renderSprites: boolean;
  20508. /**
  20509. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20510. */
  20511. coordinatesMode: number;
  20512. /**
  20513. * Define the camera used to render the texture.
  20514. */
  20515. activeCamera: Nullable<Camera>;
  20516. /**
  20517. * Override the render function of the texture with your own one.
  20518. */
  20519. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20520. /**
  20521. * Define if camera post processes should be use while rendering the texture.
  20522. */
  20523. useCameraPostProcesses: boolean;
  20524. /**
  20525. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20526. */
  20527. ignoreCameraViewport: boolean;
  20528. private _postProcessManager;
  20529. private _postProcesses;
  20530. private _resizeObserver;
  20531. /**
  20532. * An event triggered when the texture is unbind.
  20533. */
  20534. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20535. /**
  20536. * An event triggered when the texture is unbind.
  20537. */
  20538. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20539. private _onAfterUnbindObserver;
  20540. /**
  20541. * Set a after unbind callback in the texture.
  20542. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20543. */
  20544. set onAfterUnbind(callback: () => void);
  20545. /**
  20546. * An event triggered before rendering the texture
  20547. */
  20548. onBeforeRenderObservable: Observable<number>;
  20549. private _onBeforeRenderObserver;
  20550. /**
  20551. * Set a before render callback in the texture.
  20552. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20553. */
  20554. set onBeforeRender(callback: (faceIndex: number) => void);
  20555. /**
  20556. * An event triggered after rendering the texture
  20557. */
  20558. onAfterRenderObservable: Observable<number>;
  20559. private _onAfterRenderObserver;
  20560. /**
  20561. * Set a after render callback in the texture.
  20562. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20563. */
  20564. set onAfterRender(callback: (faceIndex: number) => void);
  20565. /**
  20566. * An event triggered after the texture clear
  20567. */
  20568. onClearObservable: Observable<Engine>;
  20569. private _onClearObserver;
  20570. /**
  20571. * Set a clear callback in the texture.
  20572. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20573. */
  20574. set onClear(callback: (Engine: Engine) => void);
  20575. /**
  20576. * An event triggered when the texture is resized.
  20577. */
  20578. onResizeObservable: Observable<RenderTargetTexture>;
  20579. /**
  20580. * Define the clear color of the Render Target if it should be different from the scene.
  20581. */
  20582. clearColor: Color4;
  20583. protected _size: number | {
  20584. width: number;
  20585. height: number;
  20586. layers?: number;
  20587. };
  20588. protected _initialSizeParameter: number | {
  20589. width: number;
  20590. height: number;
  20591. } | {
  20592. ratio: number;
  20593. };
  20594. protected _sizeRatio: Nullable<number>;
  20595. /** @hidden */
  20596. _generateMipMaps: boolean;
  20597. protected _renderingManager: RenderingManager;
  20598. /** @hidden */
  20599. _waitingRenderList: string[];
  20600. protected _doNotChangeAspectRatio: boolean;
  20601. protected _currentRefreshId: number;
  20602. protected _refreshRate: number;
  20603. protected _textureMatrix: Matrix;
  20604. protected _samples: number;
  20605. protected _renderTargetOptions: RenderTargetCreationOptions;
  20606. /**
  20607. * Gets render target creation options that were used.
  20608. */
  20609. get renderTargetOptions(): RenderTargetCreationOptions;
  20610. protected _engine: Engine;
  20611. protected _onRatioRescale(): void;
  20612. /**
  20613. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20614. * It must define where the camera used to render the texture is set
  20615. */
  20616. boundingBoxPosition: Vector3;
  20617. private _boundingBoxSize;
  20618. /**
  20619. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20620. * When defined, the cubemap will switch to local mode
  20621. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20622. * @example https://www.babylonjs-playground.com/#RNASML
  20623. */
  20624. set boundingBoxSize(value: Vector3);
  20625. get boundingBoxSize(): Vector3;
  20626. /**
  20627. * In case the RTT has been created with a depth texture, get the associated
  20628. * depth texture.
  20629. * Otherwise, return null.
  20630. */
  20631. get depthStencilTexture(): Nullable<InternalTexture>;
  20632. /**
  20633. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20634. * or used a shadow, depth texture...
  20635. * @param name The friendly name of the texture
  20636. * @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)
  20637. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20638. * @param generateMipMaps True if mip maps need to be generated after render.
  20639. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20640. * @param type The type of the buffer in the RTT (int, half float, float...)
  20641. * @param isCube True if a cube texture needs to be created
  20642. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20643. * @param generateDepthBuffer True to generate a depth buffer
  20644. * @param generateStencilBuffer True to generate a stencil buffer
  20645. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20646. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20647. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20648. */
  20649. constructor(name: string, size: number | {
  20650. width: number;
  20651. height: number;
  20652. layers?: number;
  20653. } | {
  20654. ratio: number;
  20655. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20656. /**
  20657. * Creates a depth stencil texture.
  20658. * This is only available in WebGL 2 or with the depth texture extension available.
  20659. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20660. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20661. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20662. */
  20663. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20664. private _processSizeParameter;
  20665. /**
  20666. * Define the number of samples to use in case of MSAA.
  20667. * It defaults to one meaning no MSAA has been enabled.
  20668. */
  20669. get samples(): number;
  20670. set samples(value: number);
  20671. /**
  20672. * Resets the refresh counter of the texture and start bak from scratch.
  20673. * Could be useful to regenerate the texture if it is setup to render only once.
  20674. */
  20675. resetRefreshCounter(): void;
  20676. /**
  20677. * Define the refresh rate of the texture or the rendering frequency.
  20678. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20679. */
  20680. get refreshRate(): number;
  20681. set refreshRate(value: number);
  20682. /**
  20683. * Adds a post process to the render target rendering passes.
  20684. * @param postProcess define the post process to add
  20685. */
  20686. addPostProcess(postProcess: PostProcess): void;
  20687. /**
  20688. * Clear all the post processes attached to the render target
  20689. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20690. */
  20691. clearPostProcesses(dispose?: boolean): void;
  20692. /**
  20693. * Remove one of the post process from the list of attached post processes to the texture
  20694. * @param postProcess define the post process to remove from the list
  20695. */
  20696. removePostProcess(postProcess: PostProcess): void;
  20697. /** @hidden */
  20698. _shouldRender(): boolean;
  20699. /**
  20700. * Gets the actual render size of the texture.
  20701. * @returns the width of the render size
  20702. */
  20703. getRenderSize(): number;
  20704. /**
  20705. * Gets the actual render width of the texture.
  20706. * @returns the width of the render size
  20707. */
  20708. getRenderWidth(): number;
  20709. /**
  20710. * Gets the actual render height of the texture.
  20711. * @returns the height of the render size
  20712. */
  20713. getRenderHeight(): number;
  20714. /**
  20715. * Gets the actual number of layers of the texture.
  20716. * @returns the number of layers
  20717. */
  20718. getRenderLayers(): number;
  20719. /**
  20720. * Get if the texture can be rescaled or not.
  20721. */
  20722. get canRescale(): boolean;
  20723. /**
  20724. * Resize the texture using a ratio.
  20725. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20726. */
  20727. scale(ratio: number): void;
  20728. /**
  20729. * Get the texture reflection matrix used to rotate/transform the reflection.
  20730. * @returns the reflection matrix
  20731. */
  20732. getReflectionTextureMatrix(): Matrix;
  20733. /**
  20734. * Resize the texture to a new desired size.
  20735. * Be carrefull as it will recreate all the data in the new texture.
  20736. * @param size Define the new size. It can be:
  20737. * - a number for squared texture,
  20738. * - an object containing { width: number, height: number }
  20739. * - or an object containing a ratio { ratio: number }
  20740. */
  20741. resize(size: number | {
  20742. width: number;
  20743. height: number;
  20744. } | {
  20745. ratio: number;
  20746. }): void;
  20747. private _defaultRenderListPrepared;
  20748. /**
  20749. * Renders all the objects from the render list into the texture.
  20750. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20751. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20752. */
  20753. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20754. private _bestReflectionRenderTargetDimension;
  20755. private _prepareRenderingManager;
  20756. /**
  20757. * @hidden
  20758. * @param faceIndex face index to bind to if this is a cubetexture
  20759. * @param layer defines the index of the texture to bind in the array
  20760. */
  20761. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20762. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20763. private renderToTarget;
  20764. /**
  20765. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20766. * This allowed control for front to back rendering or reversly depending of the special needs.
  20767. *
  20768. * @param renderingGroupId The rendering group id corresponding to its index
  20769. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20770. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20771. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20772. */
  20773. 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;
  20774. /**
  20775. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20776. *
  20777. * @param renderingGroupId The rendering group id corresponding to its index
  20778. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20779. */
  20780. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20781. /**
  20782. * Clones the texture.
  20783. * @returns the cloned texture
  20784. */
  20785. clone(): RenderTargetTexture;
  20786. /**
  20787. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20788. * @returns The JSON representation of the texture
  20789. */
  20790. serialize(): any;
  20791. /**
  20792. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20793. */
  20794. disposeFramebufferObjects(): void;
  20795. /**
  20796. * Dispose the texture and release its associated resources.
  20797. */
  20798. dispose(): void;
  20799. /** @hidden */
  20800. _rebuild(): void;
  20801. /**
  20802. * Clear the info related to rendering groups preventing retention point in material dispose.
  20803. */
  20804. freeRenderingGroups(): void;
  20805. /**
  20806. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20807. * @returns the view count
  20808. */
  20809. getViewCount(): number;
  20810. }
  20811. }
  20812. declare module BABYLON {
  20813. /**
  20814. * Options for compiling materials.
  20815. */
  20816. export interface IMaterialCompilationOptions {
  20817. /**
  20818. * Defines whether clip planes are enabled.
  20819. */
  20820. clipPlane: boolean;
  20821. /**
  20822. * Defines whether instances are enabled.
  20823. */
  20824. useInstances: boolean;
  20825. }
  20826. /**
  20827. * Base class for the main features of a material in Babylon.js
  20828. */
  20829. export class Material implements IAnimatable {
  20830. /**
  20831. * Returns the triangle fill mode
  20832. */
  20833. static readonly TriangleFillMode: number;
  20834. /**
  20835. * Returns the wireframe mode
  20836. */
  20837. static readonly WireFrameFillMode: number;
  20838. /**
  20839. * Returns the point fill mode
  20840. */
  20841. static readonly PointFillMode: number;
  20842. /**
  20843. * Returns the point list draw mode
  20844. */
  20845. static readonly PointListDrawMode: number;
  20846. /**
  20847. * Returns the line list draw mode
  20848. */
  20849. static readonly LineListDrawMode: number;
  20850. /**
  20851. * Returns the line loop draw mode
  20852. */
  20853. static readonly LineLoopDrawMode: number;
  20854. /**
  20855. * Returns the line strip draw mode
  20856. */
  20857. static readonly LineStripDrawMode: number;
  20858. /**
  20859. * Returns the triangle strip draw mode
  20860. */
  20861. static readonly TriangleStripDrawMode: number;
  20862. /**
  20863. * Returns the triangle fan draw mode
  20864. */
  20865. static readonly TriangleFanDrawMode: number;
  20866. /**
  20867. * Stores the clock-wise side orientation
  20868. */
  20869. static readonly ClockWiseSideOrientation: number;
  20870. /**
  20871. * Stores the counter clock-wise side orientation
  20872. */
  20873. static readonly CounterClockWiseSideOrientation: number;
  20874. /**
  20875. * The dirty texture flag value
  20876. */
  20877. static readonly TextureDirtyFlag: number;
  20878. /**
  20879. * The dirty light flag value
  20880. */
  20881. static readonly LightDirtyFlag: number;
  20882. /**
  20883. * The dirty fresnel flag value
  20884. */
  20885. static readonly FresnelDirtyFlag: number;
  20886. /**
  20887. * The dirty attribute flag value
  20888. */
  20889. static readonly AttributesDirtyFlag: number;
  20890. /**
  20891. * The dirty misc flag value
  20892. */
  20893. static readonly MiscDirtyFlag: number;
  20894. /**
  20895. * The all dirty flag value
  20896. */
  20897. static readonly AllDirtyFlag: number;
  20898. /**
  20899. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20900. */
  20901. static readonly MATERIAL_OPAQUE: number;
  20902. /**
  20903. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20904. */
  20905. static readonly MATERIAL_ALPHATEST: number;
  20906. /**
  20907. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20908. */
  20909. static readonly MATERIAL_ALPHABLEND: number;
  20910. /**
  20911. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20912. * They are also discarded below the alpha cutoff threshold to improve performances.
  20913. */
  20914. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  20915. /**
  20916. * The ID of the material
  20917. */
  20918. id: string;
  20919. /**
  20920. * Gets or sets the unique id of the material
  20921. */
  20922. uniqueId: number;
  20923. /**
  20924. * The name of the material
  20925. */
  20926. name: string;
  20927. /**
  20928. * Gets or sets user defined metadata
  20929. */
  20930. metadata: any;
  20931. /**
  20932. * For internal use only. Please do not use.
  20933. */
  20934. reservedDataStore: any;
  20935. /**
  20936. * Specifies if the ready state should be checked on each call
  20937. */
  20938. checkReadyOnEveryCall: boolean;
  20939. /**
  20940. * Specifies if the ready state should be checked once
  20941. */
  20942. checkReadyOnlyOnce: boolean;
  20943. /**
  20944. * The state of the material
  20945. */
  20946. state: string;
  20947. /**
  20948. * The alpha value of the material
  20949. */
  20950. protected _alpha: number;
  20951. /**
  20952. * List of inspectable custom properties (used by the Inspector)
  20953. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20954. */
  20955. inspectableCustomProperties: IInspectable[];
  20956. /**
  20957. * Sets the alpha value of the material
  20958. */
  20959. set alpha(value: number);
  20960. /**
  20961. * Gets the alpha value of the material
  20962. */
  20963. get alpha(): number;
  20964. /**
  20965. * Specifies if back face culling is enabled
  20966. */
  20967. protected _backFaceCulling: boolean;
  20968. /**
  20969. * Sets the back-face culling state
  20970. */
  20971. set backFaceCulling(value: boolean);
  20972. /**
  20973. * Gets the back-face culling state
  20974. */
  20975. get backFaceCulling(): boolean;
  20976. /**
  20977. * Stores the value for side orientation
  20978. */
  20979. sideOrientation: number;
  20980. /**
  20981. * Callback triggered when the material is compiled
  20982. */
  20983. onCompiled: Nullable<(effect: Effect) => void>;
  20984. /**
  20985. * Callback triggered when an error occurs
  20986. */
  20987. onError: Nullable<(effect: Effect, errors: string) => void>;
  20988. /**
  20989. * Callback triggered to get the render target textures
  20990. */
  20991. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20992. /**
  20993. * Gets a boolean indicating that current material needs to register RTT
  20994. */
  20995. get hasRenderTargetTextures(): boolean;
  20996. /**
  20997. * Specifies if the material should be serialized
  20998. */
  20999. doNotSerialize: boolean;
  21000. /**
  21001. * @hidden
  21002. */
  21003. _storeEffectOnSubMeshes: boolean;
  21004. /**
  21005. * Stores the animations for the material
  21006. */
  21007. animations: Nullable<Array<Animation>>;
  21008. /**
  21009. * An event triggered when the material is disposed
  21010. */
  21011. onDisposeObservable: Observable<Material>;
  21012. /**
  21013. * An observer which watches for dispose events
  21014. */
  21015. private _onDisposeObserver;
  21016. private _onUnBindObservable;
  21017. /**
  21018. * Called during a dispose event
  21019. */
  21020. set onDispose(callback: () => void);
  21021. private _onBindObservable;
  21022. /**
  21023. * An event triggered when the material is bound
  21024. */
  21025. get onBindObservable(): Observable<AbstractMesh>;
  21026. /**
  21027. * An observer which watches for bind events
  21028. */
  21029. private _onBindObserver;
  21030. /**
  21031. * Called during a bind event
  21032. */
  21033. set onBind(callback: (Mesh: AbstractMesh) => void);
  21034. /**
  21035. * An event triggered when the material is unbound
  21036. */
  21037. get onUnBindObservable(): Observable<Material>;
  21038. /**
  21039. * Stores the value of the alpha mode
  21040. */
  21041. private _alphaMode;
  21042. /**
  21043. * Sets the value of the alpha mode.
  21044. *
  21045. * | Value | Type | Description |
  21046. * | --- | --- | --- |
  21047. * | 0 | ALPHA_DISABLE | |
  21048. * | 1 | ALPHA_ADD | |
  21049. * | 2 | ALPHA_COMBINE | |
  21050. * | 3 | ALPHA_SUBTRACT | |
  21051. * | 4 | ALPHA_MULTIPLY | |
  21052. * | 5 | ALPHA_MAXIMIZED | |
  21053. * | 6 | ALPHA_ONEONE | |
  21054. * | 7 | ALPHA_PREMULTIPLIED | |
  21055. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21056. * | 9 | ALPHA_INTERPOLATE | |
  21057. * | 10 | ALPHA_SCREENMODE | |
  21058. *
  21059. */
  21060. set alphaMode(value: number);
  21061. /**
  21062. * Gets the value of the alpha mode
  21063. */
  21064. get alphaMode(): number;
  21065. /**
  21066. * Stores the state of the need depth pre-pass value
  21067. */
  21068. private _needDepthPrePass;
  21069. /**
  21070. * Sets the need depth pre-pass value
  21071. */
  21072. set needDepthPrePass(value: boolean);
  21073. /**
  21074. * Gets the depth pre-pass value
  21075. */
  21076. get needDepthPrePass(): boolean;
  21077. /**
  21078. * Specifies if depth writing should be disabled
  21079. */
  21080. disableDepthWrite: boolean;
  21081. /**
  21082. * Specifies if depth writing should be forced
  21083. */
  21084. forceDepthWrite: boolean;
  21085. /**
  21086. * Specifies the depth function that should be used. 0 means the default engine function
  21087. */
  21088. depthFunction: number;
  21089. /**
  21090. * Specifies if there should be a separate pass for culling
  21091. */
  21092. separateCullingPass: boolean;
  21093. /**
  21094. * Stores the state specifing if fog should be enabled
  21095. */
  21096. private _fogEnabled;
  21097. /**
  21098. * Sets the state for enabling fog
  21099. */
  21100. set fogEnabled(value: boolean);
  21101. /**
  21102. * Gets the value of the fog enabled state
  21103. */
  21104. get fogEnabled(): boolean;
  21105. /**
  21106. * Stores the size of points
  21107. */
  21108. pointSize: number;
  21109. /**
  21110. * Stores the z offset value
  21111. */
  21112. zOffset: number;
  21113. /**
  21114. * Gets a value specifying if wireframe mode is enabled
  21115. */
  21116. get wireframe(): boolean;
  21117. /**
  21118. * Sets the state of wireframe mode
  21119. */
  21120. set wireframe(value: boolean);
  21121. /**
  21122. * Gets the value specifying if point clouds are enabled
  21123. */
  21124. get pointsCloud(): boolean;
  21125. /**
  21126. * Sets the state of point cloud mode
  21127. */
  21128. set pointsCloud(value: boolean);
  21129. /**
  21130. * Gets the material fill mode
  21131. */
  21132. get fillMode(): number;
  21133. /**
  21134. * Sets the material fill mode
  21135. */
  21136. set fillMode(value: number);
  21137. /**
  21138. * @hidden
  21139. * Stores the effects for the material
  21140. */
  21141. _effect: Nullable<Effect>;
  21142. /**
  21143. * Specifies if uniform buffers should be used
  21144. */
  21145. private _useUBO;
  21146. /**
  21147. * Stores a reference to the scene
  21148. */
  21149. private _scene;
  21150. /**
  21151. * Stores the fill mode state
  21152. */
  21153. private _fillMode;
  21154. /**
  21155. * Specifies if the depth write state should be cached
  21156. */
  21157. private _cachedDepthWriteState;
  21158. /**
  21159. * Specifies if the depth function state should be cached
  21160. */
  21161. private _cachedDepthFunctionState;
  21162. /**
  21163. * Stores the uniform buffer
  21164. */
  21165. protected _uniformBuffer: UniformBuffer;
  21166. /** @hidden */
  21167. _indexInSceneMaterialArray: number;
  21168. /** @hidden */
  21169. meshMap: Nullable<{
  21170. [id: string]: AbstractMesh | undefined;
  21171. }>;
  21172. /**
  21173. * Creates a material instance
  21174. * @param name defines the name of the material
  21175. * @param scene defines the scene to reference
  21176. * @param doNotAdd specifies if the material should be added to the scene
  21177. */
  21178. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21179. /**
  21180. * Returns a string representation of the current material
  21181. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21182. * @returns a string with material information
  21183. */
  21184. toString(fullDetails?: boolean): string;
  21185. /**
  21186. * Gets the class name of the material
  21187. * @returns a string with the class name of the material
  21188. */
  21189. getClassName(): string;
  21190. /**
  21191. * Specifies if updates for the material been locked
  21192. */
  21193. get isFrozen(): boolean;
  21194. /**
  21195. * Locks updates for the material
  21196. */
  21197. freeze(): void;
  21198. /**
  21199. * Unlocks updates for the material
  21200. */
  21201. unfreeze(): void;
  21202. /**
  21203. * Specifies if the material is ready to be used
  21204. * @param mesh defines the mesh to check
  21205. * @param useInstances specifies if instances should be used
  21206. * @returns a boolean indicating if the material is ready to be used
  21207. */
  21208. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21209. /**
  21210. * Specifies that the submesh is ready to be used
  21211. * @param mesh defines the mesh to check
  21212. * @param subMesh defines which submesh to check
  21213. * @param useInstances specifies that instances should be used
  21214. * @returns a boolean indicating that the submesh is ready or not
  21215. */
  21216. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21217. /**
  21218. * Returns the material effect
  21219. * @returns the effect associated with the material
  21220. */
  21221. getEffect(): Nullable<Effect>;
  21222. /**
  21223. * Returns the current scene
  21224. * @returns a Scene
  21225. */
  21226. getScene(): Scene;
  21227. /**
  21228. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21229. */
  21230. protected _forceAlphaTest: boolean;
  21231. /**
  21232. * The transparency mode of the material.
  21233. */
  21234. protected _transparencyMode: Nullable<number>;
  21235. /**
  21236. * Gets the current transparency mode.
  21237. */
  21238. get transparencyMode(): Nullable<number>;
  21239. /**
  21240. * Sets the transparency mode of the material.
  21241. *
  21242. * | Value | Type | Description |
  21243. * | ----- | ----------------------------------- | ----------- |
  21244. * | 0 | OPAQUE | |
  21245. * | 1 | ALPHATEST | |
  21246. * | 2 | ALPHABLEND | |
  21247. * | 3 | ALPHATESTANDBLEND | |
  21248. *
  21249. */
  21250. set transparencyMode(value: Nullable<number>);
  21251. /**
  21252. * Returns true if alpha blending should be disabled.
  21253. */
  21254. protected get _disableAlphaBlending(): boolean;
  21255. /**
  21256. * Specifies whether or not this material should be rendered in alpha blend mode.
  21257. * @returns a boolean specifying if alpha blending is needed
  21258. */
  21259. needAlphaBlending(): boolean;
  21260. /**
  21261. * Specifies if the mesh will require alpha blending
  21262. * @param mesh defines the mesh to check
  21263. * @returns a boolean specifying if alpha blending is needed for the mesh
  21264. */
  21265. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21266. /**
  21267. * Specifies whether or not this material should be rendered in alpha test mode.
  21268. * @returns a boolean specifying if an alpha test is needed.
  21269. */
  21270. needAlphaTesting(): boolean;
  21271. /**
  21272. * Specifies if material alpha testing should be turned on for the mesh
  21273. * @param mesh defines the mesh to check
  21274. */
  21275. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21276. /**
  21277. * Gets the texture used for the alpha test
  21278. * @returns the texture to use for alpha testing
  21279. */
  21280. getAlphaTestTexture(): Nullable<BaseTexture>;
  21281. /**
  21282. * Marks the material to indicate that it needs to be re-calculated
  21283. */
  21284. markDirty(): void;
  21285. /** @hidden */
  21286. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21287. /**
  21288. * Binds the material to the mesh
  21289. * @param world defines the world transformation matrix
  21290. * @param mesh defines the mesh to bind the material to
  21291. */
  21292. bind(world: Matrix, mesh?: Mesh): void;
  21293. /**
  21294. * Binds the submesh to the material
  21295. * @param world defines the world transformation matrix
  21296. * @param mesh defines the mesh containing the submesh
  21297. * @param subMesh defines the submesh to bind the material to
  21298. */
  21299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21300. /**
  21301. * Binds the world matrix to the material
  21302. * @param world defines the world transformation matrix
  21303. */
  21304. bindOnlyWorldMatrix(world: Matrix): void;
  21305. /**
  21306. * Binds the scene's uniform buffer to the effect.
  21307. * @param effect defines the effect to bind to the scene uniform buffer
  21308. * @param sceneUbo defines the uniform buffer storing scene data
  21309. */
  21310. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21311. /**
  21312. * Binds the view matrix to the effect
  21313. * @param effect defines the effect to bind the view matrix to
  21314. */
  21315. bindView(effect: Effect): void;
  21316. /**
  21317. * Binds the view projection matrix to the effect
  21318. * @param effect defines the effect to bind the view projection matrix to
  21319. */
  21320. bindViewProjection(effect: Effect): void;
  21321. /**
  21322. * Processes to execute after binding the material to a mesh
  21323. * @param mesh defines the rendered mesh
  21324. */
  21325. protected _afterBind(mesh?: Mesh): void;
  21326. /**
  21327. * Unbinds the material from the mesh
  21328. */
  21329. unbind(): void;
  21330. /**
  21331. * Gets the active textures from the material
  21332. * @returns an array of textures
  21333. */
  21334. getActiveTextures(): BaseTexture[];
  21335. /**
  21336. * Specifies if the material uses a texture
  21337. * @param texture defines the texture to check against the material
  21338. * @returns a boolean specifying if the material uses the texture
  21339. */
  21340. hasTexture(texture: BaseTexture): boolean;
  21341. /**
  21342. * Makes a duplicate of the material, and gives it a new name
  21343. * @param name defines the new name for the duplicated material
  21344. * @returns the cloned material
  21345. */
  21346. clone(name: string): Nullable<Material>;
  21347. /**
  21348. * Gets the meshes bound to the material
  21349. * @returns an array of meshes bound to the material
  21350. */
  21351. getBindedMeshes(): AbstractMesh[];
  21352. /**
  21353. * Force shader compilation
  21354. * @param mesh defines the mesh associated with this material
  21355. * @param onCompiled defines a function to execute once the material is compiled
  21356. * @param options defines the options to configure the compilation
  21357. * @param onError defines a function to execute if the material fails compiling
  21358. */
  21359. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21360. /**
  21361. * Force shader compilation
  21362. * @param mesh defines the mesh that will use this material
  21363. * @param options defines additional options for compiling the shaders
  21364. * @returns a promise that resolves when the compilation completes
  21365. */
  21366. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21367. private static readonly _AllDirtyCallBack;
  21368. private static readonly _ImageProcessingDirtyCallBack;
  21369. private static readonly _TextureDirtyCallBack;
  21370. private static readonly _FresnelDirtyCallBack;
  21371. private static readonly _MiscDirtyCallBack;
  21372. private static readonly _LightsDirtyCallBack;
  21373. private static readonly _AttributeDirtyCallBack;
  21374. private static _FresnelAndMiscDirtyCallBack;
  21375. private static _TextureAndMiscDirtyCallBack;
  21376. private static readonly _DirtyCallbackArray;
  21377. private static readonly _RunDirtyCallBacks;
  21378. /**
  21379. * Marks a define in the material to indicate that it needs to be re-computed
  21380. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21381. */
  21382. markAsDirty(flag: number): void;
  21383. /**
  21384. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21385. * @param func defines a function which checks material defines against the submeshes
  21386. */
  21387. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21388. /**
  21389. * Indicates that we need to re-calculated for all submeshes
  21390. */
  21391. protected _markAllSubMeshesAsAllDirty(): void;
  21392. /**
  21393. * Indicates that image processing needs to be re-calculated for all submeshes
  21394. */
  21395. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21396. /**
  21397. * Indicates that textures need to be re-calculated for all submeshes
  21398. */
  21399. protected _markAllSubMeshesAsTexturesDirty(): void;
  21400. /**
  21401. * Indicates that fresnel needs to be re-calculated for all submeshes
  21402. */
  21403. protected _markAllSubMeshesAsFresnelDirty(): void;
  21404. /**
  21405. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21406. */
  21407. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21408. /**
  21409. * Indicates that lights need to be re-calculated for all submeshes
  21410. */
  21411. protected _markAllSubMeshesAsLightsDirty(): void;
  21412. /**
  21413. * Indicates that attributes need to be re-calculated for all submeshes
  21414. */
  21415. protected _markAllSubMeshesAsAttributesDirty(): void;
  21416. /**
  21417. * Indicates that misc needs to be re-calculated for all submeshes
  21418. */
  21419. protected _markAllSubMeshesAsMiscDirty(): void;
  21420. /**
  21421. * Indicates that textures and misc need to be re-calculated for all submeshes
  21422. */
  21423. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21424. /**
  21425. * Disposes the material
  21426. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21427. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21428. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21429. */
  21430. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21431. /** @hidden */
  21432. private releaseVertexArrayObject;
  21433. /**
  21434. * Serializes this material
  21435. * @returns the serialized material object
  21436. */
  21437. serialize(): any;
  21438. /**
  21439. * Creates a material from parsed material data
  21440. * @param parsedMaterial defines parsed material data
  21441. * @param scene defines the hosting scene
  21442. * @param rootUrl defines the root URL to use to load textures
  21443. * @returns a new material
  21444. */
  21445. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21446. }
  21447. }
  21448. declare module BABYLON {
  21449. /**
  21450. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21451. * separate meshes. This can be use to improve performances.
  21452. * @see http://doc.babylonjs.com/how_to/multi_materials
  21453. */
  21454. export class MultiMaterial extends Material {
  21455. private _subMaterials;
  21456. /**
  21457. * Gets or Sets the list of Materials used within the multi material.
  21458. * They need to be ordered according to the submeshes order in the associated mesh
  21459. */
  21460. get subMaterials(): Nullable<Material>[];
  21461. set subMaterials(value: Nullable<Material>[]);
  21462. /**
  21463. * Function used to align with Node.getChildren()
  21464. * @returns the list of Materials used within the multi material
  21465. */
  21466. getChildren(): Nullable<Material>[];
  21467. /**
  21468. * Instantiates a new Multi Material
  21469. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21470. * separate meshes. This can be use to improve performances.
  21471. * @see http://doc.babylonjs.com/how_to/multi_materials
  21472. * @param name Define the name in the scene
  21473. * @param scene Define the scene the material belongs to
  21474. */
  21475. constructor(name: string, scene: Scene);
  21476. private _hookArray;
  21477. /**
  21478. * Get one of the submaterial by its index in the submaterials array
  21479. * @param index The index to look the sub material at
  21480. * @returns The Material if the index has been defined
  21481. */
  21482. getSubMaterial(index: number): Nullable<Material>;
  21483. /**
  21484. * Get the list of active textures for the whole sub materials list.
  21485. * @returns All the textures that will be used during the rendering
  21486. */
  21487. getActiveTextures(): BaseTexture[];
  21488. /**
  21489. * Gets the current class name of the material e.g. "MultiMaterial"
  21490. * Mainly use in serialization.
  21491. * @returns the class name
  21492. */
  21493. getClassName(): string;
  21494. /**
  21495. * Checks if the material is ready to render the requested sub mesh
  21496. * @param mesh Define the mesh the submesh belongs to
  21497. * @param subMesh Define the sub mesh to look readyness for
  21498. * @param useInstances Define whether or not the material is used with instances
  21499. * @returns true if ready, otherwise false
  21500. */
  21501. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21502. /**
  21503. * Clones the current material and its related sub materials
  21504. * @param name Define the name of the newly cloned material
  21505. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21506. * @returns the cloned material
  21507. */
  21508. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21509. /**
  21510. * Serializes the materials into a JSON representation.
  21511. * @returns the JSON representation
  21512. */
  21513. serialize(): any;
  21514. /**
  21515. * Dispose the material and release its associated resources
  21516. * @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)
  21517. * @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)
  21518. * @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)
  21519. */
  21520. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21521. /**
  21522. * Creates a MultiMaterial from parsed MultiMaterial data.
  21523. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21524. * @param scene defines the hosting scene
  21525. * @returns a new MultiMaterial
  21526. */
  21527. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21528. }
  21529. }
  21530. declare module BABYLON {
  21531. /**
  21532. * Base class for submeshes
  21533. */
  21534. export class BaseSubMesh {
  21535. /** @hidden */
  21536. _materialDefines: Nullable<MaterialDefines>;
  21537. /** @hidden */
  21538. _materialEffect: Nullable<Effect>;
  21539. /**
  21540. * Gets material defines used by the effect associated to the sub mesh
  21541. */
  21542. get materialDefines(): Nullable<MaterialDefines>;
  21543. /**
  21544. * Sets material defines used by the effect associated to the sub mesh
  21545. */
  21546. set materialDefines(defines: Nullable<MaterialDefines>);
  21547. /**
  21548. * Gets associated effect
  21549. */
  21550. get effect(): Nullable<Effect>;
  21551. /**
  21552. * Sets associated effect (effect used to render this submesh)
  21553. * @param effect defines the effect to associate with
  21554. * @param defines defines the set of defines used to compile this effect
  21555. */
  21556. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21557. }
  21558. /**
  21559. * Defines a subdivision inside a mesh
  21560. */
  21561. export class SubMesh extends BaseSubMesh implements ICullable {
  21562. /** the material index to use */
  21563. materialIndex: number;
  21564. /** vertex index start */
  21565. verticesStart: number;
  21566. /** vertices count */
  21567. verticesCount: number;
  21568. /** index start */
  21569. indexStart: number;
  21570. /** indices count */
  21571. indexCount: number;
  21572. /** @hidden */
  21573. _linesIndexCount: number;
  21574. private _mesh;
  21575. private _renderingMesh;
  21576. private _boundingInfo;
  21577. private _linesIndexBuffer;
  21578. /** @hidden */
  21579. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21580. /** @hidden */
  21581. _trianglePlanes: Plane[];
  21582. /** @hidden */
  21583. _lastColliderTransformMatrix: Nullable<Matrix>;
  21584. /** @hidden */
  21585. _renderId: number;
  21586. /** @hidden */
  21587. _alphaIndex: number;
  21588. /** @hidden */
  21589. _distanceToCamera: number;
  21590. /** @hidden */
  21591. _id: number;
  21592. private _currentMaterial;
  21593. /**
  21594. * Add a new submesh to a mesh
  21595. * @param materialIndex defines the material index to use
  21596. * @param verticesStart defines vertex index start
  21597. * @param verticesCount defines vertices count
  21598. * @param indexStart defines index start
  21599. * @param indexCount defines indices count
  21600. * @param mesh defines the parent mesh
  21601. * @param renderingMesh defines an optional rendering mesh
  21602. * @param createBoundingBox defines if bounding box should be created for this submesh
  21603. * @returns the new submesh
  21604. */
  21605. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21606. /**
  21607. * Creates a new submesh
  21608. * @param materialIndex defines the material index to use
  21609. * @param verticesStart defines vertex index start
  21610. * @param verticesCount defines vertices count
  21611. * @param indexStart defines index start
  21612. * @param indexCount defines indices count
  21613. * @param mesh defines the parent mesh
  21614. * @param renderingMesh defines an optional rendering mesh
  21615. * @param createBoundingBox defines if bounding box should be created for this submesh
  21616. */
  21617. constructor(
  21618. /** the material index to use */
  21619. materialIndex: number,
  21620. /** vertex index start */
  21621. verticesStart: number,
  21622. /** vertices count */
  21623. verticesCount: number,
  21624. /** index start */
  21625. indexStart: number,
  21626. /** indices count */
  21627. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21628. /**
  21629. * Returns true if this submesh covers the entire parent mesh
  21630. * @ignorenaming
  21631. */
  21632. get IsGlobal(): boolean;
  21633. /**
  21634. * Returns the submesh BoudingInfo object
  21635. * @returns current bounding info (or mesh's one if the submesh is global)
  21636. */
  21637. getBoundingInfo(): BoundingInfo;
  21638. /**
  21639. * Sets the submesh BoundingInfo
  21640. * @param boundingInfo defines the new bounding info to use
  21641. * @returns the SubMesh
  21642. */
  21643. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21644. /**
  21645. * Returns the mesh of the current submesh
  21646. * @return the parent mesh
  21647. */
  21648. getMesh(): AbstractMesh;
  21649. /**
  21650. * Returns the rendering mesh of the submesh
  21651. * @returns the rendering mesh (could be different from parent mesh)
  21652. */
  21653. getRenderingMesh(): Mesh;
  21654. /**
  21655. * Returns the submesh material
  21656. * @returns null or the current material
  21657. */
  21658. getMaterial(): Nullable<Material>;
  21659. /**
  21660. * Sets a new updated BoundingInfo object to the submesh
  21661. * @param data defines an optional position array to use to determine the bounding info
  21662. * @returns the SubMesh
  21663. */
  21664. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21665. /** @hidden */
  21666. _checkCollision(collider: Collider): boolean;
  21667. /**
  21668. * Updates the submesh BoundingInfo
  21669. * @param world defines the world matrix to use to update the bounding info
  21670. * @returns the submesh
  21671. */
  21672. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21673. /**
  21674. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21675. * @param frustumPlanes defines the frustum planes
  21676. * @returns true if the submesh is intersecting with the frustum
  21677. */
  21678. isInFrustum(frustumPlanes: Plane[]): boolean;
  21679. /**
  21680. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21681. * @param frustumPlanes defines the frustum planes
  21682. * @returns true if the submesh is inside the frustum
  21683. */
  21684. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21685. /**
  21686. * Renders the submesh
  21687. * @param enableAlphaMode defines if alpha needs to be used
  21688. * @returns the submesh
  21689. */
  21690. render(enableAlphaMode: boolean): SubMesh;
  21691. /**
  21692. * @hidden
  21693. */
  21694. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21695. /**
  21696. * Checks if the submesh intersects with a ray
  21697. * @param ray defines the ray to test
  21698. * @returns true is the passed ray intersects the submesh bounding box
  21699. */
  21700. canIntersects(ray: Ray): boolean;
  21701. /**
  21702. * Intersects current submesh with a ray
  21703. * @param ray defines the ray to test
  21704. * @param positions defines mesh's positions array
  21705. * @param indices defines mesh's indices array
  21706. * @param fastCheck defines if only bounding info should be used
  21707. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21708. * @returns intersection info or null if no intersection
  21709. */
  21710. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21711. /** @hidden */
  21712. private _intersectLines;
  21713. /** @hidden */
  21714. private _intersectUnIndexedLines;
  21715. /** @hidden */
  21716. private _intersectTriangles;
  21717. /** @hidden */
  21718. private _intersectUnIndexedTriangles;
  21719. /** @hidden */
  21720. _rebuild(): void;
  21721. /**
  21722. * Creates a new submesh from the passed mesh
  21723. * @param newMesh defines the new hosting mesh
  21724. * @param newRenderingMesh defines an optional rendering mesh
  21725. * @returns the new submesh
  21726. */
  21727. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21728. /**
  21729. * Release associated resources
  21730. */
  21731. dispose(): void;
  21732. /**
  21733. * Gets the class name
  21734. * @returns the string "SubMesh".
  21735. */
  21736. getClassName(): string;
  21737. /**
  21738. * Creates a new submesh from indices data
  21739. * @param materialIndex the index of the main mesh material
  21740. * @param startIndex the index where to start the copy in the mesh indices array
  21741. * @param indexCount the number of indices to copy then from the startIndex
  21742. * @param mesh the main mesh to create the submesh from
  21743. * @param renderingMesh the optional rendering mesh
  21744. * @returns a new submesh
  21745. */
  21746. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21747. }
  21748. }
  21749. declare module BABYLON {
  21750. /**
  21751. * Class used to represent data loading progression
  21752. */
  21753. export class SceneLoaderFlags {
  21754. private static _ForceFullSceneLoadingForIncremental;
  21755. private static _ShowLoadingScreen;
  21756. private static _CleanBoneMatrixWeights;
  21757. private static _loggingLevel;
  21758. /**
  21759. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21760. */
  21761. static get ForceFullSceneLoadingForIncremental(): boolean;
  21762. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21763. /**
  21764. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21765. */
  21766. static get ShowLoadingScreen(): boolean;
  21767. static set ShowLoadingScreen(value: boolean);
  21768. /**
  21769. * Defines the current logging level (while loading the scene)
  21770. * @ignorenaming
  21771. */
  21772. static get loggingLevel(): number;
  21773. static set loggingLevel(value: number);
  21774. /**
  21775. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21776. */
  21777. static get CleanBoneMatrixWeights(): boolean;
  21778. static set CleanBoneMatrixWeights(value: boolean);
  21779. }
  21780. }
  21781. declare module BABYLON {
  21782. /**
  21783. * Class used to store geometry data (vertex buffers + index buffer)
  21784. */
  21785. export class Geometry implements IGetSetVerticesData {
  21786. /**
  21787. * Gets or sets the ID of the geometry
  21788. */
  21789. id: string;
  21790. /**
  21791. * Gets or sets the unique ID of the geometry
  21792. */
  21793. uniqueId: number;
  21794. /**
  21795. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21796. */
  21797. delayLoadState: number;
  21798. /**
  21799. * Gets the file containing the data to load when running in delay load state
  21800. */
  21801. delayLoadingFile: Nullable<string>;
  21802. /**
  21803. * Callback called when the geometry is updated
  21804. */
  21805. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21806. private _scene;
  21807. private _engine;
  21808. private _meshes;
  21809. private _totalVertices;
  21810. /** @hidden */
  21811. _indices: IndicesArray;
  21812. /** @hidden */
  21813. _vertexBuffers: {
  21814. [key: string]: VertexBuffer;
  21815. };
  21816. private _isDisposed;
  21817. private _extend;
  21818. private _boundingBias;
  21819. /** @hidden */
  21820. _delayInfo: Array<string>;
  21821. private _indexBuffer;
  21822. private _indexBufferIsUpdatable;
  21823. /** @hidden */
  21824. _boundingInfo: Nullable<BoundingInfo>;
  21825. /** @hidden */
  21826. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21827. /** @hidden */
  21828. _softwareSkinningFrameId: number;
  21829. private _vertexArrayObjects;
  21830. private _updatable;
  21831. /** @hidden */
  21832. _positions: Nullable<Vector3[]>;
  21833. /**
  21834. * 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
  21835. */
  21836. get boundingBias(): Vector2;
  21837. /**
  21838. * 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
  21839. */
  21840. set boundingBias(value: Vector2);
  21841. /**
  21842. * Static function used to attach a new empty geometry to a mesh
  21843. * @param mesh defines the mesh to attach the geometry to
  21844. * @returns the new Geometry
  21845. */
  21846. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21847. /**
  21848. * Creates a new geometry
  21849. * @param id defines the unique ID
  21850. * @param scene defines the hosting scene
  21851. * @param vertexData defines the VertexData used to get geometry data
  21852. * @param updatable defines if geometry must be updatable (false by default)
  21853. * @param mesh defines the mesh that will be associated with the geometry
  21854. */
  21855. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21856. /**
  21857. * Gets the current extend of the geometry
  21858. */
  21859. get extend(): {
  21860. minimum: Vector3;
  21861. maximum: Vector3;
  21862. };
  21863. /**
  21864. * Gets the hosting scene
  21865. * @returns the hosting Scene
  21866. */
  21867. getScene(): Scene;
  21868. /**
  21869. * Gets the hosting engine
  21870. * @returns the hosting Engine
  21871. */
  21872. getEngine(): Engine;
  21873. /**
  21874. * Defines if the geometry is ready to use
  21875. * @returns true if the geometry is ready to be used
  21876. */
  21877. isReady(): boolean;
  21878. /**
  21879. * Gets a value indicating that the geometry should not be serialized
  21880. */
  21881. get doNotSerialize(): boolean;
  21882. /** @hidden */
  21883. _rebuild(): void;
  21884. /**
  21885. * Affects all geometry data in one call
  21886. * @param vertexData defines the geometry data
  21887. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21888. */
  21889. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21890. /**
  21891. * Set specific vertex data
  21892. * @param kind defines the data kind (Position, normal, etc...)
  21893. * @param data defines the vertex data to use
  21894. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21895. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21896. */
  21897. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21898. /**
  21899. * Removes a specific vertex data
  21900. * @param kind defines the data kind (Position, normal, etc...)
  21901. */
  21902. removeVerticesData(kind: string): void;
  21903. /**
  21904. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21905. * @param buffer defines the vertex buffer to use
  21906. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21907. */
  21908. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21909. /**
  21910. * Update a specific vertex buffer
  21911. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21912. * It will do nothing if the buffer is not updatable
  21913. * @param kind defines the data kind (Position, normal, etc...)
  21914. * @param data defines the data to use
  21915. * @param offset defines the offset in the target buffer where to store the data
  21916. * @param useBytes set to true if the offset is in bytes
  21917. */
  21918. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21919. /**
  21920. * Update a specific vertex buffer
  21921. * This function will create a new buffer if the current one is not updatable
  21922. * @param kind defines the data kind (Position, normal, etc...)
  21923. * @param data defines the data to use
  21924. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21925. */
  21926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21927. private _updateBoundingInfo;
  21928. /** @hidden */
  21929. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21930. /**
  21931. * Gets total number of vertices
  21932. * @returns the total number of vertices
  21933. */
  21934. getTotalVertices(): number;
  21935. /**
  21936. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21937. * @param kind defines the data kind (Position, normal, etc...)
  21938. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21940. * @returns a float array containing vertex data
  21941. */
  21942. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21943. /**
  21944. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21945. * @param kind defines the data kind (Position, normal, etc...)
  21946. * @returns true if the vertex buffer with the specified kind is updatable
  21947. */
  21948. isVertexBufferUpdatable(kind: string): boolean;
  21949. /**
  21950. * Gets a specific vertex buffer
  21951. * @param kind defines the data kind (Position, normal, etc...)
  21952. * @returns a VertexBuffer
  21953. */
  21954. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21955. /**
  21956. * Returns all vertex buffers
  21957. * @return an object holding all vertex buffers indexed by kind
  21958. */
  21959. getVertexBuffers(): Nullable<{
  21960. [key: string]: VertexBuffer;
  21961. }>;
  21962. /**
  21963. * Gets a boolean indicating if specific vertex buffer is present
  21964. * @param kind defines the data kind (Position, normal, etc...)
  21965. * @returns true if data is present
  21966. */
  21967. isVerticesDataPresent(kind: string): boolean;
  21968. /**
  21969. * Gets a list of all attached data kinds (Position, normal, etc...)
  21970. * @returns a list of string containing all kinds
  21971. */
  21972. getVerticesDataKinds(): string[];
  21973. /**
  21974. * Update index buffer
  21975. * @param indices defines the indices to store in the index buffer
  21976. * @param offset defines the offset in the target buffer where to store the data
  21977. * @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)
  21978. */
  21979. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21980. /**
  21981. * Creates a new index buffer
  21982. * @param indices defines the indices to store in the index buffer
  21983. * @param totalVertices defines the total number of vertices (could be null)
  21984. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21985. */
  21986. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21987. /**
  21988. * Return the total number of indices
  21989. * @returns the total number of indices
  21990. */
  21991. getTotalIndices(): number;
  21992. /**
  21993. * Gets the index buffer array
  21994. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21995. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21996. * @returns the index buffer array
  21997. */
  21998. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21999. /**
  22000. * Gets the index buffer
  22001. * @return the index buffer
  22002. */
  22003. getIndexBuffer(): Nullable<DataBuffer>;
  22004. /** @hidden */
  22005. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22006. /**
  22007. * Release the associated resources for a specific mesh
  22008. * @param mesh defines the source mesh
  22009. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22010. */
  22011. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22012. /**
  22013. * Apply current geometry to a given mesh
  22014. * @param mesh defines the mesh to apply geometry to
  22015. */
  22016. applyToMesh(mesh: Mesh): void;
  22017. private _updateExtend;
  22018. private _applyToMesh;
  22019. private notifyUpdate;
  22020. /**
  22021. * Load the geometry if it was flagged as delay loaded
  22022. * @param scene defines the hosting scene
  22023. * @param onLoaded defines a callback called when the geometry is loaded
  22024. */
  22025. load(scene: Scene, onLoaded?: () => void): void;
  22026. private _queueLoad;
  22027. /**
  22028. * Invert the geometry to move from a right handed system to a left handed one.
  22029. */
  22030. toLeftHanded(): void;
  22031. /** @hidden */
  22032. _resetPointsArrayCache(): void;
  22033. /** @hidden */
  22034. _generatePointsArray(): boolean;
  22035. /**
  22036. * Gets a value indicating if the geometry is disposed
  22037. * @returns true if the geometry was disposed
  22038. */
  22039. isDisposed(): boolean;
  22040. private _disposeVertexArrayObjects;
  22041. /**
  22042. * Free all associated resources
  22043. */
  22044. dispose(): void;
  22045. /**
  22046. * Clone the current geometry into a new geometry
  22047. * @param id defines the unique ID of the new geometry
  22048. * @returns a new geometry object
  22049. */
  22050. copy(id: string): Geometry;
  22051. /**
  22052. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22053. * @return a JSON representation of the current geometry data (without the vertices data)
  22054. */
  22055. serialize(): any;
  22056. private toNumberArray;
  22057. /**
  22058. * Serialize all vertices data into a JSON oject
  22059. * @returns a JSON representation of the current geometry data
  22060. */
  22061. serializeVerticeData(): any;
  22062. /**
  22063. * Extracts a clone of a mesh geometry
  22064. * @param mesh defines the source mesh
  22065. * @param id defines the unique ID of the new geometry object
  22066. * @returns the new geometry object
  22067. */
  22068. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22069. /**
  22070. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22071. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22072. * Be aware Math.random() could cause collisions, but:
  22073. * "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"
  22074. * @returns a string containing a new GUID
  22075. */
  22076. static RandomId(): string;
  22077. /** @hidden */
  22078. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22079. private static _CleanMatricesWeights;
  22080. /**
  22081. * Create a new geometry from persisted data (Using .babylon file format)
  22082. * @param parsedVertexData defines the persisted data
  22083. * @param scene defines the hosting scene
  22084. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22085. * @returns the new geometry object
  22086. */
  22087. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22088. }
  22089. }
  22090. declare module BABYLON {
  22091. /**
  22092. * Define an interface for all classes that will get and set the data on vertices
  22093. */
  22094. export interface IGetSetVerticesData {
  22095. /**
  22096. * Gets a boolean indicating if specific vertex data is present
  22097. * @param kind defines the vertex data kind to use
  22098. * @returns true is data kind is present
  22099. */
  22100. isVerticesDataPresent(kind: string): boolean;
  22101. /**
  22102. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22103. * @param kind defines the data kind (Position, normal, etc...)
  22104. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22105. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22106. * @returns a float array containing vertex data
  22107. */
  22108. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22109. /**
  22110. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22111. * @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.
  22112. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22113. * @returns the indices array or an empty array if the mesh has no geometry
  22114. */
  22115. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22116. /**
  22117. * Set specific vertex data
  22118. * @param kind defines the data kind (Position, normal, etc...)
  22119. * @param data defines the vertex data to use
  22120. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22121. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22122. */
  22123. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22124. /**
  22125. * Update a specific associated vertex buffer
  22126. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22127. * - VertexBuffer.PositionKind
  22128. * - VertexBuffer.UVKind
  22129. * - VertexBuffer.UV2Kind
  22130. * - VertexBuffer.UV3Kind
  22131. * - VertexBuffer.UV4Kind
  22132. * - VertexBuffer.UV5Kind
  22133. * - VertexBuffer.UV6Kind
  22134. * - VertexBuffer.ColorKind
  22135. * - VertexBuffer.MatricesIndicesKind
  22136. * - VertexBuffer.MatricesIndicesExtraKind
  22137. * - VertexBuffer.MatricesWeightsKind
  22138. * - VertexBuffer.MatricesWeightsExtraKind
  22139. * @param data defines the data source
  22140. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22141. * @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)
  22142. */
  22143. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22144. /**
  22145. * Creates a new index buffer
  22146. * @param indices defines the indices to store in the index buffer
  22147. * @param totalVertices defines the total number of vertices (could be null)
  22148. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22149. */
  22150. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22151. }
  22152. /**
  22153. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22154. */
  22155. export class VertexData {
  22156. /**
  22157. * Mesh side orientation : usually the external or front surface
  22158. */
  22159. static readonly FRONTSIDE: number;
  22160. /**
  22161. * Mesh side orientation : usually the internal or back surface
  22162. */
  22163. static readonly BACKSIDE: number;
  22164. /**
  22165. * Mesh side orientation : both internal and external or front and back surfaces
  22166. */
  22167. static readonly DOUBLESIDE: number;
  22168. /**
  22169. * Mesh side orientation : by default, `FRONTSIDE`
  22170. */
  22171. static readonly DEFAULTSIDE: number;
  22172. /**
  22173. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22174. */
  22175. positions: Nullable<FloatArray>;
  22176. /**
  22177. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22178. */
  22179. normals: Nullable<FloatArray>;
  22180. /**
  22181. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22182. */
  22183. tangents: Nullable<FloatArray>;
  22184. /**
  22185. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22186. */
  22187. uvs: Nullable<FloatArray>;
  22188. /**
  22189. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22190. */
  22191. uvs2: Nullable<FloatArray>;
  22192. /**
  22193. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22194. */
  22195. uvs3: Nullable<FloatArray>;
  22196. /**
  22197. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22198. */
  22199. uvs4: Nullable<FloatArray>;
  22200. /**
  22201. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22202. */
  22203. uvs5: Nullable<FloatArray>;
  22204. /**
  22205. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22206. */
  22207. uvs6: Nullable<FloatArray>;
  22208. /**
  22209. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22210. */
  22211. colors: Nullable<FloatArray>;
  22212. /**
  22213. * 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).
  22214. */
  22215. matricesIndices: Nullable<FloatArray>;
  22216. /**
  22217. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22218. */
  22219. matricesWeights: Nullable<FloatArray>;
  22220. /**
  22221. * An array extending the number of possible indices
  22222. */
  22223. matricesIndicesExtra: Nullable<FloatArray>;
  22224. /**
  22225. * An array extending the number of possible weights when the number of indices is extended
  22226. */
  22227. matricesWeightsExtra: Nullable<FloatArray>;
  22228. /**
  22229. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22230. */
  22231. indices: Nullable<IndicesArray>;
  22232. /**
  22233. * Uses the passed data array to set the set the values for the specified kind of data
  22234. * @param data a linear array of floating numbers
  22235. * @param kind the type of data that is being set, eg positions, colors etc
  22236. */
  22237. set(data: FloatArray, kind: string): void;
  22238. /**
  22239. * Associates the vertexData to the passed Mesh.
  22240. * Sets it as updatable or not (default `false`)
  22241. * @param mesh the mesh the vertexData is applied to
  22242. * @param updatable when used and having the value true allows new data to update the vertexData
  22243. * @returns the VertexData
  22244. */
  22245. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22246. /**
  22247. * Associates the vertexData to the passed Geometry.
  22248. * Sets it as updatable or not (default `false`)
  22249. * @param geometry the geometry the vertexData is applied to
  22250. * @param updatable when used and having the value true allows new data to update the vertexData
  22251. * @returns VertexData
  22252. */
  22253. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22254. /**
  22255. * Updates the associated mesh
  22256. * @param mesh the mesh to be updated
  22257. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22258. * @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
  22259. * @returns VertexData
  22260. */
  22261. updateMesh(mesh: Mesh): VertexData;
  22262. /**
  22263. * Updates the associated geometry
  22264. * @param geometry the geometry to be updated
  22265. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22266. * @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
  22267. * @returns VertexData.
  22268. */
  22269. updateGeometry(geometry: Geometry): VertexData;
  22270. private _applyTo;
  22271. private _update;
  22272. /**
  22273. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22274. * @param matrix the transforming matrix
  22275. * @returns the VertexData
  22276. */
  22277. transform(matrix: Matrix): VertexData;
  22278. /**
  22279. * Merges the passed VertexData into the current one
  22280. * @param other the VertexData to be merged into the current one
  22281. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22282. * @returns the modified VertexData
  22283. */
  22284. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22285. private _mergeElement;
  22286. private _validate;
  22287. /**
  22288. * Serializes the VertexData
  22289. * @returns a serialized object
  22290. */
  22291. serialize(): any;
  22292. /**
  22293. * Extracts the vertexData from a mesh
  22294. * @param mesh the mesh from which to extract the VertexData
  22295. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22296. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22297. * @returns the object VertexData associated to the passed mesh
  22298. */
  22299. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22300. /**
  22301. * Extracts the vertexData from the geometry
  22302. * @param geometry the geometry from which to extract the VertexData
  22303. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22304. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22305. * @returns the object VertexData associated to the passed mesh
  22306. */
  22307. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22308. private static _ExtractFrom;
  22309. /**
  22310. * Creates the VertexData for a Ribbon
  22311. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22312. * * pathArray array of paths, each of which an array of successive Vector3
  22313. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22314. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22315. * * 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
  22316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22317. * * 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)
  22318. * * 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)
  22319. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22320. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22321. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22322. * @returns the VertexData of the ribbon
  22323. */
  22324. static CreateRibbon(options: {
  22325. pathArray: Vector3[][];
  22326. closeArray?: boolean;
  22327. closePath?: boolean;
  22328. offset?: number;
  22329. sideOrientation?: number;
  22330. frontUVs?: Vector4;
  22331. backUVs?: Vector4;
  22332. invertUV?: boolean;
  22333. uvs?: Vector2[];
  22334. colors?: Color4[];
  22335. }): VertexData;
  22336. /**
  22337. * Creates the VertexData for a box
  22338. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22339. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22340. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22341. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22342. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22343. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22344. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22346. * * 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)
  22347. * * 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)
  22348. * @returns the VertexData of the box
  22349. */
  22350. static CreateBox(options: {
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. depth?: number;
  22355. faceUV?: Vector4[];
  22356. faceColors?: Color4[];
  22357. sideOrientation?: number;
  22358. frontUVs?: Vector4;
  22359. backUVs?: Vector4;
  22360. }): VertexData;
  22361. /**
  22362. * Creates the VertexData for a tiled box
  22363. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22364. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22365. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22366. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22368. * @returns the VertexData of the box
  22369. */
  22370. static CreateTiledBox(options: {
  22371. pattern?: number;
  22372. width?: number;
  22373. height?: number;
  22374. depth?: number;
  22375. tileSize?: number;
  22376. tileWidth?: number;
  22377. tileHeight?: number;
  22378. alignHorizontal?: number;
  22379. alignVertical?: number;
  22380. faceUV?: Vector4[];
  22381. faceColors?: Color4[];
  22382. sideOrientation?: number;
  22383. }): VertexData;
  22384. /**
  22385. * Creates the VertexData for a tiled plane
  22386. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22387. * * pattern a limited pattern arrangement depending on the number
  22388. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22389. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22390. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22391. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22392. * * 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)
  22393. * * 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)
  22394. * @returns the VertexData of the tiled plane
  22395. */
  22396. static CreateTiledPlane(options: {
  22397. pattern?: number;
  22398. tileSize?: number;
  22399. tileWidth?: number;
  22400. tileHeight?: number;
  22401. size?: number;
  22402. width?: number;
  22403. height?: number;
  22404. alignHorizontal?: number;
  22405. alignVertical?: number;
  22406. sideOrientation?: number;
  22407. frontUVs?: Vector4;
  22408. backUVs?: Vector4;
  22409. }): VertexData;
  22410. /**
  22411. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22412. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22413. * * segments sets the number of horizontal strips optional, default 32
  22414. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22415. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22416. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22417. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22418. * * 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
  22419. * * 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
  22420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22421. * * 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)
  22422. * * 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)
  22423. * @returns the VertexData of the ellipsoid
  22424. */
  22425. static CreateSphere(options: {
  22426. segments?: number;
  22427. diameter?: number;
  22428. diameterX?: number;
  22429. diameterY?: number;
  22430. diameterZ?: number;
  22431. arc?: number;
  22432. slice?: number;
  22433. sideOrientation?: number;
  22434. frontUVs?: Vector4;
  22435. backUVs?: Vector4;
  22436. }): VertexData;
  22437. /**
  22438. * Creates the VertexData for a cylinder, cone or prism
  22439. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22440. * * height sets the height (y direction) of the cylinder, optional, default 2
  22441. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22442. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22443. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22444. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22445. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22446. * * 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
  22447. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22448. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22449. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22450. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22452. * * 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)
  22453. * * 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)
  22454. * @returns the VertexData of the cylinder, cone or prism
  22455. */
  22456. static CreateCylinder(options: {
  22457. height?: number;
  22458. diameterTop?: number;
  22459. diameterBottom?: number;
  22460. diameter?: number;
  22461. tessellation?: number;
  22462. subdivisions?: number;
  22463. arc?: number;
  22464. faceColors?: Color4[];
  22465. faceUV?: Vector4[];
  22466. hasRings?: boolean;
  22467. enclose?: boolean;
  22468. sideOrientation?: number;
  22469. frontUVs?: Vector4;
  22470. backUVs?: Vector4;
  22471. }): VertexData;
  22472. /**
  22473. * Creates the VertexData for a torus
  22474. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22475. * * diameter the diameter of the torus, optional default 1
  22476. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22477. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22478. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22479. * * 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)
  22480. * * 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)
  22481. * @returns the VertexData of the torus
  22482. */
  22483. static CreateTorus(options: {
  22484. diameter?: number;
  22485. thickness?: number;
  22486. tessellation?: number;
  22487. sideOrientation?: number;
  22488. frontUVs?: Vector4;
  22489. backUVs?: Vector4;
  22490. }): VertexData;
  22491. /**
  22492. * Creates the VertexData of the LineSystem
  22493. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22494. * - lines an array of lines, each line being an array of successive Vector3
  22495. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22496. * @returns the VertexData of the LineSystem
  22497. */
  22498. static CreateLineSystem(options: {
  22499. lines: Vector3[][];
  22500. colors?: Nullable<Color4[][]>;
  22501. }): VertexData;
  22502. /**
  22503. * Create the VertexData for a DashedLines
  22504. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22505. * - points an array successive Vector3
  22506. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22507. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22508. * - dashNb the intended total number of dashes, optional, default 200
  22509. * @returns the VertexData for the DashedLines
  22510. */
  22511. static CreateDashedLines(options: {
  22512. points: Vector3[];
  22513. dashSize?: number;
  22514. gapSize?: number;
  22515. dashNb?: number;
  22516. }): VertexData;
  22517. /**
  22518. * Creates the VertexData for a Ground
  22519. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22520. * - width the width (x direction) of the ground, optional, default 1
  22521. * - height the height (z direction) of the ground, optional, default 1
  22522. * - subdivisions the number of subdivisions per side, optional, default 1
  22523. * @returns the VertexData of the Ground
  22524. */
  22525. static CreateGround(options: {
  22526. width?: number;
  22527. height?: number;
  22528. subdivisions?: number;
  22529. subdivisionsX?: number;
  22530. subdivisionsY?: number;
  22531. }): VertexData;
  22532. /**
  22533. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22534. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22535. * * xmin the ground minimum X coordinate, optional, default -1
  22536. * * zmin the ground minimum Z coordinate, optional, default -1
  22537. * * xmax the ground maximum X coordinate, optional, default 1
  22538. * * zmax the ground maximum Z coordinate, optional, default 1
  22539. * * 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}
  22540. * * 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}
  22541. * @returns the VertexData of the TiledGround
  22542. */
  22543. static CreateTiledGround(options: {
  22544. xmin: number;
  22545. zmin: number;
  22546. xmax: number;
  22547. zmax: number;
  22548. subdivisions?: {
  22549. w: number;
  22550. h: number;
  22551. };
  22552. precision?: {
  22553. w: number;
  22554. h: number;
  22555. };
  22556. }): VertexData;
  22557. /**
  22558. * Creates the VertexData of the Ground designed from a heightmap
  22559. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22560. * * width the width (x direction) of the ground
  22561. * * height the height (z direction) of the ground
  22562. * * subdivisions the number of subdivisions per side
  22563. * * minHeight the minimum altitude on the ground, optional, default 0
  22564. * * maxHeight the maximum altitude on the ground, optional default 1
  22565. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22566. * * buffer the array holding the image color data
  22567. * * bufferWidth the width of image
  22568. * * bufferHeight the height of image
  22569. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22570. * @returns the VertexData of the Ground designed from a heightmap
  22571. */
  22572. static CreateGroundFromHeightMap(options: {
  22573. width: number;
  22574. height: number;
  22575. subdivisions: number;
  22576. minHeight: number;
  22577. maxHeight: number;
  22578. colorFilter: Color3;
  22579. buffer: Uint8Array;
  22580. bufferWidth: number;
  22581. bufferHeight: number;
  22582. alphaFilter: number;
  22583. }): VertexData;
  22584. /**
  22585. * Creates the VertexData for a Plane
  22586. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22587. * * size sets the width and height of the plane to the value of size, optional default 1
  22588. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22589. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22590. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22591. * * 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)
  22592. * * 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)
  22593. * @returns the VertexData of the box
  22594. */
  22595. static CreatePlane(options: {
  22596. size?: number;
  22597. width?: number;
  22598. height?: number;
  22599. sideOrientation?: number;
  22600. frontUVs?: Vector4;
  22601. backUVs?: Vector4;
  22602. }): VertexData;
  22603. /**
  22604. * Creates the VertexData of the Disc or regular Polygon
  22605. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22606. * * radius the radius of the disc, optional default 0.5
  22607. * * tessellation the number of polygon sides, optional, default 64
  22608. * * 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
  22609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22610. * * 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)
  22611. * * 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)
  22612. * @returns the VertexData of the box
  22613. */
  22614. static CreateDisc(options: {
  22615. radius?: number;
  22616. tessellation?: number;
  22617. arc?: number;
  22618. sideOrientation?: number;
  22619. frontUVs?: Vector4;
  22620. backUVs?: Vector4;
  22621. }): VertexData;
  22622. /**
  22623. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22624. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22625. * @param polygon a mesh built from polygonTriangulation.build()
  22626. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22627. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22628. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22629. * @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)
  22630. * @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)
  22631. * @returns the VertexData of the Polygon
  22632. */
  22633. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22634. /**
  22635. * Creates the VertexData of the IcoSphere
  22636. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22637. * * radius the radius of the IcoSphere, optional default 1
  22638. * * radiusX allows stretching in the x direction, optional, default radius
  22639. * * radiusY allows stretching in the y direction, optional, default radius
  22640. * * radiusZ allows stretching in the z direction, optional, default radius
  22641. * * flat when true creates a flat shaded mesh, optional, default true
  22642. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22644. * * 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)
  22645. * * 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)
  22646. * @returns the VertexData of the IcoSphere
  22647. */
  22648. static CreateIcoSphere(options: {
  22649. radius?: number;
  22650. radiusX?: number;
  22651. radiusY?: number;
  22652. radiusZ?: number;
  22653. flat?: boolean;
  22654. subdivisions?: number;
  22655. sideOrientation?: number;
  22656. frontUVs?: Vector4;
  22657. backUVs?: Vector4;
  22658. }): VertexData;
  22659. /**
  22660. * Creates the VertexData for a Polyhedron
  22661. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22662. * * type provided types are:
  22663. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22664. * * 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)
  22665. * * size the size of the IcoSphere, optional default 1
  22666. * * sizeX allows stretching in the x direction, optional, default size
  22667. * * sizeY allows stretching in the y direction, optional, default size
  22668. * * sizeZ allows stretching in the z direction, optional, default size
  22669. * * 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
  22670. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22671. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22672. * * flat when true creates a flat shaded mesh, optional, default true
  22673. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22675. * * 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)
  22676. * * 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)
  22677. * @returns the VertexData of the Polyhedron
  22678. */
  22679. static CreatePolyhedron(options: {
  22680. type?: number;
  22681. size?: number;
  22682. sizeX?: number;
  22683. sizeY?: number;
  22684. sizeZ?: number;
  22685. custom?: any;
  22686. faceUV?: Vector4[];
  22687. faceColors?: Color4[];
  22688. flat?: boolean;
  22689. sideOrientation?: number;
  22690. frontUVs?: Vector4;
  22691. backUVs?: Vector4;
  22692. }): VertexData;
  22693. /**
  22694. * Creates the VertexData for a TorusKnot
  22695. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22696. * * radius the radius of the torus knot, optional, default 2
  22697. * * tube the thickness of the tube, optional, default 0.5
  22698. * * radialSegments the number of sides on each tube segments, optional, default 32
  22699. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22700. * * p the number of windings around the z axis, optional, default 2
  22701. * * q the number of windings around the x axis, optional, default 3
  22702. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22703. * * 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)
  22704. * * 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)
  22705. * @returns the VertexData of the Torus Knot
  22706. */
  22707. static CreateTorusKnot(options: {
  22708. radius?: number;
  22709. tube?: number;
  22710. radialSegments?: number;
  22711. tubularSegments?: number;
  22712. p?: number;
  22713. q?: number;
  22714. sideOrientation?: number;
  22715. frontUVs?: Vector4;
  22716. backUVs?: Vector4;
  22717. }): VertexData;
  22718. /**
  22719. * Compute normals for given positions and indices
  22720. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22721. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22722. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22723. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22724. * * facetNormals : optional array of facet normals (vector3)
  22725. * * facetPositions : optional array of facet positions (vector3)
  22726. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22727. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22728. * * bInfo : optional bounding info, required for facetPartitioning computation
  22729. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22730. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22731. * * useRightHandedSystem: optional boolean to for right handed system computation
  22732. * * depthSort : optional boolean to enable the facet depth sort computation
  22733. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22734. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22735. */
  22736. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22737. facetNormals?: any;
  22738. facetPositions?: any;
  22739. facetPartitioning?: any;
  22740. ratio?: number;
  22741. bInfo?: any;
  22742. bbSize?: Vector3;
  22743. subDiv?: any;
  22744. useRightHandedSystem?: boolean;
  22745. depthSort?: boolean;
  22746. distanceTo?: Vector3;
  22747. depthSortedFacets?: any;
  22748. }): void;
  22749. /** @hidden */
  22750. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22751. /**
  22752. * Applies VertexData created from the imported parameters to the geometry
  22753. * @param parsedVertexData the parsed data from an imported file
  22754. * @param geometry the geometry to apply the VertexData to
  22755. */
  22756. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22757. }
  22758. }
  22759. declare module BABYLON {
  22760. /**
  22761. * Defines a target to use with MorphTargetManager
  22762. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22763. */
  22764. export class MorphTarget implements IAnimatable {
  22765. /** defines the name of the target */
  22766. name: string;
  22767. /**
  22768. * Gets or sets the list of animations
  22769. */
  22770. animations: Animation[];
  22771. private _scene;
  22772. private _positions;
  22773. private _normals;
  22774. private _tangents;
  22775. private _uvs;
  22776. private _influence;
  22777. private _uniqueId;
  22778. /**
  22779. * Observable raised when the influence changes
  22780. */
  22781. onInfluenceChanged: Observable<boolean>;
  22782. /** @hidden */
  22783. _onDataLayoutChanged: Observable<void>;
  22784. /**
  22785. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22786. */
  22787. get influence(): number;
  22788. set influence(influence: number);
  22789. /**
  22790. * Gets or sets the id of the morph Target
  22791. */
  22792. id: string;
  22793. private _animationPropertiesOverride;
  22794. /**
  22795. * Gets or sets the animation properties override
  22796. */
  22797. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22798. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22799. /**
  22800. * Creates a new MorphTarget
  22801. * @param name defines the name of the target
  22802. * @param influence defines the influence to use
  22803. * @param scene defines the scene the morphtarget belongs to
  22804. */
  22805. constructor(
  22806. /** defines the name of the target */
  22807. name: string, influence?: number, scene?: Nullable<Scene>);
  22808. /**
  22809. * Gets the unique ID of this manager
  22810. */
  22811. get uniqueId(): number;
  22812. /**
  22813. * Gets a boolean defining if the target contains position data
  22814. */
  22815. get hasPositions(): boolean;
  22816. /**
  22817. * Gets a boolean defining if the target contains normal data
  22818. */
  22819. get hasNormals(): boolean;
  22820. /**
  22821. * Gets a boolean defining if the target contains tangent data
  22822. */
  22823. get hasTangents(): boolean;
  22824. /**
  22825. * Gets a boolean defining if the target contains texture coordinates data
  22826. */
  22827. get hasUVs(): boolean;
  22828. /**
  22829. * Affects position data to this target
  22830. * @param data defines the position data to use
  22831. */
  22832. setPositions(data: Nullable<FloatArray>): void;
  22833. /**
  22834. * Gets the position data stored in this target
  22835. * @returns a FloatArray containing the position data (or null if not present)
  22836. */
  22837. getPositions(): Nullable<FloatArray>;
  22838. /**
  22839. * Affects normal data to this target
  22840. * @param data defines the normal data to use
  22841. */
  22842. setNormals(data: Nullable<FloatArray>): void;
  22843. /**
  22844. * Gets the normal data stored in this target
  22845. * @returns a FloatArray containing the normal data (or null if not present)
  22846. */
  22847. getNormals(): Nullable<FloatArray>;
  22848. /**
  22849. * Affects tangent data to this target
  22850. * @param data defines the tangent data to use
  22851. */
  22852. setTangents(data: Nullable<FloatArray>): void;
  22853. /**
  22854. * Gets the tangent data stored in this target
  22855. * @returns a FloatArray containing the tangent data (or null if not present)
  22856. */
  22857. getTangents(): Nullable<FloatArray>;
  22858. /**
  22859. * Affects texture coordinates data to this target
  22860. * @param data defines the texture coordinates data to use
  22861. */
  22862. setUVs(data: Nullable<FloatArray>): void;
  22863. /**
  22864. * Gets the texture coordinates data stored in this target
  22865. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22866. */
  22867. getUVs(): Nullable<FloatArray>;
  22868. /**
  22869. * Clone the current target
  22870. * @returns a new MorphTarget
  22871. */
  22872. clone(): MorphTarget;
  22873. /**
  22874. * Serializes the current target into a Serialization object
  22875. * @returns the serialized object
  22876. */
  22877. serialize(): any;
  22878. /**
  22879. * Returns the string "MorphTarget"
  22880. * @returns "MorphTarget"
  22881. */
  22882. getClassName(): string;
  22883. /**
  22884. * Creates a new target from serialized data
  22885. * @param serializationObject defines the serialized data to use
  22886. * @returns a new MorphTarget
  22887. */
  22888. static Parse(serializationObject: any): MorphTarget;
  22889. /**
  22890. * Creates a MorphTarget from mesh data
  22891. * @param mesh defines the source mesh
  22892. * @param name defines the name to use for the new target
  22893. * @param influence defines the influence to attach to the target
  22894. * @returns a new MorphTarget
  22895. */
  22896. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22897. }
  22898. }
  22899. declare module BABYLON {
  22900. /**
  22901. * This class is used to deform meshes using morphing between different targets
  22902. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22903. */
  22904. export class MorphTargetManager {
  22905. private _targets;
  22906. private _targetInfluenceChangedObservers;
  22907. private _targetDataLayoutChangedObservers;
  22908. private _activeTargets;
  22909. private _scene;
  22910. private _influences;
  22911. private _supportsNormals;
  22912. private _supportsTangents;
  22913. private _supportsUVs;
  22914. private _vertexCount;
  22915. private _uniqueId;
  22916. private _tempInfluences;
  22917. /**
  22918. * Gets or sets a boolean indicating if normals must be morphed
  22919. */
  22920. enableNormalMorphing: boolean;
  22921. /**
  22922. * Gets or sets a boolean indicating if tangents must be morphed
  22923. */
  22924. enableTangentMorphing: boolean;
  22925. /**
  22926. * Gets or sets a boolean indicating if UV must be morphed
  22927. */
  22928. enableUVMorphing: boolean;
  22929. /**
  22930. * Creates a new MorphTargetManager
  22931. * @param scene defines the current scene
  22932. */
  22933. constructor(scene?: Nullable<Scene>);
  22934. /**
  22935. * Gets the unique ID of this manager
  22936. */
  22937. get uniqueId(): number;
  22938. /**
  22939. * Gets the number of vertices handled by this manager
  22940. */
  22941. get vertexCount(): number;
  22942. /**
  22943. * Gets a boolean indicating if this manager supports morphing of normals
  22944. */
  22945. get supportsNormals(): boolean;
  22946. /**
  22947. * Gets a boolean indicating if this manager supports morphing of tangents
  22948. */
  22949. get supportsTangents(): boolean;
  22950. /**
  22951. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22952. */
  22953. get supportsUVs(): boolean;
  22954. /**
  22955. * Gets the number of targets stored in this manager
  22956. */
  22957. get numTargets(): number;
  22958. /**
  22959. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22960. */
  22961. get numInfluencers(): number;
  22962. /**
  22963. * Gets the list of influences (one per target)
  22964. */
  22965. get influences(): Float32Array;
  22966. /**
  22967. * Gets the active target at specified index. An active target is a target with an influence > 0
  22968. * @param index defines the index to check
  22969. * @returns the requested target
  22970. */
  22971. getActiveTarget(index: number): MorphTarget;
  22972. /**
  22973. * Gets the target at specified index
  22974. * @param index defines the index to check
  22975. * @returns the requested target
  22976. */
  22977. getTarget(index: number): MorphTarget;
  22978. /**
  22979. * Add a new target to this manager
  22980. * @param target defines the target to add
  22981. */
  22982. addTarget(target: MorphTarget): void;
  22983. /**
  22984. * Removes a target from the manager
  22985. * @param target defines the target to remove
  22986. */
  22987. removeTarget(target: MorphTarget): void;
  22988. /**
  22989. * Clone the current manager
  22990. * @returns a new MorphTargetManager
  22991. */
  22992. clone(): MorphTargetManager;
  22993. /**
  22994. * Serializes the current manager into a Serialization object
  22995. * @returns the serialized object
  22996. */
  22997. serialize(): any;
  22998. private _syncActiveTargets;
  22999. /**
  23000. * Syncrhonize the targets with all the meshes using this morph target manager
  23001. */
  23002. synchronize(): void;
  23003. /**
  23004. * Creates a new MorphTargetManager from serialized data
  23005. * @param serializationObject defines the serialized data
  23006. * @param scene defines the hosting scene
  23007. * @returns the new MorphTargetManager
  23008. */
  23009. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23010. }
  23011. }
  23012. declare module BABYLON {
  23013. /**
  23014. * Class used to represent a specific level of detail of a mesh
  23015. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23016. */
  23017. export class MeshLODLevel {
  23018. /** Defines the distance where this level should start being displayed */
  23019. distance: number;
  23020. /** Defines the mesh to use to render this level */
  23021. mesh: Nullable<Mesh>;
  23022. /**
  23023. * Creates a new LOD level
  23024. * @param distance defines the distance where this level should star being displayed
  23025. * @param mesh defines the mesh to use to render this level
  23026. */
  23027. constructor(
  23028. /** Defines the distance where this level should start being displayed */
  23029. distance: number,
  23030. /** Defines the mesh to use to render this level */
  23031. mesh: Nullable<Mesh>);
  23032. }
  23033. }
  23034. declare module BABYLON {
  23035. /**
  23036. * Mesh representing the gorund
  23037. */
  23038. export class GroundMesh extends Mesh {
  23039. /** If octree should be generated */
  23040. generateOctree: boolean;
  23041. private _heightQuads;
  23042. /** @hidden */
  23043. _subdivisionsX: number;
  23044. /** @hidden */
  23045. _subdivisionsY: number;
  23046. /** @hidden */
  23047. _width: number;
  23048. /** @hidden */
  23049. _height: number;
  23050. /** @hidden */
  23051. _minX: number;
  23052. /** @hidden */
  23053. _maxX: number;
  23054. /** @hidden */
  23055. _minZ: number;
  23056. /** @hidden */
  23057. _maxZ: number;
  23058. constructor(name: string, scene: Scene);
  23059. /**
  23060. * "GroundMesh"
  23061. * @returns "GroundMesh"
  23062. */
  23063. getClassName(): string;
  23064. /**
  23065. * The minimum of x and y subdivisions
  23066. */
  23067. get subdivisions(): number;
  23068. /**
  23069. * X subdivisions
  23070. */
  23071. get subdivisionsX(): number;
  23072. /**
  23073. * Y subdivisions
  23074. */
  23075. get subdivisionsY(): number;
  23076. /**
  23077. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23078. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23079. * @param chunksCount the number of subdivisions for x and y
  23080. * @param octreeBlocksSize (Default: 32)
  23081. */
  23082. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23083. /**
  23084. * Returns a height (y) value in the Worl system :
  23085. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23086. * @param x x coordinate
  23087. * @param z z coordinate
  23088. * @returns the ground y position if (x, z) are outside the ground surface.
  23089. */
  23090. getHeightAtCoordinates(x: number, z: number): number;
  23091. /**
  23092. * Returns a normalized vector (Vector3) orthogonal to the ground
  23093. * at the ground coordinates (x, z) expressed in the World system.
  23094. * @param x x coordinate
  23095. * @param z z coordinate
  23096. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23097. */
  23098. getNormalAtCoordinates(x: number, z: number): Vector3;
  23099. /**
  23100. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23101. * at the ground coordinates (x, z) expressed in the World system.
  23102. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23103. * @param x x coordinate
  23104. * @param z z coordinate
  23105. * @param ref vector to store the result
  23106. * @returns the GroundMesh.
  23107. */
  23108. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23109. /**
  23110. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23111. * if the ground has been updated.
  23112. * This can be used in the render loop.
  23113. * @returns the GroundMesh.
  23114. */
  23115. updateCoordinateHeights(): GroundMesh;
  23116. private _getFacetAt;
  23117. private _initHeightQuads;
  23118. private _computeHeightQuads;
  23119. /**
  23120. * Serializes this ground mesh
  23121. * @param serializationObject object to write serialization to
  23122. */
  23123. serialize(serializationObject: any): void;
  23124. /**
  23125. * Parses a serialized ground mesh
  23126. * @param parsedMesh the serialized mesh
  23127. * @param scene the scene to create the ground mesh in
  23128. * @returns the created ground mesh
  23129. */
  23130. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23131. }
  23132. }
  23133. declare module BABYLON {
  23134. /**
  23135. * Interface for Physics-Joint data
  23136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23137. */
  23138. export interface PhysicsJointData {
  23139. /**
  23140. * The main pivot of the joint
  23141. */
  23142. mainPivot?: Vector3;
  23143. /**
  23144. * The connected pivot of the joint
  23145. */
  23146. connectedPivot?: Vector3;
  23147. /**
  23148. * The main axis of the joint
  23149. */
  23150. mainAxis?: Vector3;
  23151. /**
  23152. * The connected axis of the joint
  23153. */
  23154. connectedAxis?: Vector3;
  23155. /**
  23156. * The collision of the joint
  23157. */
  23158. collision?: boolean;
  23159. /**
  23160. * Native Oimo/Cannon/Energy data
  23161. */
  23162. nativeParams?: any;
  23163. }
  23164. /**
  23165. * This is a holder class for the physics joint created by the physics plugin
  23166. * It holds a set of functions to control the underlying joint
  23167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23168. */
  23169. export class PhysicsJoint {
  23170. /**
  23171. * The type of the physics joint
  23172. */
  23173. type: number;
  23174. /**
  23175. * The data for the physics joint
  23176. */
  23177. jointData: PhysicsJointData;
  23178. private _physicsJoint;
  23179. protected _physicsPlugin: IPhysicsEnginePlugin;
  23180. /**
  23181. * Initializes the physics joint
  23182. * @param type The type of the physics joint
  23183. * @param jointData The data for the physics joint
  23184. */
  23185. constructor(
  23186. /**
  23187. * The type of the physics joint
  23188. */
  23189. type: number,
  23190. /**
  23191. * The data for the physics joint
  23192. */
  23193. jointData: PhysicsJointData);
  23194. /**
  23195. * Gets the physics joint
  23196. */
  23197. get physicsJoint(): any;
  23198. /**
  23199. * Sets the physics joint
  23200. */
  23201. set physicsJoint(newJoint: any);
  23202. /**
  23203. * Sets the physics plugin
  23204. */
  23205. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23206. /**
  23207. * Execute a function that is physics-plugin specific.
  23208. * @param {Function} func the function that will be executed.
  23209. * It accepts two parameters: the physics world and the physics joint
  23210. */
  23211. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23212. /**
  23213. * Distance-Joint type
  23214. */
  23215. static DistanceJoint: number;
  23216. /**
  23217. * Hinge-Joint type
  23218. */
  23219. static HingeJoint: number;
  23220. /**
  23221. * Ball-and-Socket joint type
  23222. */
  23223. static BallAndSocketJoint: number;
  23224. /**
  23225. * Wheel-Joint type
  23226. */
  23227. static WheelJoint: number;
  23228. /**
  23229. * Slider-Joint type
  23230. */
  23231. static SliderJoint: number;
  23232. /**
  23233. * Prismatic-Joint type
  23234. */
  23235. static PrismaticJoint: number;
  23236. /**
  23237. * Universal-Joint type
  23238. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23239. */
  23240. static UniversalJoint: number;
  23241. /**
  23242. * Hinge-Joint 2 type
  23243. */
  23244. static Hinge2Joint: number;
  23245. /**
  23246. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23247. */
  23248. static PointToPointJoint: number;
  23249. /**
  23250. * Spring-Joint type
  23251. */
  23252. static SpringJoint: number;
  23253. /**
  23254. * Lock-Joint type
  23255. */
  23256. static LockJoint: number;
  23257. }
  23258. /**
  23259. * A class representing a physics distance joint
  23260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23261. */
  23262. export class DistanceJoint extends PhysicsJoint {
  23263. /**
  23264. *
  23265. * @param jointData The data for the Distance-Joint
  23266. */
  23267. constructor(jointData: DistanceJointData);
  23268. /**
  23269. * Update the predefined distance.
  23270. * @param maxDistance The maximum preferred distance
  23271. * @param minDistance The minimum preferred distance
  23272. */
  23273. updateDistance(maxDistance: number, minDistance?: number): void;
  23274. }
  23275. /**
  23276. * Represents a Motor-Enabled Joint
  23277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23278. */
  23279. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23280. /**
  23281. * Initializes the Motor-Enabled Joint
  23282. * @param type The type of the joint
  23283. * @param jointData The physica joint data for the joint
  23284. */
  23285. constructor(type: number, jointData: PhysicsJointData);
  23286. /**
  23287. * Set the motor values.
  23288. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23289. * @param force the force to apply
  23290. * @param maxForce max force for this motor.
  23291. */
  23292. setMotor(force?: number, maxForce?: number): void;
  23293. /**
  23294. * Set the motor's limits.
  23295. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23296. * @param upperLimit The upper limit of the motor
  23297. * @param lowerLimit The lower limit of the motor
  23298. */
  23299. setLimit(upperLimit: number, lowerLimit?: number): void;
  23300. }
  23301. /**
  23302. * This class represents a single physics Hinge-Joint
  23303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23304. */
  23305. export class HingeJoint extends MotorEnabledJoint {
  23306. /**
  23307. * Initializes the Hinge-Joint
  23308. * @param jointData The joint data for the Hinge-Joint
  23309. */
  23310. constructor(jointData: PhysicsJointData);
  23311. /**
  23312. * Set the motor values.
  23313. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23314. * @param {number} force the force to apply
  23315. * @param {number} maxForce max force for this motor.
  23316. */
  23317. setMotor(force?: number, maxForce?: number): void;
  23318. /**
  23319. * Set the motor's limits.
  23320. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23321. * @param upperLimit The upper limit of the motor
  23322. * @param lowerLimit The lower limit of the motor
  23323. */
  23324. setLimit(upperLimit: number, lowerLimit?: number): void;
  23325. }
  23326. /**
  23327. * This class represents a dual hinge physics joint (same as wheel joint)
  23328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23329. */
  23330. export class Hinge2Joint extends MotorEnabledJoint {
  23331. /**
  23332. * Initializes the Hinge2-Joint
  23333. * @param jointData The joint data for the Hinge2-Joint
  23334. */
  23335. constructor(jointData: PhysicsJointData);
  23336. /**
  23337. * Set the motor values.
  23338. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23339. * @param {number} targetSpeed the speed the motor is to reach
  23340. * @param {number} maxForce max force for this motor.
  23341. * @param {motorIndex} the motor's index, 0 or 1.
  23342. */
  23343. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23344. /**
  23345. * Set the motor limits.
  23346. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23347. * @param {number} upperLimit the upper limit
  23348. * @param {number} lowerLimit lower limit
  23349. * @param {motorIndex} the motor's index, 0 or 1.
  23350. */
  23351. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23352. }
  23353. /**
  23354. * Interface for a motor enabled joint
  23355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23356. */
  23357. export interface IMotorEnabledJoint {
  23358. /**
  23359. * Physics joint
  23360. */
  23361. physicsJoint: any;
  23362. /**
  23363. * Sets the motor of the motor-enabled joint
  23364. * @param force The force of the motor
  23365. * @param maxForce The maximum force of the motor
  23366. * @param motorIndex The index of the motor
  23367. */
  23368. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23369. /**
  23370. * Sets the limit of the motor
  23371. * @param upperLimit The upper limit of the motor
  23372. * @param lowerLimit The lower limit of the motor
  23373. * @param motorIndex The index of the motor
  23374. */
  23375. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23376. }
  23377. /**
  23378. * Joint data for a Distance-Joint
  23379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23380. */
  23381. export interface DistanceJointData extends PhysicsJointData {
  23382. /**
  23383. * Max distance the 2 joint objects can be apart
  23384. */
  23385. maxDistance: number;
  23386. }
  23387. /**
  23388. * Joint data from a spring joint
  23389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23390. */
  23391. export interface SpringJointData extends PhysicsJointData {
  23392. /**
  23393. * Length of the spring
  23394. */
  23395. length: number;
  23396. /**
  23397. * Stiffness of the spring
  23398. */
  23399. stiffness: number;
  23400. /**
  23401. * Damping of the spring
  23402. */
  23403. damping: number;
  23404. /** this callback will be called when applying the force to the impostors. */
  23405. forceApplicationCallback: () => void;
  23406. }
  23407. }
  23408. declare module BABYLON {
  23409. /**
  23410. * Holds the data for the raycast result
  23411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23412. */
  23413. export class PhysicsRaycastResult {
  23414. private _hasHit;
  23415. private _hitDistance;
  23416. private _hitNormalWorld;
  23417. private _hitPointWorld;
  23418. private _rayFromWorld;
  23419. private _rayToWorld;
  23420. /**
  23421. * Gets if there was a hit
  23422. */
  23423. get hasHit(): boolean;
  23424. /**
  23425. * Gets the distance from the hit
  23426. */
  23427. get hitDistance(): number;
  23428. /**
  23429. * Gets the hit normal/direction in the world
  23430. */
  23431. get hitNormalWorld(): Vector3;
  23432. /**
  23433. * Gets the hit point in the world
  23434. */
  23435. get hitPointWorld(): Vector3;
  23436. /**
  23437. * Gets the ray "start point" of the ray in the world
  23438. */
  23439. get rayFromWorld(): Vector3;
  23440. /**
  23441. * Gets the ray "end point" of the ray in the world
  23442. */
  23443. get rayToWorld(): Vector3;
  23444. /**
  23445. * Sets the hit data (normal & point in world space)
  23446. * @param hitNormalWorld defines the normal in world space
  23447. * @param hitPointWorld defines the point in world space
  23448. */
  23449. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23450. /**
  23451. * Sets the distance from the start point to the hit point
  23452. * @param distance
  23453. */
  23454. setHitDistance(distance: number): void;
  23455. /**
  23456. * Calculates the distance manually
  23457. */
  23458. calculateHitDistance(): void;
  23459. /**
  23460. * Resets all the values to default
  23461. * @param from The from point on world space
  23462. * @param to The to point on world space
  23463. */
  23464. reset(from?: Vector3, to?: Vector3): void;
  23465. }
  23466. /**
  23467. * Interface for the size containing width and height
  23468. */
  23469. interface IXYZ {
  23470. /**
  23471. * X
  23472. */
  23473. x: number;
  23474. /**
  23475. * Y
  23476. */
  23477. y: number;
  23478. /**
  23479. * Z
  23480. */
  23481. z: number;
  23482. }
  23483. }
  23484. declare module BABYLON {
  23485. /**
  23486. * Interface used to describe a physics joint
  23487. */
  23488. export interface PhysicsImpostorJoint {
  23489. /** Defines the main impostor to which the joint is linked */
  23490. mainImpostor: PhysicsImpostor;
  23491. /** Defines the impostor that is connected to the main impostor using this joint */
  23492. connectedImpostor: PhysicsImpostor;
  23493. /** Defines the joint itself */
  23494. joint: PhysicsJoint;
  23495. }
  23496. /** @hidden */
  23497. export interface IPhysicsEnginePlugin {
  23498. world: any;
  23499. name: string;
  23500. setGravity(gravity: Vector3): void;
  23501. setTimeStep(timeStep: number): void;
  23502. getTimeStep(): number;
  23503. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23504. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23505. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23506. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23507. removePhysicsBody(impostor: PhysicsImpostor): void;
  23508. generateJoint(joint: PhysicsImpostorJoint): void;
  23509. removeJoint(joint: PhysicsImpostorJoint): void;
  23510. isSupported(): boolean;
  23511. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23512. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23513. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23514. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23515. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23516. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23517. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23518. getBodyMass(impostor: PhysicsImpostor): number;
  23519. getBodyFriction(impostor: PhysicsImpostor): number;
  23520. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23521. getBodyRestitution(impostor: PhysicsImpostor): number;
  23522. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23523. getBodyPressure?(impostor: PhysicsImpostor): number;
  23524. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23525. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23526. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23527. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23528. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23529. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23530. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23531. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23532. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23533. sleepBody(impostor: PhysicsImpostor): void;
  23534. wakeUpBody(impostor: PhysicsImpostor): void;
  23535. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23536. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23537. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23538. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23539. getRadius(impostor: PhysicsImpostor): number;
  23540. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23541. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23542. dispose(): void;
  23543. }
  23544. /**
  23545. * Interface used to define a physics engine
  23546. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23547. */
  23548. export interface IPhysicsEngine {
  23549. /**
  23550. * Gets the gravity vector used by the simulation
  23551. */
  23552. gravity: Vector3;
  23553. /**
  23554. * Sets the gravity vector used by the simulation
  23555. * @param gravity defines the gravity vector to use
  23556. */
  23557. setGravity(gravity: Vector3): void;
  23558. /**
  23559. * Set the time step of the physics engine.
  23560. * Default is 1/60.
  23561. * To slow it down, enter 1/600 for example.
  23562. * To speed it up, 1/30
  23563. * @param newTimeStep the new timestep to apply to this world.
  23564. */
  23565. setTimeStep(newTimeStep: number): void;
  23566. /**
  23567. * Get the time step of the physics engine.
  23568. * @returns the current time step
  23569. */
  23570. getTimeStep(): number;
  23571. /**
  23572. * Set the sub time step of the physics engine.
  23573. * Default is 0 meaning there is no sub steps
  23574. * To increase physics resolution precision, set a small value (like 1 ms)
  23575. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23576. */
  23577. setSubTimeStep(subTimeStep: number): void;
  23578. /**
  23579. * Get the sub time step of the physics engine.
  23580. * @returns the current sub time step
  23581. */
  23582. getSubTimeStep(): number;
  23583. /**
  23584. * Release all resources
  23585. */
  23586. dispose(): void;
  23587. /**
  23588. * Gets the name of the current physics plugin
  23589. * @returns the name of the plugin
  23590. */
  23591. getPhysicsPluginName(): string;
  23592. /**
  23593. * Adding a new impostor for the impostor tracking.
  23594. * This will be done by the impostor itself.
  23595. * @param impostor the impostor to add
  23596. */
  23597. addImpostor(impostor: PhysicsImpostor): void;
  23598. /**
  23599. * Remove an impostor from the engine.
  23600. * This impostor and its mesh will not longer be updated by the physics engine.
  23601. * @param impostor the impostor to remove
  23602. */
  23603. removeImpostor(impostor: PhysicsImpostor): void;
  23604. /**
  23605. * Add a joint to the physics engine
  23606. * @param mainImpostor defines the main impostor to which the joint is added.
  23607. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23608. * @param joint defines the joint that will connect both impostors.
  23609. */
  23610. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23611. /**
  23612. * Removes a joint from the simulation
  23613. * @param mainImpostor defines the impostor used with the joint
  23614. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23615. * @param joint defines the joint to remove
  23616. */
  23617. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23618. /**
  23619. * Gets the current plugin used to run the simulation
  23620. * @returns current plugin
  23621. */
  23622. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23623. /**
  23624. * Gets the list of physic impostors
  23625. * @returns an array of PhysicsImpostor
  23626. */
  23627. getImpostors(): Array<PhysicsImpostor>;
  23628. /**
  23629. * Gets the impostor for a physics enabled object
  23630. * @param object defines the object impersonated by the impostor
  23631. * @returns the PhysicsImpostor or null if not found
  23632. */
  23633. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23634. /**
  23635. * Gets the impostor for a physics body object
  23636. * @param body defines physics body used by the impostor
  23637. * @returns the PhysicsImpostor or null if not found
  23638. */
  23639. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23640. /**
  23641. * Does a raycast in the physics world
  23642. * @param from when should the ray start?
  23643. * @param to when should the ray end?
  23644. * @returns PhysicsRaycastResult
  23645. */
  23646. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23647. /**
  23648. * Called by the scene. No need to call it.
  23649. * @param delta defines the timespam between frames
  23650. */
  23651. _step(delta: number): void;
  23652. }
  23653. }
  23654. declare module BABYLON {
  23655. /**
  23656. * The interface for the physics imposter parameters
  23657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23658. */
  23659. export interface PhysicsImpostorParameters {
  23660. /**
  23661. * The mass of the physics imposter
  23662. */
  23663. mass: number;
  23664. /**
  23665. * The friction of the physics imposter
  23666. */
  23667. friction?: number;
  23668. /**
  23669. * The coefficient of restitution of the physics imposter
  23670. */
  23671. restitution?: number;
  23672. /**
  23673. * The native options of the physics imposter
  23674. */
  23675. nativeOptions?: any;
  23676. /**
  23677. * Specifies if the parent should be ignored
  23678. */
  23679. ignoreParent?: boolean;
  23680. /**
  23681. * Specifies if bi-directional transformations should be disabled
  23682. */
  23683. disableBidirectionalTransformation?: boolean;
  23684. /**
  23685. * The pressure inside the physics imposter, soft object only
  23686. */
  23687. pressure?: number;
  23688. /**
  23689. * The stiffness the physics imposter, soft object only
  23690. */
  23691. stiffness?: number;
  23692. /**
  23693. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23694. */
  23695. velocityIterations?: number;
  23696. /**
  23697. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23698. */
  23699. positionIterations?: number;
  23700. /**
  23701. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23702. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23703. * Add to fix multiple points
  23704. */
  23705. fixedPoints?: number;
  23706. /**
  23707. * The collision margin around a soft object
  23708. */
  23709. margin?: number;
  23710. /**
  23711. * The collision margin around a soft object
  23712. */
  23713. damping?: number;
  23714. /**
  23715. * The path for a rope based on an extrusion
  23716. */
  23717. path?: any;
  23718. /**
  23719. * The shape of an extrusion used for a rope based on an extrusion
  23720. */
  23721. shape?: any;
  23722. }
  23723. /**
  23724. * Interface for a physics-enabled object
  23725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23726. */
  23727. export interface IPhysicsEnabledObject {
  23728. /**
  23729. * The position of the physics-enabled object
  23730. */
  23731. position: Vector3;
  23732. /**
  23733. * The rotation of the physics-enabled object
  23734. */
  23735. rotationQuaternion: Nullable<Quaternion>;
  23736. /**
  23737. * The scale of the physics-enabled object
  23738. */
  23739. scaling: Vector3;
  23740. /**
  23741. * The rotation of the physics-enabled object
  23742. */
  23743. rotation?: Vector3;
  23744. /**
  23745. * The parent of the physics-enabled object
  23746. */
  23747. parent?: any;
  23748. /**
  23749. * The bounding info of the physics-enabled object
  23750. * @returns The bounding info of the physics-enabled object
  23751. */
  23752. getBoundingInfo(): BoundingInfo;
  23753. /**
  23754. * Computes the world matrix
  23755. * @param force Specifies if the world matrix should be computed by force
  23756. * @returns A world matrix
  23757. */
  23758. computeWorldMatrix(force: boolean): Matrix;
  23759. /**
  23760. * Gets the world matrix
  23761. * @returns A world matrix
  23762. */
  23763. getWorldMatrix?(): Matrix;
  23764. /**
  23765. * Gets the child meshes
  23766. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23767. * @returns An array of abstract meshes
  23768. */
  23769. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23770. /**
  23771. * Gets the vertex data
  23772. * @param kind The type of vertex data
  23773. * @returns A nullable array of numbers, or a float32 array
  23774. */
  23775. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23776. /**
  23777. * Gets the indices from the mesh
  23778. * @returns A nullable array of index arrays
  23779. */
  23780. getIndices?(): Nullable<IndicesArray>;
  23781. /**
  23782. * Gets the scene from the mesh
  23783. * @returns the indices array or null
  23784. */
  23785. getScene?(): Scene;
  23786. /**
  23787. * Gets the absolute position from the mesh
  23788. * @returns the absolute position
  23789. */
  23790. getAbsolutePosition(): Vector3;
  23791. /**
  23792. * Gets the absolute pivot point from the mesh
  23793. * @returns the absolute pivot point
  23794. */
  23795. getAbsolutePivotPoint(): Vector3;
  23796. /**
  23797. * Rotates the mesh
  23798. * @param axis The axis of rotation
  23799. * @param amount The amount of rotation
  23800. * @param space The space of the rotation
  23801. * @returns The rotation transform node
  23802. */
  23803. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23804. /**
  23805. * Translates the mesh
  23806. * @param axis The axis of translation
  23807. * @param distance The distance of translation
  23808. * @param space The space of the translation
  23809. * @returns The transform node
  23810. */
  23811. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23812. /**
  23813. * Sets the absolute position of the mesh
  23814. * @param absolutePosition The absolute position of the mesh
  23815. * @returns The transform node
  23816. */
  23817. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23818. /**
  23819. * Gets the class name of the mesh
  23820. * @returns The class name
  23821. */
  23822. getClassName(): string;
  23823. }
  23824. /**
  23825. * Represents a physics imposter
  23826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23827. */
  23828. export class PhysicsImpostor {
  23829. /**
  23830. * The physics-enabled object used as the physics imposter
  23831. */
  23832. object: IPhysicsEnabledObject;
  23833. /**
  23834. * The type of the physics imposter
  23835. */
  23836. type: number;
  23837. private _options;
  23838. private _scene?;
  23839. /**
  23840. * The default object size of the imposter
  23841. */
  23842. static DEFAULT_OBJECT_SIZE: Vector3;
  23843. /**
  23844. * The identity quaternion of the imposter
  23845. */
  23846. static IDENTITY_QUATERNION: Quaternion;
  23847. /** @hidden */
  23848. _pluginData: any;
  23849. private _physicsEngine;
  23850. private _physicsBody;
  23851. private _bodyUpdateRequired;
  23852. private _onBeforePhysicsStepCallbacks;
  23853. private _onAfterPhysicsStepCallbacks;
  23854. /** @hidden */
  23855. _onPhysicsCollideCallbacks: Array<{
  23856. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23857. otherImpostors: Array<PhysicsImpostor>;
  23858. }>;
  23859. private _deltaPosition;
  23860. private _deltaRotation;
  23861. private _deltaRotationConjugated;
  23862. /** @hidden */
  23863. _isFromLine: boolean;
  23864. private _parent;
  23865. private _isDisposed;
  23866. private static _tmpVecs;
  23867. private static _tmpQuat;
  23868. /**
  23869. * Specifies if the physics imposter is disposed
  23870. */
  23871. get isDisposed(): boolean;
  23872. /**
  23873. * Gets the mass of the physics imposter
  23874. */
  23875. get mass(): number;
  23876. set mass(value: number);
  23877. /**
  23878. * Gets the coefficient of friction
  23879. */
  23880. get friction(): number;
  23881. /**
  23882. * Sets the coefficient of friction
  23883. */
  23884. set friction(value: number);
  23885. /**
  23886. * Gets the coefficient of restitution
  23887. */
  23888. get restitution(): number;
  23889. /**
  23890. * Sets the coefficient of restitution
  23891. */
  23892. set restitution(value: number);
  23893. /**
  23894. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23895. */
  23896. get pressure(): number;
  23897. /**
  23898. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23899. */
  23900. set pressure(value: number);
  23901. /**
  23902. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23903. */
  23904. get stiffness(): number;
  23905. /**
  23906. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23907. */
  23908. set stiffness(value: number);
  23909. /**
  23910. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23911. */
  23912. get velocityIterations(): number;
  23913. /**
  23914. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23915. */
  23916. set velocityIterations(value: number);
  23917. /**
  23918. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23919. */
  23920. get positionIterations(): number;
  23921. /**
  23922. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23923. */
  23924. set positionIterations(value: number);
  23925. /**
  23926. * The unique id of the physics imposter
  23927. * set by the physics engine when adding this impostor to the array
  23928. */
  23929. uniqueId: number;
  23930. /**
  23931. * @hidden
  23932. */
  23933. soft: boolean;
  23934. /**
  23935. * @hidden
  23936. */
  23937. segments: number;
  23938. private _joints;
  23939. /**
  23940. * Initializes the physics imposter
  23941. * @param object The physics-enabled object used as the physics imposter
  23942. * @param type The type of the physics imposter
  23943. * @param _options The options for the physics imposter
  23944. * @param _scene The Babylon scene
  23945. */
  23946. constructor(
  23947. /**
  23948. * The physics-enabled object used as the physics imposter
  23949. */
  23950. object: IPhysicsEnabledObject,
  23951. /**
  23952. * The type of the physics imposter
  23953. */
  23954. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23955. /**
  23956. * This function will completly initialize this impostor.
  23957. * It will create a new body - but only if this mesh has no parent.
  23958. * If it has, this impostor will not be used other than to define the impostor
  23959. * of the child mesh.
  23960. * @hidden
  23961. */
  23962. _init(): void;
  23963. private _getPhysicsParent;
  23964. /**
  23965. * Should a new body be generated.
  23966. * @returns boolean specifying if body initialization is required
  23967. */
  23968. isBodyInitRequired(): boolean;
  23969. /**
  23970. * Sets the updated scaling
  23971. * @param updated Specifies if the scaling is updated
  23972. */
  23973. setScalingUpdated(): void;
  23974. /**
  23975. * Force a regeneration of this or the parent's impostor's body.
  23976. * Use under cautious - This will remove all joints already implemented.
  23977. */
  23978. forceUpdate(): void;
  23979. /**
  23980. * Gets the body that holds this impostor. Either its own, or its parent.
  23981. */
  23982. get physicsBody(): any;
  23983. /**
  23984. * Get the parent of the physics imposter
  23985. * @returns Physics imposter or null
  23986. */
  23987. get parent(): Nullable<PhysicsImpostor>;
  23988. /**
  23989. * Sets the parent of the physics imposter
  23990. */
  23991. set parent(value: Nullable<PhysicsImpostor>);
  23992. /**
  23993. * Set the physics body. Used mainly by the physics engine/plugin
  23994. */
  23995. set physicsBody(physicsBody: any);
  23996. /**
  23997. * Resets the update flags
  23998. */
  23999. resetUpdateFlags(): void;
  24000. /**
  24001. * Gets the object extend size
  24002. * @returns the object extend size
  24003. */
  24004. getObjectExtendSize(): Vector3;
  24005. /**
  24006. * Gets the object center
  24007. * @returns The object center
  24008. */
  24009. getObjectCenter(): Vector3;
  24010. /**
  24011. * Get a specific parameter from the options parameters
  24012. * @param paramName The object parameter name
  24013. * @returns The object parameter
  24014. */
  24015. getParam(paramName: string): any;
  24016. /**
  24017. * Sets a specific parameter in the options given to the physics plugin
  24018. * @param paramName The parameter name
  24019. * @param value The value of the parameter
  24020. */
  24021. setParam(paramName: string, value: number): void;
  24022. /**
  24023. * Specifically change the body's mass option. Won't recreate the physics body object
  24024. * @param mass The mass of the physics imposter
  24025. */
  24026. setMass(mass: number): void;
  24027. /**
  24028. * Gets the linear velocity
  24029. * @returns linear velocity or null
  24030. */
  24031. getLinearVelocity(): Nullable<Vector3>;
  24032. /**
  24033. * Sets the linear velocity
  24034. * @param velocity linear velocity or null
  24035. */
  24036. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24037. /**
  24038. * Gets the angular velocity
  24039. * @returns angular velocity or null
  24040. */
  24041. getAngularVelocity(): Nullable<Vector3>;
  24042. /**
  24043. * Sets the angular velocity
  24044. * @param velocity The velocity or null
  24045. */
  24046. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24047. /**
  24048. * Execute a function with the physics plugin native code
  24049. * Provide a function the will have two variables - the world object and the physics body object
  24050. * @param func The function to execute with the physics plugin native code
  24051. */
  24052. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24053. /**
  24054. * Register a function that will be executed before the physics world is stepping forward
  24055. * @param func The function to execute before the physics world is stepped forward
  24056. */
  24057. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24058. /**
  24059. * Unregister a function that will be executed before the physics world is stepping forward
  24060. * @param func The function to execute before the physics world is stepped forward
  24061. */
  24062. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24063. /**
  24064. * Register a function that will be executed after the physics step
  24065. * @param func The function to execute after physics step
  24066. */
  24067. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24068. /**
  24069. * Unregisters a function that will be executed after the physics step
  24070. * @param func The function to execute after physics step
  24071. */
  24072. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24073. /**
  24074. * register a function that will be executed when this impostor collides against a different body
  24075. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24076. * @param func Callback that is executed on collision
  24077. */
  24078. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24079. /**
  24080. * Unregisters the physics imposter on contact
  24081. * @param collideAgainst The physics object to collide against
  24082. * @param func Callback to execute on collision
  24083. */
  24084. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24085. private _tmpQuat;
  24086. private _tmpQuat2;
  24087. /**
  24088. * Get the parent rotation
  24089. * @returns The parent rotation
  24090. */
  24091. getParentsRotation(): Quaternion;
  24092. /**
  24093. * this function is executed by the physics engine.
  24094. */
  24095. beforeStep: () => void;
  24096. /**
  24097. * this function is executed by the physics engine
  24098. */
  24099. afterStep: () => void;
  24100. /**
  24101. * Legacy collision detection event support
  24102. */
  24103. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24104. /**
  24105. * event and body object due to cannon's event-based architecture.
  24106. */
  24107. onCollide: (e: {
  24108. body: any;
  24109. }) => void;
  24110. /**
  24111. * Apply a force
  24112. * @param force The force to apply
  24113. * @param contactPoint The contact point for the force
  24114. * @returns The physics imposter
  24115. */
  24116. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24117. /**
  24118. * Apply an impulse
  24119. * @param force The impulse force
  24120. * @param contactPoint The contact point for the impulse force
  24121. * @returns The physics imposter
  24122. */
  24123. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24124. /**
  24125. * A help function to create a joint
  24126. * @param otherImpostor A physics imposter used to create a joint
  24127. * @param jointType The type of joint
  24128. * @param jointData The data for the joint
  24129. * @returns The physics imposter
  24130. */
  24131. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24132. /**
  24133. * Add a joint to this impostor with a different impostor
  24134. * @param otherImpostor A physics imposter used to add a joint
  24135. * @param joint The joint to add
  24136. * @returns The physics imposter
  24137. */
  24138. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24139. /**
  24140. * Add an anchor to a cloth impostor
  24141. * @param otherImpostor rigid impostor to anchor to
  24142. * @param width ratio across width from 0 to 1
  24143. * @param height ratio up height from 0 to 1
  24144. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24145. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24146. * @returns impostor the soft imposter
  24147. */
  24148. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24149. /**
  24150. * Add a hook to a rope impostor
  24151. * @param otherImpostor rigid impostor to anchor to
  24152. * @param length ratio across rope from 0 to 1
  24153. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24154. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24155. * @returns impostor the rope imposter
  24156. */
  24157. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24158. /**
  24159. * Will keep this body still, in a sleep mode.
  24160. * @returns the physics imposter
  24161. */
  24162. sleep(): PhysicsImpostor;
  24163. /**
  24164. * Wake the body up.
  24165. * @returns The physics imposter
  24166. */
  24167. wakeUp(): PhysicsImpostor;
  24168. /**
  24169. * Clones the physics imposter
  24170. * @param newObject The physics imposter clones to this physics-enabled object
  24171. * @returns A nullable physics imposter
  24172. */
  24173. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24174. /**
  24175. * Disposes the physics imposter
  24176. */
  24177. dispose(): void;
  24178. /**
  24179. * Sets the delta position
  24180. * @param position The delta position amount
  24181. */
  24182. setDeltaPosition(position: Vector3): void;
  24183. /**
  24184. * Sets the delta rotation
  24185. * @param rotation The delta rotation amount
  24186. */
  24187. setDeltaRotation(rotation: Quaternion): void;
  24188. /**
  24189. * Gets the box size of the physics imposter and stores the result in the input parameter
  24190. * @param result Stores the box size
  24191. * @returns The physics imposter
  24192. */
  24193. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24194. /**
  24195. * Gets the radius of the physics imposter
  24196. * @returns Radius of the physics imposter
  24197. */
  24198. getRadius(): number;
  24199. /**
  24200. * Sync a bone with this impostor
  24201. * @param bone The bone to sync to the impostor.
  24202. * @param boneMesh The mesh that the bone is influencing.
  24203. * @param jointPivot The pivot of the joint / bone in local space.
  24204. * @param distToJoint Optional distance from the impostor to the joint.
  24205. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24206. */
  24207. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24208. /**
  24209. * Sync impostor to a bone
  24210. * @param bone The bone that the impostor will be synced to.
  24211. * @param boneMesh The mesh that the bone is influencing.
  24212. * @param jointPivot The pivot of the joint / bone in local space.
  24213. * @param distToJoint Optional distance from the impostor to the joint.
  24214. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24215. * @param boneAxis Optional vector3 axis the bone is aligned with
  24216. */
  24217. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24218. /**
  24219. * No-Imposter type
  24220. */
  24221. static NoImpostor: number;
  24222. /**
  24223. * Sphere-Imposter type
  24224. */
  24225. static SphereImpostor: number;
  24226. /**
  24227. * Box-Imposter type
  24228. */
  24229. static BoxImpostor: number;
  24230. /**
  24231. * Plane-Imposter type
  24232. */
  24233. static PlaneImpostor: number;
  24234. /**
  24235. * Mesh-imposter type
  24236. */
  24237. static MeshImpostor: number;
  24238. /**
  24239. * Capsule-Impostor type (Ammo.js plugin only)
  24240. */
  24241. static CapsuleImpostor: number;
  24242. /**
  24243. * Cylinder-Imposter type
  24244. */
  24245. static CylinderImpostor: number;
  24246. /**
  24247. * Particle-Imposter type
  24248. */
  24249. static ParticleImpostor: number;
  24250. /**
  24251. * Heightmap-Imposter type
  24252. */
  24253. static HeightmapImpostor: number;
  24254. /**
  24255. * ConvexHull-Impostor type (Ammo.js plugin only)
  24256. */
  24257. static ConvexHullImpostor: number;
  24258. /**
  24259. * Custom-Imposter type (Ammo.js plugin only)
  24260. */
  24261. static CustomImpostor: number;
  24262. /**
  24263. * Rope-Imposter type
  24264. */
  24265. static RopeImpostor: number;
  24266. /**
  24267. * Cloth-Imposter type
  24268. */
  24269. static ClothImpostor: number;
  24270. /**
  24271. * Softbody-Imposter type
  24272. */
  24273. static SoftbodyImpostor: number;
  24274. }
  24275. }
  24276. declare module BABYLON {
  24277. /**
  24278. * @hidden
  24279. **/
  24280. export class _CreationDataStorage {
  24281. closePath?: boolean;
  24282. closeArray?: boolean;
  24283. idx: number[];
  24284. dashSize: number;
  24285. gapSize: number;
  24286. path3D: Path3D;
  24287. pathArray: Vector3[][];
  24288. arc: number;
  24289. radius: number;
  24290. cap: number;
  24291. tessellation: number;
  24292. }
  24293. /**
  24294. * @hidden
  24295. **/
  24296. class _InstanceDataStorage {
  24297. visibleInstances: any;
  24298. batchCache: _InstancesBatch;
  24299. instancesBufferSize: number;
  24300. instancesBuffer: Nullable<Buffer>;
  24301. instancesData: Float32Array;
  24302. overridenInstanceCount: number;
  24303. isFrozen: boolean;
  24304. previousBatch: Nullable<_InstancesBatch>;
  24305. hardwareInstancedRendering: boolean;
  24306. sideOrientation: number;
  24307. manualUpdate: boolean;
  24308. }
  24309. /**
  24310. * @hidden
  24311. **/
  24312. export class _InstancesBatch {
  24313. mustReturn: boolean;
  24314. visibleInstances: Nullable<InstancedMesh[]>[];
  24315. renderSelf: boolean[];
  24316. hardwareInstancedRendering: boolean[];
  24317. }
  24318. /**
  24319. * Class used to represent renderable models
  24320. */
  24321. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24322. /**
  24323. * Mesh side orientation : usually the external or front surface
  24324. */
  24325. static readonly FRONTSIDE: number;
  24326. /**
  24327. * Mesh side orientation : usually the internal or back surface
  24328. */
  24329. static readonly BACKSIDE: number;
  24330. /**
  24331. * Mesh side orientation : both internal and external or front and back surfaces
  24332. */
  24333. static readonly DOUBLESIDE: number;
  24334. /**
  24335. * Mesh side orientation : by default, `FRONTSIDE`
  24336. */
  24337. static readonly DEFAULTSIDE: number;
  24338. /**
  24339. * Mesh cap setting : no cap
  24340. */
  24341. static readonly NO_CAP: number;
  24342. /**
  24343. * Mesh cap setting : one cap at the beginning of the mesh
  24344. */
  24345. static readonly CAP_START: number;
  24346. /**
  24347. * Mesh cap setting : one cap at the end of the mesh
  24348. */
  24349. static readonly CAP_END: number;
  24350. /**
  24351. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24352. */
  24353. static readonly CAP_ALL: number;
  24354. /**
  24355. * Mesh pattern setting : no flip or rotate
  24356. */
  24357. static readonly NO_FLIP: number;
  24358. /**
  24359. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24360. */
  24361. static readonly FLIP_TILE: number;
  24362. /**
  24363. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24364. */
  24365. static readonly ROTATE_TILE: number;
  24366. /**
  24367. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24368. */
  24369. static readonly FLIP_ROW: number;
  24370. /**
  24371. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24372. */
  24373. static readonly ROTATE_ROW: number;
  24374. /**
  24375. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24376. */
  24377. static readonly FLIP_N_ROTATE_TILE: number;
  24378. /**
  24379. * Mesh pattern setting : rotate pattern and rotate
  24380. */
  24381. static readonly FLIP_N_ROTATE_ROW: number;
  24382. /**
  24383. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24384. */
  24385. static readonly CENTER: number;
  24386. /**
  24387. * Mesh tile positioning : part tiles on left
  24388. */
  24389. static readonly LEFT: number;
  24390. /**
  24391. * Mesh tile positioning : part tiles on right
  24392. */
  24393. static readonly RIGHT: number;
  24394. /**
  24395. * Mesh tile positioning : part tiles on top
  24396. */
  24397. static readonly TOP: number;
  24398. /**
  24399. * Mesh tile positioning : part tiles on bottom
  24400. */
  24401. static readonly BOTTOM: number;
  24402. /**
  24403. * Gets the default side orientation.
  24404. * @param orientation the orientation to value to attempt to get
  24405. * @returns the default orientation
  24406. * @hidden
  24407. */
  24408. static _GetDefaultSideOrientation(orientation?: number): number;
  24409. private _internalMeshDataInfo;
  24410. /**
  24411. * An event triggered before rendering the mesh
  24412. */
  24413. get onBeforeRenderObservable(): Observable<Mesh>;
  24414. /**
  24415. * An event triggered before binding the mesh
  24416. */
  24417. get onBeforeBindObservable(): Observable<Mesh>;
  24418. /**
  24419. * An event triggered after rendering the mesh
  24420. */
  24421. get onAfterRenderObservable(): Observable<Mesh>;
  24422. /**
  24423. * An event triggered before drawing the mesh
  24424. */
  24425. get onBeforeDrawObservable(): Observable<Mesh>;
  24426. private _onBeforeDrawObserver;
  24427. /**
  24428. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24429. */
  24430. set onBeforeDraw(callback: () => void);
  24431. get hasInstances(): boolean;
  24432. /**
  24433. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24434. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24435. */
  24436. delayLoadState: number;
  24437. /**
  24438. * Gets the list of instances created from this mesh
  24439. * it is not supposed to be modified manually.
  24440. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24441. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24442. */
  24443. instances: InstancedMesh[];
  24444. /**
  24445. * Gets the file containing delay loading data for this mesh
  24446. */
  24447. delayLoadingFile: string;
  24448. /** @hidden */
  24449. _binaryInfo: any;
  24450. /**
  24451. * User defined function used to change how LOD level selection is done
  24452. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24453. */
  24454. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24455. /**
  24456. * Gets or sets the morph target manager
  24457. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24458. */
  24459. get morphTargetManager(): Nullable<MorphTargetManager>;
  24460. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24461. /** @hidden */
  24462. _creationDataStorage: Nullable<_CreationDataStorage>;
  24463. /** @hidden */
  24464. _geometry: Nullable<Geometry>;
  24465. /** @hidden */
  24466. _delayInfo: Array<string>;
  24467. /** @hidden */
  24468. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24469. /** @hidden */
  24470. _instanceDataStorage: _InstanceDataStorage;
  24471. private _effectiveMaterial;
  24472. /** @hidden */
  24473. _shouldGenerateFlatShading: boolean;
  24474. /** @hidden */
  24475. _originalBuilderSideOrientation: number;
  24476. /**
  24477. * Use this property to change the original side orientation defined at construction time
  24478. */
  24479. overrideMaterialSideOrientation: Nullable<number>;
  24480. /**
  24481. * Gets the source mesh (the one used to clone this one from)
  24482. */
  24483. get source(): Nullable<Mesh>;
  24484. /**
  24485. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24486. */
  24487. get isUnIndexed(): boolean;
  24488. set isUnIndexed(value: boolean);
  24489. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24490. get worldMatrixInstancedBuffer(): Float32Array;
  24491. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24492. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24493. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24494. /**
  24495. * @constructor
  24496. * @param name The value used by scene.getMeshByName() to do a lookup.
  24497. * @param scene The scene to add this mesh to.
  24498. * @param parent The parent of this mesh, if it has one
  24499. * @param source An optional Mesh from which geometry is shared, cloned.
  24500. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24501. * When false, achieved by calling a clone(), also passing False.
  24502. * This will make creation of children, recursive.
  24503. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24504. */
  24505. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24506. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24507. doNotInstantiate: boolean;
  24508. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24509. /**
  24510. * Gets the class name
  24511. * @returns the string "Mesh".
  24512. */
  24513. getClassName(): string;
  24514. /** @hidden */
  24515. get _isMesh(): boolean;
  24516. /**
  24517. * Returns a description of this mesh
  24518. * @param fullDetails define if full details about this mesh must be used
  24519. * @returns a descriptive string representing this mesh
  24520. */
  24521. toString(fullDetails?: boolean): string;
  24522. /** @hidden */
  24523. _unBindEffect(): void;
  24524. /**
  24525. * Gets a boolean indicating if this mesh has LOD
  24526. */
  24527. get hasLODLevels(): boolean;
  24528. /**
  24529. * Gets the list of MeshLODLevel associated with the current mesh
  24530. * @returns an array of MeshLODLevel
  24531. */
  24532. getLODLevels(): MeshLODLevel[];
  24533. private _sortLODLevels;
  24534. /**
  24535. * Add a mesh as LOD level triggered at the given distance.
  24536. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24537. * @param distance The distance from the center of the object to show this level
  24538. * @param mesh The mesh to be added as LOD level (can be null)
  24539. * @return This mesh (for chaining)
  24540. */
  24541. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24542. /**
  24543. * Returns the LOD level mesh at the passed distance or null if not found.
  24544. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24545. * @param distance The distance from the center of the object to show this level
  24546. * @returns a Mesh or `null`
  24547. */
  24548. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24549. /**
  24550. * Remove a mesh from the LOD array
  24551. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24552. * @param mesh defines the mesh to be removed
  24553. * @return This mesh (for chaining)
  24554. */
  24555. removeLODLevel(mesh: Mesh): Mesh;
  24556. /**
  24557. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24558. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24559. * @param camera defines the camera to use to compute distance
  24560. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24561. * @return This mesh (for chaining)
  24562. */
  24563. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24564. /**
  24565. * Gets the mesh internal Geometry object
  24566. */
  24567. get geometry(): Nullable<Geometry>;
  24568. /**
  24569. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24570. * @returns the total number of vertices
  24571. */
  24572. getTotalVertices(): number;
  24573. /**
  24574. * Returns the content of an associated vertex buffer
  24575. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24576. * - VertexBuffer.PositionKind
  24577. * - VertexBuffer.UVKind
  24578. * - VertexBuffer.UV2Kind
  24579. * - VertexBuffer.UV3Kind
  24580. * - VertexBuffer.UV4Kind
  24581. * - VertexBuffer.UV5Kind
  24582. * - VertexBuffer.UV6Kind
  24583. * - VertexBuffer.ColorKind
  24584. * - VertexBuffer.MatricesIndicesKind
  24585. * - VertexBuffer.MatricesIndicesExtraKind
  24586. * - VertexBuffer.MatricesWeightsKind
  24587. * - VertexBuffer.MatricesWeightsExtraKind
  24588. * @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
  24589. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24590. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24591. */
  24592. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24593. /**
  24594. * Returns the mesh VertexBuffer object from the requested `kind`
  24595. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24596. * - VertexBuffer.PositionKind
  24597. * - VertexBuffer.NormalKind
  24598. * - VertexBuffer.UVKind
  24599. * - VertexBuffer.UV2Kind
  24600. * - VertexBuffer.UV3Kind
  24601. * - VertexBuffer.UV4Kind
  24602. * - VertexBuffer.UV5Kind
  24603. * - VertexBuffer.UV6Kind
  24604. * - VertexBuffer.ColorKind
  24605. * - VertexBuffer.MatricesIndicesKind
  24606. * - VertexBuffer.MatricesIndicesExtraKind
  24607. * - VertexBuffer.MatricesWeightsKind
  24608. * - VertexBuffer.MatricesWeightsExtraKind
  24609. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24610. */
  24611. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24612. /**
  24613. * Tests if a specific vertex buffer is associated with this mesh
  24614. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24615. * - VertexBuffer.PositionKind
  24616. * - VertexBuffer.NormalKind
  24617. * - VertexBuffer.UVKind
  24618. * - VertexBuffer.UV2Kind
  24619. * - VertexBuffer.UV3Kind
  24620. * - VertexBuffer.UV4Kind
  24621. * - VertexBuffer.UV5Kind
  24622. * - VertexBuffer.UV6Kind
  24623. * - VertexBuffer.ColorKind
  24624. * - VertexBuffer.MatricesIndicesKind
  24625. * - VertexBuffer.MatricesIndicesExtraKind
  24626. * - VertexBuffer.MatricesWeightsKind
  24627. * - VertexBuffer.MatricesWeightsExtraKind
  24628. * @returns a boolean
  24629. */
  24630. isVerticesDataPresent(kind: string): boolean;
  24631. /**
  24632. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24633. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24634. * - VertexBuffer.PositionKind
  24635. * - VertexBuffer.UVKind
  24636. * - VertexBuffer.UV2Kind
  24637. * - VertexBuffer.UV3Kind
  24638. * - VertexBuffer.UV4Kind
  24639. * - VertexBuffer.UV5Kind
  24640. * - VertexBuffer.UV6Kind
  24641. * - VertexBuffer.ColorKind
  24642. * - VertexBuffer.MatricesIndicesKind
  24643. * - VertexBuffer.MatricesIndicesExtraKind
  24644. * - VertexBuffer.MatricesWeightsKind
  24645. * - VertexBuffer.MatricesWeightsExtraKind
  24646. * @returns a boolean
  24647. */
  24648. isVertexBufferUpdatable(kind: string): boolean;
  24649. /**
  24650. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24651. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24652. * - VertexBuffer.PositionKind
  24653. * - VertexBuffer.NormalKind
  24654. * - VertexBuffer.UVKind
  24655. * - VertexBuffer.UV2Kind
  24656. * - VertexBuffer.UV3Kind
  24657. * - VertexBuffer.UV4Kind
  24658. * - VertexBuffer.UV5Kind
  24659. * - VertexBuffer.UV6Kind
  24660. * - VertexBuffer.ColorKind
  24661. * - VertexBuffer.MatricesIndicesKind
  24662. * - VertexBuffer.MatricesIndicesExtraKind
  24663. * - VertexBuffer.MatricesWeightsKind
  24664. * - VertexBuffer.MatricesWeightsExtraKind
  24665. * @returns an array of strings
  24666. */
  24667. getVerticesDataKinds(): string[];
  24668. /**
  24669. * Returns a positive integer : the total number of indices in this mesh geometry.
  24670. * @returns the numner of indices or zero if the mesh has no geometry.
  24671. */
  24672. getTotalIndices(): number;
  24673. /**
  24674. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24675. * @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.
  24676. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24677. * @returns the indices array or an empty array if the mesh has no geometry
  24678. */
  24679. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24680. get isBlocked(): boolean;
  24681. /**
  24682. * Determine if the current mesh is ready to be rendered
  24683. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24684. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24685. * @returns true if all associated assets are ready (material, textures, shaders)
  24686. */
  24687. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24688. /**
  24689. * 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.
  24690. */
  24691. get areNormalsFrozen(): boolean;
  24692. /**
  24693. * 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.
  24694. * @returns the current mesh
  24695. */
  24696. freezeNormals(): Mesh;
  24697. /**
  24698. * 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
  24699. * @returns the current mesh
  24700. */
  24701. unfreezeNormals(): Mesh;
  24702. /**
  24703. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24704. */
  24705. set overridenInstanceCount(count: number);
  24706. /** @hidden */
  24707. _preActivate(): Mesh;
  24708. /** @hidden */
  24709. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24710. /** @hidden */
  24711. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24712. /**
  24713. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24714. * This means the mesh underlying bounding box and sphere are recomputed.
  24715. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24716. * @returns the current mesh
  24717. */
  24718. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24719. /** @hidden */
  24720. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24721. /**
  24722. * This function will subdivide the mesh into multiple submeshes
  24723. * @param count defines the expected number of submeshes
  24724. */
  24725. subdivide(count: number): void;
  24726. /**
  24727. * Copy a FloatArray into a specific associated vertex buffer
  24728. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24729. * - VertexBuffer.PositionKind
  24730. * - VertexBuffer.UVKind
  24731. * - VertexBuffer.UV2Kind
  24732. * - VertexBuffer.UV3Kind
  24733. * - VertexBuffer.UV4Kind
  24734. * - VertexBuffer.UV5Kind
  24735. * - VertexBuffer.UV6Kind
  24736. * - VertexBuffer.ColorKind
  24737. * - VertexBuffer.MatricesIndicesKind
  24738. * - VertexBuffer.MatricesIndicesExtraKind
  24739. * - VertexBuffer.MatricesWeightsKind
  24740. * - VertexBuffer.MatricesWeightsExtraKind
  24741. * @param data defines the data source
  24742. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24743. * @param stride defines the data stride size (can be null)
  24744. * @returns the current mesh
  24745. */
  24746. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24747. /**
  24748. * Delete a vertex buffer associated with this mesh
  24749. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24750. * - VertexBuffer.PositionKind
  24751. * - VertexBuffer.UVKind
  24752. * - VertexBuffer.UV2Kind
  24753. * - VertexBuffer.UV3Kind
  24754. * - VertexBuffer.UV4Kind
  24755. * - VertexBuffer.UV5Kind
  24756. * - VertexBuffer.UV6Kind
  24757. * - VertexBuffer.ColorKind
  24758. * - VertexBuffer.MatricesIndicesKind
  24759. * - VertexBuffer.MatricesIndicesExtraKind
  24760. * - VertexBuffer.MatricesWeightsKind
  24761. * - VertexBuffer.MatricesWeightsExtraKind
  24762. */
  24763. removeVerticesData(kind: string): void;
  24764. /**
  24765. * Flags an associated vertex buffer as updatable
  24766. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24767. * - VertexBuffer.PositionKind
  24768. * - VertexBuffer.UVKind
  24769. * - VertexBuffer.UV2Kind
  24770. * - VertexBuffer.UV3Kind
  24771. * - VertexBuffer.UV4Kind
  24772. * - VertexBuffer.UV5Kind
  24773. * - VertexBuffer.UV6Kind
  24774. * - VertexBuffer.ColorKind
  24775. * - VertexBuffer.MatricesIndicesKind
  24776. * - VertexBuffer.MatricesIndicesExtraKind
  24777. * - VertexBuffer.MatricesWeightsKind
  24778. * - VertexBuffer.MatricesWeightsExtraKind
  24779. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24780. */
  24781. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24782. /**
  24783. * Sets the mesh global Vertex Buffer
  24784. * @param buffer defines the buffer to use
  24785. * @returns the current mesh
  24786. */
  24787. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24788. /**
  24789. * Update a specific associated vertex buffer
  24790. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24791. * - VertexBuffer.PositionKind
  24792. * - VertexBuffer.UVKind
  24793. * - VertexBuffer.UV2Kind
  24794. * - VertexBuffer.UV3Kind
  24795. * - VertexBuffer.UV4Kind
  24796. * - VertexBuffer.UV5Kind
  24797. * - VertexBuffer.UV6Kind
  24798. * - VertexBuffer.ColorKind
  24799. * - VertexBuffer.MatricesIndicesKind
  24800. * - VertexBuffer.MatricesIndicesExtraKind
  24801. * - VertexBuffer.MatricesWeightsKind
  24802. * - VertexBuffer.MatricesWeightsExtraKind
  24803. * @param data defines the data source
  24804. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24805. * @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)
  24806. * @returns the current mesh
  24807. */
  24808. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24809. /**
  24810. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24811. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24812. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24813. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24814. * @returns the current mesh
  24815. */
  24816. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24817. /**
  24818. * Creates a un-shared specific occurence of the geometry for the mesh.
  24819. * @returns the current mesh
  24820. */
  24821. makeGeometryUnique(): Mesh;
  24822. /**
  24823. * Set the index buffer of this mesh
  24824. * @param indices defines the source data
  24825. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24826. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24827. * @returns the current mesh
  24828. */
  24829. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24830. /**
  24831. * Update the current index buffer
  24832. * @param indices defines the source data
  24833. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24834. * @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)
  24835. * @returns the current mesh
  24836. */
  24837. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24838. /**
  24839. * Invert the geometry to move from a right handed system to a left handed one.
  24840. * @returns the current mesh
  24841. */
  24842. toLeftHanded(): Mesh;
  24843. /** @hidden */
  24844. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24845. /** @hidden */
  24846. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24847. /**
  24848. * Registers for this mesh a javascript function called just before the rendering process
  24849. * @param func defines the function to call before rendering this mesh
  24850. * @returns the current mesh
  24851. */
  24852. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24853. /**
  24854. * Disposes a previously registered javascript function called before the rendering
  24855. * @param func defines the function to remove
  24856. * @returns the current mesh
  24857. */
  24858. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24859. /**
  24860. * Registers for this mesh a javascript function called just after the rendering is complete
  24861. * @param func defines the function to call after rendering this mesh
  24862. * @returns the current mesh
  24863. */
  24864. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24865. /**
  24866. * Disposes a previously registered javascript function called after the rendering.
  24867. * @param func defines the function to remove
  24868. * @returns the current mesh
  24869. */
  24870. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24871. /** @hidden */
  24872. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24873. /** @hidden */
  24874. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24875. /** @hidden */
  24876. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24877. /** @hidden */
  24878. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24879. /** @hidden */
  24880. _rebuild(): void;
  24881. /** @hidden */
  24882. _freeze(): void;
  24883. /** @hidden */
  24884. _unFreeze(): void;
  24885. /**
  24886. * 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
  24887. * @param subMesh defines the subMesh to render
  24888. * @param enableAlphaMode defines if alpha mode can be changed
  24889. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24890. * @returns the current mesh
  24891. */
  24892. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24893. private _onBeforeDraw;
  24894. /**
  24895. * Renormalize the mesh and patch it up if there are no weights
  24896. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24897. * However in the case of zero weights then we set just a single influence to 1.
  24898. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24899. */
  24900. cleanMatrixWeights(): void;
  24901. private normalizeSkinFourWeights;
  24902. private normalizeSkinWeightsAndExtra;
  24903. /**
  24904. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24905. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24906. * the user know there was an issue with importing the mesh
  24907. * @returns a validation object with skinned, valid and report string
  24908. */
  24909. validateSkinning(): {
  24910. skinned: boolean;
  24911. valid: boolean;
  24912. report: string;
  24913. };
  24914. /** @hidden */
  24915. _checkDelayState(): Mesh;
  24916. private _queueLoad;
  24917. /**
  24918. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24919. * A mesh is in the frustum if its bounding box intersects the frustum
  24920. * @param frustumPlanes defines the frustum to test
  24921. * @returns true if the mesh is in the frustum planes
  24922. */
  24923. isInFrustum(frustumPlanes: Plane[]): boolean;
  24924. /**
  24925. * Sets the mesh material by the material or multiMaterial `id` property
  24926. * @param id is a string identifying the material or the multiMaterial
  24927. * @returns the current mesh
  24928. */
  24929. setMaterialByID(id: string): Mesh;
  24930. /**
  24931. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24932. * @returns an array of IAnimatable
  24933. */
  24934. getAnimatables(): IAnimatable[];
  24935. /**
  24936. * Modifies the mesh geometry according to the passed transformation matrix.
  24937. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24938. * The mesh normals are modified using the same transformation.
  24939. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24940. * @param transform defines the transform matrix to use
  24941. * @see http://doc.babylonjs.com/resources/baking_transformations
  24942. * @returns the current mesh
  24943. */
  24944. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24945. /**
  24946. * Modifies the mesh geometry according to its own current World Matrix.
  24947. * The mesh World Matrix is then reset.
  24948. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24949. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24950. * @see http://doc.babylonjs.com/resources/baking_transformations
  24951. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24952. * @returns the current mesh
  24953. */
  24954. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24955. /** @hidden */
  24956. get _positions(): Nullable<Vector3[]>;
  24957. /** @hidden */
  24958. _resetPointsArrayCache(): Mesh;
  24959. /** @hidden */
  24960. _generatePointsArray(): boolean;
  24961. /**
  24962. * Returns a new Mesh object generated from the current mesh properties.
  24963. * This method must not get confused with createInstance()
  24964. * @param name is a string, the name given to the new mesh
  24965. * @param newParent can be any Node object (default `null`)
  24966. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24967. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24968. * @returns a new mesh
  24969. */
  24970. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24971. /**
  24972. * Releases resources associated with this mesh.
  24973. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24974. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24975. */
  24976. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24977. /** @hidden */
  24978. _disposeInstanceSpecificData(): void;
  24979. /**
  24980. * Modifies the mesh geometry according to a displacement map.
  24981. * 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.
  24982. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24983. * @param url is a string, the URL from the image file is to be downloaded.
  24984. * @param minHeight is the lower limit of the displacement.
  24985. * @param maxHeight is the upper limit of the displacement.
  24986. * @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.
  24987. * @param uvOffset is an optional vector2 used to offset UV.
  24988. * @param uvScale is an optional vector2 used to scale UV.
  24989. * @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.
  24990. * @returns the Mesh.
  24991. */
  24992. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24993. /**
  24994. * Modifies the mesh geometry according to a displacementMap buffer.
  24995. * 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.
  24996. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24997. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24998. * @param heightMapWidth is the width of the buffer image.
  24999. * @param heightMapHeight is the height of the buffer image.
  25000. * @param minHeight is the lower limit of the displacement.
  25001. * @param maxHeight is the upper limit of the displacement.
  25002. * @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.
  25003. * @param uvOffset is an optional vector2 used to offset UV.
  25004. * @param uvScale is an optional vector2 used to scale UV.
  25005. * @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.
  25006. * @returns the Mesh.
  25007. */
  25008. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25009. /**
  25010. * Modify the mesh to get a flat shading rendering.
  25011. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25012. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25013. * @returns current mesh
  25014. */
  25015. convertToFlatShadedMesh(): Mesh;
  25016. /**
  25017. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25018. * In other words, more vertices, no more indices and a single bigger VBO.
  25019. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25020. * @returns current mesh
  25021. */
  25022. convertToUnIndexedMesh(): Mesh;
  25023. /**
  25024. * Inverses facet orientations.
  25025. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25026. * @param flipNormals will also inverts the normals
  25027. * @returns current mesh
  25028. */
  25029. flipFaces(flipNormals?: boolean): Mesh;
  25030. /**
  25031. * Increase the number of facets and hence vertices in a mesh
  25032. * Vertex normals are interpolated from existing vertex normals
  25033. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25034. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25035. */
  25036. increaseVertices(numberPerEdge: number): void;
  25037. /**
  25038. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25039. * This will undo any application of covertToFlatShadedMesh
  25040. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25041. */
  25042. forceSharedVertices(): void;
  25043. /** @hidden */
  25044. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25045. /** @hidden */
  25046. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25047. /**
  25048. * Creates a new InstancedMesh object from the mesh model.
  25049. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25050. * @param name defines the name of the new instance
  25051. * @returns a new InstancedMesh
  25052. */
  25053. createInstance(name: string): InstancedMesh;
  25054. /**
  25055. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25056. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25057. * @returns the current mesh
  25058. */
  25059. synchronizeInstances(): Mesh;
  25060. /**
  25061. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25062. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25063. * This should be used together with the simplification to avoid disappearing triangles.
  25064. * @param successCallback an optional success callback to be called after the optimization finished.
  25065. * @returns the current mesh
  25066. */
  25067. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25068. /**
  25069. * Serialize current mesh
  25070. * @param serializationObject defines the object which will receive the serialization data
  25071. */
  25072. serialize(serializationObject: any): void;
  25073. /** @hidden */
  25074. _syncGeometryWithMorphTargetManager(): void;
  25075. /** @hidden */
  25076. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25077. /**
  25078. * Returns a new Mesh object parsed from the source provided.
  25079. * @param parsedMesh is the source
  25080. * @param scene defines the hosting scene
  25081. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25082. * @returns a new Mesh
  25083. */
  25084. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25085. /**
  25086. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25087. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25088. * @param name defines the name of the mesh to create
  25089. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25090. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25091. * @param closePath creates a seam between the first and the last points of each path of the path array
  25092. * @param offset is taken in account only if the `pathArray` is containing a single path
  25093. * @param scene defines the hosting scene
  25094. * @param updatable defines if the mesh must be flagged as updatable
  25095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25096. * @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)
  25097. * @returns a new Mesh
  25098. */
  25099. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25100. /**
  25101. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25102. * @param name defines the name of the mesh to create
  25103. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25104. * @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
  25105. * @param scene defines the hosting scene
  25106. * @param updatable defines if the mesh must be flagged as updatable
  25107. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25108. * @returns a new Mesh
  25109. */
  25110. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25111. /**
  25112. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25113. * @param name defines the name of the mesh to create
  25114. * @param size sets the size (float) of each box side (default 1)
  25115. * @param scene defines the hosting scene
  25116. * @param updatable defines if the mesh must be flagged as updatable
  25117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25118. * @returns a new Mesh
  25119. */
  25120. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25121. /**
  25122. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25123. * @param name defines the name of the mesh to create
  25124. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25125. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25126. * @param scene defines the hosting scene
  25127. * @param updatable defines if the mesh must be flagged as updatable
  25128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25129. * @returns a new Mesh
  25130. */
  25131. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25132. /**
  25133. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25134. * @param name defines the name of the mesh to create
  25135. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25136. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25137. * @param scene defines the hosting scene
  25138. * @returns a new Mesh
  25139. */
  25140. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25141. /**
  25142. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25143. * @param name defines the name of the mesh to create
  25144. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25145. * @param diameterTop set the top cap diameter (floats, default 1)
  25146. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25147. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25148. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25149. * @param scene defines the hosting scene
  25150. * @param updatable defines if the mesh must be flagged as updatable
  25151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25152. * @returns a new Mesh
  25153. */
  25154. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25155. /**
  25156. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25157. * @param name defines the name of the mesh to create
  25158. * @param diameter sets the diameter size (float) of the torus (default 1)
  25159. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25160. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25161. * @param scene defines the hosting scene
  25162. * @param updatable defines if the mesh must be flagged as updatable
  25163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25164. * @returns a new Mesh
  25165. */
  25166. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25167. /**
  25168. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25169. * @param name defines the name of the mesh to create
  25170. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25171. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25172. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25173. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25174. * @param p the number of windings on X axis (positive integers, default 2)
  25175. * @param q the number of windings on Y axis (positive integers, default 3)
  25176. * @param scene defines the hosting scene
  25177. * @param updatable defines if the mesh must be flagged as updatable
  25178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25179. * @returns a new Mesh
  25180. */
  25181. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25182. /**
  25183. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25184. * @param name defines the name of the mesh to create
  25185. * @param points is an array successive Vector3
  25186. * @param scene defines the hosting scene
  25187. * @param updatable defines if the mesh must be flagged as updatable
  25188. * @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).
  25189. * @returns a new Mesh
  25190. */
  25191. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25192. /**
  25193. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25194. * @param name defines the name of the mesh to create
  25195. * @param points is an array successive Vector3
  25196. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25197. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25198. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25199. * @param scene defines the hosting scene
  25200. * @param updatable defines if the mesh must be flagged as updatable
  25201. * @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)
  25202. * @returns a new Mesh
  25203. */
  25204. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25205. /**
  25206. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25207. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25208. * 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.
  25209. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25210. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25211. * Remember you can only change the shape positions, not their number when updating a polygon.
  25212. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25213. * @param name defines the name of the mesh to create
  25214. * @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
  25215. * @param scene defines the hosting scene
  25216. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25217. * @param updatable defines if the mesh must be flagged as updatable
  25218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25219. * @param earcutInjection can be used to inject your own earcut reference
  25220. * @returns a new Mesh
  25221. */
  25222. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25223. /**
  25224. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25225. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25226. * @param name defines the name of the mesh to create
  25227. * @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
  25228. * @param depth defines the height of extrusion
  25229. * @param scene defines the hosting scene
  25230. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25231. * @param updatable defines if the mesh must be flagged as updatable
  25232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25233. * @param earcutInjection can be used to inject your own earcut reference
  25234. * @returns a new Mesh
  25235. */
  25236. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25237. /**
  25238. * Creates an extruded shape mesh.
  25239. * 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
  25240. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25241. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25242. * @param name defines the name of the mesh to create
  25243. * @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
  25244. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25245. * @param scale is the value to scale the shape
  25246. * @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
  25247. * @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
  25248. * @param scene defines the hosting scene
  25249. * @param updatable defines if the mesh must be flagged as updatable
  25250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25251. * @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)
  25252. * @returns a new Mesh
  25253. */
  25254. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25255. /**
  25256. * Creates an custom extruded shape mesh.
  25257. * The custom extrusion is a parametric shape.
  25258. * It has no predefined shape. Its final shape will depend on the input parameters.
  25259. * Please consider using the same method from the MeshBuilder class instead
  25260. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25261. * @param name defines the name of the mesh to create
  25262. * @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
  25263. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25264. * @param scaleFunction is a custom Javascript function called on each path point
  25265. * @param rotationFunction is a custom Javascript function called on each path point
  25266. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25267. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25268. * @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
  25269. * @param scene defines the hosting scene
  25270. * @param updatable defines if the mesh must be flagged as updatable
  25271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25272. * @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)
  25273. * @returns a new Mesh
  25274. */
  25275. 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;
  25276. /**
  25277. * Creates lathe mesh.
  25278. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25279. * Please consider using the same method from the MeshBuilder class instead
  25280. * @param name defines the name of the mesh to create
  25281. * @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
  25282. * @param radius is the radius value of the lathe
  25283. * @param tessellation is the side number of the lathe.
  25284. * @param scene defines the hosting scene
  25285. * @param updatable defines if the mesh must be flagged as updatable
  25286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25287. * @returns a new Mesh
  25288. */
  25289. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25290. /**
  25291. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25292. * @param name defines the name of the mesh to create
  25293. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25294. * @param scene defines the hosting scene
  25295. * @param updatable defines if the mesh must be flagged as updatable
  25296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25297. * @returns a new Mesh
  25298. */
  25299. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25300. /**
  25301. * Creates a ground mesh.
  25302. * Please consider using the same method from the MeshBuilder class instead
  25303. * @param name defines the name of the mesh to create
  25304. * @param width set the width of the ground
  25305. * @param height set the height of the ground
  25306. * @param subdivisions sets the number of subdivisions per side
  25307. * @param scene defines the hosting scene
  25308. * @param updatable defines if the mesh must be flagged as updatable
  25309. * @returns a new Mesh
  25310. */
  25311. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25312. /**
  25313. * Creates a tiled ground mesh.
  25314. * Please consider using the same method from the MeshBuilder class instead
  25315. * @param name defines the name of the mesh to create
  25316. * @param xmin set the ground minimum X coordinate
  25317. * @param zmin set the ground minimum Y coordinate
  25318. * @param xmax set the ground maximum X coordinate
  25319. * @param zmax set the ground maximum Z coordinate
  25320. * @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
  25321. * @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
  25322. * @param scene defines the hosting scene
  25323. * @param updatable defines if the mesh must be flagged as updatable
  25324. * @returns a new Mesh
  25325. */
  25326. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25327. w: number;
  25328. h: number;
  25329. }, precision: {
  25330. w: number;
  25331. h: number;
  25332. }, scene: Scene, updatable?: boolean): Mesh;
  25333. /**
  25334. * Creates a ground mesh from a height map.
  25335. * Please consider using the same method from the MeshBuilder class instead
  25336. * @see http://doc.babylonjs.com/babylon101/height_map
  25337. * @param name defines the name of the mesh to create
  25338. * @param url sets the URL of the height map image resource
  25339. * @param width set the ground width size
  25340. * @param height set the ground height size
  25341. * @param subdivisions sets the number of subdivision per side
  25342. * @param minHeight is the minimum altitude on the ground
  25343. * @param maxHeight is the maximum altitude on the ground
  25344. * @param scene defines the hosting scene
  25345. * @param updatable defines if the mesh must be flagged as updatable
  25346. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25347. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25348. * @returns a new Mesh
  25349. */
  25350. 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;
  25351. /**
  25352. * Creates a tube mesh.
  25353. * The tube is a parametric shape.
  25354. * It has no predefined shape. Its final shape will depend on the input parameters.
  25355. * Please consider using the same method from the MeshBuilder class instead
  25356. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25357. * @param name defines the name of the mesh to create
  25358. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25359. * @param radius sets the tube radius size
  25360. * @param tessellation is the number of sides on the tubular surface
  25361. * @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
  25362. * @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
  25363. * @param scene defines the hosting scene
  25364. * @param updatable defines if the mesh must be flagged as updatable
  25365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25366. * @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)
  25367. * @returns a new Mesh
  25368. */
  25369. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25370. (i: number, distance: number): number;
  25371. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25372. /**
  25373. * Creates a polyhedron mesh.
  25374. * Please consider using the same method from the MeshBuilder class instead.
  25375. * * 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
  25376. * * The parameter `size` (positive float, default 1) sets the polygon size
  25377. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25378. * * 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`
  25379. * * 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
  25380. * * 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)`)
  25381. * * 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
  25382. * * 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
  25383. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25384. * * 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
  25385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25386. * @param name defines the name of the mesh to create
  25387. * @param options defines the options used to create the mesh
  25388. * @param scene defines the hosting scene
  25389. * @returns a new Mesh
  25390. */
  25391. static CreatePolyhedron(name: string, options: {
  25392. type?: number;
  25393. size?: number;
  25394. sizeX?: number;
  25395. sizeY?: number;
  25396. sizeZ?: number;
  25397. custom?: any;
  25398. faceUV?: Vector4[];
  25399. faceColors?: Color4[];
  25400. updatable?: boolean;
  25401. sideOrientation?: number;
  25402. }, scene: Scene): Mesh;
  25403. /**
  25404. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25405. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25406. * * 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`)
  25407. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25408. * * 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
  25409. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25410. * * 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
  25411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25412. * @param name defines the name of the mesh
  25413. * @param options defines the options used to create the mesh
  25414. * @param scene defines the hosting scene
  25415. * @returns a new Mesh
  25416. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25417. */
  25418. static CreateIcoSphere(name: string, options: {
  25419. radius?: number;
  25420. flat?: boolean;
  25421. subdivisions?: number;
  25422. sideOrientation?: number;
  25423. updatable?: boolean;
  25424. }, scene: Scene): Mesh;
  25425. /**
  25426. * Creates a decal mesh.
  25427. * Please consider using the same method from the MeshBuilder class instead.
  25428. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25429. * @param name defines the name of the mesh
  25430. * @param sourceMesh defines the mesh receiving the decal
  25431. * @param position sets the position of the decal in world coordinates
  25432. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25433. * @param size sets the decal scaling
  25434. * @param angle sets the angle to rotate the decal
  25435. * @returns a new Mesh
  25436. */
  25437. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25438. /**
  25439. * Prepare internal position array for software CPU skinning
  25440. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25441. */
  25442. setPositionsForCPUSkinning(): Float32Array;
  25443. /**
  25444. * Prepare internal normal array for software CPU skinning
  25445. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25446. */
  25447. setNormalsForCPUSkinning(): Float32Array;
  25448. /**
  25449. * Updates the vertex buffer by applying transformation from the bones
  25450. * @param skeleton defines the skeleton to apply to current mesh
  25451. * @returns the current mesh
  25452. */
  25453. applySkeleton(skeleton: Skeleton): Mesh;
  25454. /**
  25455. * 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
  25456. * @param meshes defines the list of meshes to scan
  25457. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25458. */
  25459. static MinMax(meshes: AbstractMesh[]): {
  25460. min: Vector3;
  25461. max: Vector3;
  25462. };
  25463. /**
  25464. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25465. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25466. * @returns a vector3
  25467. */
  25468. static Center(meshesOrMinMaxVector: {
  25469. min: Vector3;
  25470. max: Vector3;
  25471. } | AbstractMesh[]): Vector3;
  25472. /**
  25473. * Merge the array of meshes into a single mesh for performance reasons.
  25474. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25475. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25476. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25477. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25478. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25479. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25480. * @returns a new mesh
  25481. */
  25482. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25483. /** @hidden */
  25484. addInstance(instance: InstancedMesh): void;
  25485. /** @hidden */
  25486. removeInstance(instance: InstancedMesh): void;
  25487. }
  25488. }
  25489. declare module BABYLON {
  25490. /**
  25491. * This is the base class of all the camera used in the application.
  25492. * @see http://doc.babylonjs.com/features/cameras
  25493. */
  25494. export class Camera extends Node {
  25495. /** @hidden */
  25496. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25497. /**
  25498. * This is the default projection mode used by the cameras.
  25499. * It helps recreating a feeling of perspective and better appreciate depth.
  25500. * This is the best way to simulate real life cameras.
  25501. */
  25502. static readonly PERSPECTIVE_CAMERA: number;
  25503. /**
  25504. * This helps creating camera with an orthographic mode.
  25505. * 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.
  25506. */
  25507. static readonly ORTHOGRAPHIC_CAMERA: number;
  25508. /**
  25509. * This is the default FOV mode for perspective cameras.
  25510. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25511. */
  25512. static readonly FOVMODE_VERTICAL_FIXED: number;
  25513. /**
  25514. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25515. */
  25516. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25517. /**
  25518. * This specifies ther is no need for a camera rig.
  25519. * Basically only one eye is rendered corresponding to the camera.
  25520. */
  25521. static readonly RIG_MODE_NONE: number;
  25522. /**
  25523. * Simulates a camera Rig with one blue eye and one red eye.
  25524. * This can be use with 3d blue and red glasses.
  25525. */
  25526. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25527. /**
  25528. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25529. */
  25530. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25531. /**
  25532. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25533. */
  25534. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25535. /**
  25536. * Defines that both eyes of the camera will be rendered over under each other.
  25537. */
  25538. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25539. /**
  25540. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25541. */
  25542. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25543. /**
  25544. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25545. */
  25546. static readonly RIG_MODE_VR: number;
  25547. /**
  25548. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25549. */
  25550. static readonly RIG_MODE_WEBVR: number;
  25551. /**
  25552. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25553. */
  25554. static readonly RIG_MODE_CUSTOM: number;
  25555. /**
  25556. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25557. */
  25558. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25559. /**
  25560. * Define the input manager associated with the camera.
  25561. */
  25562. inputs: CameraInputsManager<Camera>;
  25563. /** @hidden */
  25564. _position: Vector3;
  25565. /**
  25566. * Define the current local position of the camera in the scene
  25567. */
  25568. get position(): Vector3;
  25569. set position(newPosition: Vector3);
  25570. /**
  25571. * The vector the camera should consider as up.
  25572. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25573. */
  25574. upVector: Vector3;
  25575. /**
  25576. * Define the current limit on the left side for an orthographic camera
  25577. * In scene unit
  25578. */
  25579. orthoLeft: Nullable<number>;
  25580. /**
  25581. * Define the current limit on the right side for an orthographic camera
  25582. * In scene unit
  25583. */
  25584. orthoRight: Nullable<number>;
  25585. /**
  25586. * Define the current limit on the bottom side for an orthographic camera
  25587. * In scene unit
  25588. */
  25589. orthoBottom: Nullable<number>;
  25590. /**
  25591. * Define the current limit on the top side for an orthographic camera
  25592. * In scene unit
  25593. */
  25594. orthoTop: Nullable<number>;
  25595. /**
  25596. * Field Of View is set in Radians. (default is 0.8)
  25597. */
  25598. fov: number;
  25599. /**
  25600. * Define the minimum distance the camera can see from.
  25601. * This is important to note that the depth buffer are not infinite and the closer it starts
  25602. * the more your scene might encounter depth fighting issue.
  25603. */
  25604. minZ: number;
  25605. /**
  25606. * Define the maximum distance the camera can see to.
  25607. * This is important to note that the depth buffer are not infinite and the further it end
  25608. * the more your scene might encounter depth fighting issue.
  25609. */
  25610. maxZ: number;
  25611. /**
  25612. * Define the default inertia of the camera.
  25613. * This helps giving a smooth feeling to the camera movement.
  25614. */
  25615. inertia: number;
  25616. /**
  25617. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25618. */
  25619. mode: number;
  25620. /**
  25621. * Define whether the camera is intermediate.
  25622. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25623. */
  25624. isIntermediate: boolean;
  25625. /**
  25626. * Define the viewport of the camera.
  25627. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25628. */
  25629. viewport: Viewport;
  25630. /**
  25631. * Restricts the camera to viewing objects with the same layerMask.
  25632. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25633. */
  25634. layerMask: number;
  25635. /**
  25636. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25637. */
  25638. fovMode: number;
  25639. /**
  25640. * Rig mode of the camera.
  25641. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25642. * This is normally controlled byt the camera themselves as internal use.
  25643. */
  25644. cameraRigMode: number;
  25645. /**
  25646. * Defines the distance between both "eyes" in case of a RIG
  25647. */
  25648. interaxialDistance: number;
  25649. /**
  25650. * Defines if stereoscopic rendering is done side by side or over under.
  25651. */
  25652. isStereoscopicSideBySide: boolean;
  25653. /**
  25654. * 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
  25655. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25656. * else in the scene. (Eg. security camera)
  25657. *
  25658. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25659. */
  25660. customRenderTargets: RenderTargetTexture[];
  25661. /**
  25662. * When set, the camera will render to this render target instead of the default canvas
  25663. *
  25664. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25665. */
  25666. outputRenderTarget: Nullable<RenderTargetTexture>;
  25667. /**
  25668. * Observable triggered when the camera view matrix has changed.
  25669. */
  25670. onViewMatrixChangedObservable: Observable<Camera>;
  25671. /**
  25672. * Observable triggered when the camera Projection matrix has changed.
  25673. */
  25674. onProjectionMatrixChangedObservable: Observable<Camera>;
  25675. /**
  25676. * Observable triggered when the inputs have been processed.
  25677. */
  25678. onAfterCheckInputsObservable: Observable<Camera>;
  25679. /**
  25680. * Observable triggered when reset has been called and applied to the camera.
  25681. */
  25682. onRestoreStateObservable: Observable<Camera>;
  25683. /**
  25684. * Is this camera a part of a rig system?
  25685. */
  25686. isRigCamera: boolean;
  25687. /**
  25688. * If isRigCamera set to true this will be set with the parent camera.
  25689. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25690. */
  25691. rigParent?: Camera;
  25692. /** @hidden */
  25693. _cameraRigParams: any;
  25694. /** @hidden */
  25695. _rigCameras: Camera[];
  25696. /** @hidden */
  25697. _rigPostProcess: Nullable<PostProcess>;
  25698. protected _webvrViewMatrix: Matrix;
  25699. /** @hidden */
  25700. _skipRendering: boolean;
  25701. /** @hidden */
  25702. _projectionMatrix: Matrix;
  25703. /** @hidden */
  25704. _postProcesses: Nullable<PostProcess>[];
  25705. /** @hidden */
  25706. _activeMeshes: SmartArray<AbstractMesh>;
  25707. protected _globalPosition: Vector3;
  25708. /** @hidden */
  25709. _computedViewMatrix: Matrix;
  25710. private _doNotComputeProjectionMatrix;
  25711. private _transformMatrix;
  25712. private _frustumPlanes;
  25713. private _refreshFrustumPlanes;
  25714. private _storedFov;
  25715. private _stateStored;
  25716. /**
  25717. * Instantiates a new camera object.
  25718. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25719. * @see http://doc.babylonjs.com/features/cameras
  25720. * @param name Defines the name of the camera in the scene
  25721. * @param position Defines the position of the camera
  25722. * @param scene Defines the scene the camera belongs too
  25723. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25724. */
  25725. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25726. /**
  25727. * Store current camera state (fov, position, etc..)
  25728. * @returns the camera
  25729. */
  25730. storeState(): Camera;
  25731. /**
  25732. * Restores the camera state values if it has been stored. You must call storeState() first
  25733. */
  25734. protected _restoreStateValues(): boolean;
  25735. /**
  25736. * Restored camera state. You must call storeState() first.
  25737. * @returns true if restored and false otherwise
  25738. */
  25739. restoreState(): boolean;
  25740. /**
  25741. * Gets the class name of the camera.
  25742. * @returns the class name
  25743. */
  25744. getClassName(): string;
  25745. /** @hidden */
  25746. readonly _isCamera: boolean;
  25747. /**
  25748. * Gets a string representation of the camera useful for debug purpose.
  25749. * @param fullDetails Defines that a more verboe level of logging is required
  25750. * @returns the string representation
  25751. */
  25752. toString(fullDetails?: boolean): string;
  25753. /**
  25754. * Gets the current world space position of the camera.
  25755. */
  25756. get globalPosition(): Vector3;
  25757. /**
  25758. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25759. * @returns the active meshe list
  25760. */
  25761. getActiveMeshes(): SmartArray<AbstractMesh>;
  25762. /**
  25763. * Check whether a mesh is part of the current active mesh list of the camera
  25764. * @param mesh Defines the mesh to check
  25765. * @returns true if active, false otherwise
  25766. */
  25767. isActiveMesh(mesh: Mesh): boolean;
  25768. /**
  25769. * Is this camera ready to be used/rendered
  25770. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25771. * @return true if the camera is ready
  25772. */
  25773. isReady(completeCheck?: boolean): boolean;
  25774. /** @hidden */
  25775. _initCache(): void;
  25776. /** @hidden */
  25777. _updateCache(ignoreParentClass?: boolean): void;
  25778. /** @hidden */
  25779. _isSynchronized(): boolean;
  25780. /** @hidden */
  25781. _isSynchronizedViewMatrix(): boolean;
  25782. /** @hidden */
  25783. _isSynchronizedProjectionMatrix(): boolean;
  25784. /**
  25785. * Attach the input controls to a specific dom element to get the input from.
  25786. * @param element Defines the element the controls should be listened from
  25787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25788. */
  25789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25790. /**
  25791. * Detach the current controls from the specified dom element.
  25792. * @param element Defines the element to stop listening the inputs from
  25793. */
  25794. detachControl(element: HTMLElement): void;
  25795. /**
  25796. * Update the camera state according to the different inputs gathered during the frame.
  25797. */
  25798. update(): void;
  25799. /** @hidden */
  25800. _checkInputs(): void;
  25801. /** @hidden */
  25802. get rigCameras(): Camera[];
  25803. /**
  25804. * Gets the post process used by the rig cameras
  25805. */
  25806. get rigPostProcess(): Nullable<PostProcess>;
  25807. /**
  25808. * Internal, gets the first post proces.
  25809. * @returns the first post process to be run on this camera.
  25810. */
  25811. _getFirstPostProcess(): Nullable<PostProcess>;
  25812. private _cascadePostProcessesToRigCams;
  25813. /**
  25814. * Attach a post process to the camera.
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25816. * @param postProcess The post process to attach to the camera
  25817. * @param insertAt The position of the post process in case several of them are in use in the scene
  25818. * @returns the position the post process has been inserted at
  25819. */
  25820. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25821. /**
  25822. * Detach a post process to the camera.
  25823. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25824. * @param postProcess The post process to detach from the camera
  25825. */
  25826. detachPostProcess(postProcess: PostProcess): void;
  25827. /**
  25828. * Gets the current world matrix of the camera
  25829. */
  25830. getWorldMatrix(): Matrix;
  25831. /** @hidden */
  25832. _getViewMatrix(): Matrix;
  25833. /**
  25834. * Gets the current view matrix of the camera.
  25835. * @param force forces the camera to recompute the matrix without looking at the cached state
  25836. * @returns the view matrix
  25837. */
  25838. getViewMatrix(force?: boolean): Matrix;
  25839. /**
  25840. * Freeze the projection matrix.
  25841. * It will prevent the cache check of the camera projection compute and can speed up perf
  25842. * if no parameter of the camera are meant to change
  25843. * @param projection Defines manually a projection if necessary
  25844. */
  25845. freezeProjectionMatrix(projection?: Matrix): void;
  25846. /**
  25847. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25848. */
  25849. unfreezeProjectionMatrix(): void;
  25850. /**
  25851. * Gets the current projection matrix of the camera.
  25852. * @param force forces the camera to recompute the matrix without looking at the cached state
  25853. * @returns the projection matrix
  25854. */
  25855. getProjectionMatrix(force?: boolean): Matrix;
  25856. /**
  25857. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25858. * @returns a Matrix
  25859. */
  25860. getTransformationMatrix(): Matrix;
  25861. private _updateFrustumPlanes;
  25862. /**
  25863. * Checks if a cullable object (mesh...) is in the camera frustum
  25864. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25865. * @param target The object to check
  25866. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25867. * @returns true if the object is in frustum otherwise false
  25868. */
  25869. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25870. /**
  25871. * Checks if a cullable object (mesh...) is in the camera frustum
  25872. * Unlike isInFrustum this cheks the full bounding box
  25873. * @param target The object to check
  25874. * @returns true if the object is in frustum otherwise false
  25875. */
  25876. isCompletelyInFrustum(target: ICullable): boolean;
  25877. /**
  25878. * Gets a ray in the forward direction from the camera.
  25879. * @param length Defines the length of the ray to create
  25880. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25881. * @param origin Defines the start point of the ray which defaults to the camera position
  25882. * @returns the forward ray
  25883. */
  25884. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25885. /**
  25886. * Releases resources associated with this node.
  25887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25889. */
  25890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25891. /** @hidden */
  25892. _isLeftCamera: boolean;
  25893. /**
  25894. * Gets the left camera of a rig setup in case of Rigged Camera
  25895. */
  25896. get isLeftCamera(): boolean;
  25897. /** @hidden */
  25898. _isRightCamera: boolean;
  25899. /**
  25900. * Gets the right camera of a rig setup in case of Rigged Camera
  25901. */
  25902. get isRightCamera(): boolean;
  25903. /**
  25904. * Gets the left camera of a rig setup in case of Rigged Camera
  25905. */
  25906. get leftCamera(): Nullable<FreeCamera>;
  25907. /**
  25908. * Gets the right camera of a rig setup in case of Rigged Camera
  25909. */
  25910. get rightCamera(): Nullable<FreeCamera>;
  25911. /**
  25912. * Gets the left camera target of a rig setup in case of Rigged Camera
  25913. * @returns the target position
  25914. */
  25915. getLeftTarget(): Nullable<Vector3>;
  25916. /**
  25917. * Gets the right camera target of a rig setup in case of Rigged Camera
  25918. * @returns the target position
  25919. */
  25920. getRightTarget(): Nullable<Vector3>;
  25921. /**
  25922. * @hidden
  25923. */
  25924. setCameraRigMode(mode: number, rigParams: any): void;
  25925. /** @hidden */
  25926. static _setStereoscopicRigMode(camera: Camera): void;
  25927. /** @hidden */
  25928. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25929. /** @hidden */
  25930. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25931. /** @hidden */
  25932. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25933. /** @hidden */
  25934. _getVRProjectionMatrix(): Matrix;
  25935. protected _updateCameraRotationMatrix(): void;
  25936. protected _updateWebVRCameraRotationMatrix(): void;
  25937. /**
  25938. * This function MUST be overwritten by the different WebVR cameras available.
  25939. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25940. * @hidden
  25941. */
  25942. _getWebVRProjectionMatrix(): Matrix;
  25943. /**
  25944. * This function MUST be overwritten by the different WebVR cameras available.
  25945. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25946. * @hidden
  25947. */
  25948. _getWebVRViewMatrix(): Matrix;
  25949. /** @hidden */
  25950. setCameraRigParameter(name: string, value: any): void;
  25951. /**
  25952. * needs to be overridden by children so sub has required properties to be copied
  25953. * @hidden
  25954. */
  25955. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25956. /**
  25957. * May need to be overridden by children
  25958. * @hidden
  25959. */
  25960. _updateRigCameras(): void;
  25961. /** @hidden */
  25962. _setupInputs(): void;
  25963. /**
  25964. * Serialiaze the camera setup to a json represention
  25965. * @returns the JSON representation
  25966. */
  25967. serialize(): any;
  25968. /**
  25969. * Clones the current camera.
  25970. * @param name The cloned camera name
  25971. * @returns the cloned camera
  25972. */
  25973. clone(name: string): Camera;
  25974. /**
  25975. * Gets the direction of the camera relative to a given local axis.
  25976. * @param localAxis Defines the reference axis to provide a relative direction.
  25977. * @return the direction
  25978. */
  25979. getDirection(localAxis: Vector3): Vector3;
  25980. /**
  25981. * Returns the current camera absolute rotation
  25982. */
  25983. get absoluteRotation(): Quaternion;
  25984. /**
  25985. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25986. * @param localAxis Defines the reference axis to provide a relative direction.
  25987. * @param result Defines the vector to store the result in
  25988. */
  25989. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25990. /**
  25991. * Gets a camera constructor for a given camera type
  25992. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25993. * @param name The name of the camera the result will be able to instantiate
  25994. * @param scene The scene the result will construct the camera in
  25995. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25996. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25997. * @returns a factory method to construc the camera
  25998. */
  25999. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26000. /**
  26001. * Compute the world matrix of the camera.
  26002. * @returns the camera world matrix
  26003. */
  26004. computeWorldMatrix(): Matrix;
  26005. /**
  26006. * Parse a JSON and creates the camera from the parsed information
  26007. * @param parsedCamera The JSON to parse
  26008. * @param scene The scene to instantiate the camera in
  26009. * @returns the newly constructed camera
  26010. */
  26011. static Parse(parsedCamera: any, scene: Scene): Camera;
  26012. }
  26013. }
  26014. declare module BABYLON {
  26015. /**
  26016. * Class containing static functions to help procedurally build meshes
  26017. */
  26018. export class DiscBuilder {
  26019. /**
  26020. * Creates a plane polygonal mesh. By default, this is a disc
  26021. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26022. * * 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
  26023. * * 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
  26024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26025. * * 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
  26026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26027. * @param name defines the name of the mesh
  26028. * @param options defines the options used to create the mesh
  26029. * @param scene defines the hosting scene
  26030. * @returns the plane polygonal mesh
  26031. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26032. */
  26033. static CreateDisc(name: string, options: {
  26034. radius?: number;
  26035. tessellation?: number;
  26036. arc?: number;
  26037. updatable?: boolean;
  26038. sideOrientation?: number;
  26039. frontUVs?: Vector4;
  26040. backUVs?: Vector4;
  26041. }, scene?: Nullable<Scene>): Mesh;
  26042. }
  26043. }
  26044. declare module BABYLON {
  26045. /**
  26046. * This represents all the required information to add a fresnel effect on a material:
  26047. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26048. */
  26049. export class FresnelParameters {
  26050. private _isEnabled;
  26051. /**
  26052. * Define if the fresnel effect is enable or not.
  26053. */
  26054. get isEnabled(): boolean;
  26055. set isEnabled(value: boolean);
  26056. /**
  26057. * Define the color used on edges (grazing angle)
  26058. */
  26059. leftColor: Color3;
  26060. /**
  26061. * Define the color used on center
  26062. */
  26063. rightColor: Color3;
  26064. /**
  26065. * Define bias applied to computed fresnel term
  26066. */
  26067. bias: number;
  26068. /**
  26069. * Defined the power exponent applied to fresnel term
  26070. */
  26071. power: number;
  26072. /**
  26073. * Clones the current fresnel and its valuues
  26074. * @returns a clone fresnel configuration
  26075. */
  26076. clone(): FresnelParameters;
  26077. /**
  26078. * Serializes the current fresnel parameters to a JSON representation.
  26079. * @return the JSON serialization
  26080. */
  26081. serialize(): any;
  26082. /**
  26083. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26084. * @param parsedFresnelParameters Define the JSON representation
  26085. * @returns the parsed parameters
  26086. */
  26087. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26088. }
  26089. }
  26090. declare module BABYLON {
  26091. /**
  26092. * Base class of materials working in push mode in babylon JS
  26093. * @hidden
  26094. */
  26095. export class PushMaterial extends Material {
  26096. protected _activeEffect: Effect;
  26097. protected _normalMatrix: Matrix;
  26098. /**
  26099. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26100. * This means that the material can keep using a previous shader while a new one is being compiled.
  26101. * This is mostly used when shader parallel compilation is supported (true by default)
  26102. */
  26103. allowShaderHotSwapping: boolean;
  26104. constructor(name: string, scene: Scene);
  26105. getEffect(): Effect;
  26106. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26107. /**
  26108. * Binds the given world matrix to the active effect
  26109. *
  26110. * @param world the matrix to bind
  26111. */
  26112. bindOnlyWorldMatrix(world: Matrix): void;
  26113. /**
  26114. * Binds the given normal matrix to the active effect
  26115. *
  26116. * @param normalMatrix the matrix to bind
  26117. */
  26118. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26119. bind(world: Matrix, mesh?: Mesh): void;
  26120. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26121. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26122. }
  26123. }
  26124. declare module BABYLON {
  26125. /**
  26126. * This groups all the flags used to control the materials channel.
  26127. */
  26128. export class MaterialFlags {
  26129. private static _DiffuseTextureEnabled;
  26130. /**
  26131. * Are diffuse textures enabled in the application.
  26132. */
  26133. static get DiffuseTextureEnabled(): boolean;
  26134. static set DiffuseTextureEnabled(value: boolean);
  26135. private static _AmbientTextureEnabled;
  26136. /**
  26137. * Are ambient textures enabled in the application.
  26138. */
  26139. static get AmbientTextureEnabled(): boolean;
  26140. static set AmbientTextureEnabled(value: boolean);
  26141. private static _OpacityTextureEnabled;
  26142. /**
  26143. * Are opacity textures enabled in the application.
  26144. */
  26145. static get OpacityTextureEnabled(): boolean;
  26146. static set OpacityTextureEnabled(value: boolean);
  26147. private static _ReflectionTextureEnabled;
  26148. /**
  26149. * Are reflection textures enabled in the application.
  26150. */
  26151. static get ReflectionTextureEnabled(): boolean;
  26152. static set ReflectionTextureEnabled(value: boolean);
  26153. private static _EmissiveTextureEnabled;
  26154. /**
  26155. * Are emissive textures enabled in the application.
  26156. */
  26157. static get EmissiveTextureEnabled(): boolean;
  26158. static set EmissiveTextureEnabled(value: boolean);
  26159. private static _SpecularTextureEnabled;
  26160. /**
  26161. * Are specular textures enabled in the application.
  26162. */
  26163. static get SpecularTextureEnabled(): boolean;
  26164. static set SpecularTextureEnabled(value: boolean);
  26165. private static _BumpTextureEnabled;
  26166. /**
  26167. * Are bump textures enabled in the application.
  26168. */
  26169. static get BumpTextureEnabled(): boolean;
  26170. static set BumpTextureEnabled(value: boolean);
  26171. private static _LightmapTextureEnabled;
  26172. /**
  26173. * Are lightmap textures enabled in the application.
  26174. */
  26175. static get LightmapTextureEnabled(): boolean;
  26176. static set LightmapTextureEnabled(value: boolean);
  26177. private static _RefractionTextureEnabled;
  26178. /**
  26179. * Are refraction textures enabled in the application.
  26180. */
  26181. static get RefractionTextureEnabled(): boolean;
  26182. static set RefractionTextureEnabled(value: boolean);
  26183. private static _ColorGradingTextureEnabled;
  26184. /**
  26185. * Are color grading textures enabled in the application.
  26186. */
  26187. static get ColorGradingTextureEnabled(): boolean;
  26188. static set ColorGradingTextureEnabled(value: boolean);
  26189. private static _FresnelEnabled;
  26190. /**
  26191. * Are fresnels enabled in the application.
  26192. */
  26193. static get FresnelEnabled(): boolean;
  26194. static set FresnelEnabled(value: boolean);
  26195. private static _ClearCoatTextureEnabled;
  26196. /**
  26197. * Are clear coat textures enabled in the application.
  26198. */
  26199. static get ClearCoatTextureEnabled(): boolean;
  26200. static set ClearCoatTextureEnabled(value: boolean);
  26201. private static _ClearCoatBumpTextureEnabled;
  26202. /**
  26203. * Are clear coat bump textures enabled in the application.
  26204. */
  26205. static get ClearCoatBumpTextureEnabled(): boolean;
  26206. static set ClearCoatBumpTextureEnabled(value: boolean);
  26207. private static _ClearCoatTintTextureEnabled;
  26208. /**
  26209. * Are clear coat tint textures enabled in the application.
  26210. */
  26211. static get ClearCoatTintTextureEnabled(): boolean;
  26212. static set ClearCoatTintTextureEnabled(value: boolean);
  26213. private static _SheenTextureEnabled;
  26214. /**
  26215. * Are sheen textures enabled in the application.
  26216. */
  26217. static get SheenTextureEnabled(): boolean;
  26218. static set SheenTextureEnabled(value: boolean);
  26219. private static _AnisotropicTextureEnabled;
  26220. /**
  26221. * Are anisotropic textures enabled in the application.
  26222. */
  26223. static get AnisotropicTextureEnabled(): boolean;
  26224. static set AnisotropicTextureEnabled(value: boolean);
  26225. private static _ThicknessTextureEnabled;
  26226. /**
  26227. * Are thickness textures enabled in the application.
  26228. */
  26229. static get ThicknessTextureEnabled(): boolean;
  26230. static set ThicknessTextureEnabled(value: boolean);
  26231. }
  26232. }
  26233. declare module BABYLON {
  26234. /** @hidden */
  26235. export var defaultFragmentDeclaration: {
  26236. name: string;
  26237. shader: string;
  26238. };
  26239. }
  26240. declare module BABYLON {
  26241. /** @hidden */
  26242. export var defaultUboDeclaration: {
  26243. name: string;
  26244. shader: string;
  26245. };
  26246. }
  26247. declare module BABYLON {
  26248. /** @hidden */
  26249. export var lightFragmentDeclaration: {
  26250. name: string;
  26251. shader: string;
  26252. };
  26253. }
  26254. declare module BABYLON {
  26255. /** @hidden */
  26256. export var lightUboDeclaration: {
  26257. name: string;
  26258. shader: string;
  26259. };
  26260. }
  26261. declare module BABYLON {
  26262. /** @hidden */
  26263. export var lightsFragmentFunctions: {
  26264. name: string;
  26265. shader: string;
  26266. };
  26267. }
  26268. declare module BABYLON {
  26269. /** @hidden */
  26270. export var shadowsFragmentFunctions: {
  26271. name: string;
  26272. shader: string;
  26273. };
  26274. }
  26275. declare module BABYLON {
  26276. /** @hidden */
  26277. export var fresnelFunction: {
  26278. name: string;
  26279. shader: string;
  26280. };
  26281. }
  26282. declare module BABYLON {
  26283. /** @hidden */
  26284. export var reflectionFunction: {
  26285. name: string;
  26286. shader: string;
  26287. };
  26288. }
  26289. declare module BABYLON {
  26290. /** @hidden */
  26291. export var bumpFragmentFunctions: {
  26292. name: string;
  26293. shader: string;
  26294. };
  26295. }
  26296. declare module BABYLON {
  26297. /** @hidden */
  26298. export var logDepthDeclaration: {
  26299. name: string;
  26300. shader: string;
  26301. };
  26302. }
  26303. declare module BABYLON {
  26304. /** @hidden */
  26305. export var bumpFragment: {
  26306. name: string;
  26307. shader: string;
  26308. };
  26309. }
  26310. declare module BABYLON {
  26311. /** @hidden */
  26312. export var depthPrePass: {
  26313. name: string;
  26314. shader: string;
  26315. };
  26316. }
  26317. declare module BABYLON {
  26318. /** @hidden */
  26319. export var lightFragment: {
  26320. name: string;
  26321. shader: string;
  26322. };
  26323. }
  26324. declare module BABYLON {
  26325. /** @hidden */
  26326. export var logDepthFragment: {
  26327. name: string;
  26328. shader: string;
  26329. };
  26330. }
  26331. declare module BABYLON {
  26332. /** @hidden */
  26333. export var defaultPixelShader: {
  26334. name: string;
  26335. shader: string;
  26336. };
  26337. }
  26338. declare module BABYLON {
  26339. /** @hidden */
  26340. export var defaultVertexDeclaration: {
  26341. name: string;
  26342. shader: string;
  26343. };
  26344. }
  26345. declare module BABYLON {
  26346. /** @hidden */
  26347. export var bumpVertexDeclaration: {
  26348. name: string;
  26349. shader: string;
  26350. };
  26351. }
  26352. declare module BABYLON {
  26353. /** @hidden */
  26354. export var bumpVertex: {
  26355. name: string;
  26356. shader: string;
  26357. };
  26358. }
  26359. declare module BABYLON {
  26360. /** @hidden */
  26361. export var fogVertex: {
  26362. name: string;
  26363. shader: string;
  26364. };
  26365. }
  26366. declare module BABYLON {
  26367. /** @hidden */
  26368. export var shadowsVertex: {
  26369. name: string;
  26370. shader: string;
  26371. };
  26372. }
  26373. declare module BABYLON {
  26374. /** @hidden */
  26375. export var pointCloudVertex: {
  26376. name: string;
  26377. shader: string;
  26378. };
  26379. }
  26380. declare module BABYLON {
  26381. /** @hidden */
  26382. export var logDepthVertex: {
  26383. name: string;
  26384. shader: string;
  26385. };
  26386. }
  26387. declare module BABYLON {
  26388. /** @hidden */
  26389. export var defaultVertexShader: {
  26390. name: string;
  26391. shader: string;
  26392. };
  26393. }
  26394. declare module BABYLON {
  26395. /** @hidden */
  26396. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26397. MAINUV1: boolean;
  26398. MAINUV2: boolean;
  26399. DIFFUSE: boolean;
  26400. DIFFUSEDIRECTUV: number;
  26401. AMBIENT: boolean;
  26402. AMBIENTDIRECTUV: number;
  26403. OPACITY: boolean;
  26404. OPACITYDIRECTUV: number;
  26405. OPACITYRGB: boolean;
  26406. REFLECTION: boolean;
  26407. EMISSIVE: boolean;
  26408. EMISSIVEDIRECTUV: number;
  26409. SPECULAR: boolean;
  26410. SPECULARDIRECTUV: number;
  26411. BUMP: boolean;
  26412. BUMPDIRECTUV: number;
  26413. PARALLAX: boolean;
  26414. PARALLAXOCCLUSION: boolean;
  26415. SPECULAROVERALPHA: boolean;
  26416. CLIPPLANE: boolean;
  26417. CLIPPLANE2: boolean;
  26418. CLIPPLANE3: boolean;
  26419. CLIPPLANE4: boolean;
  26420. CLIPPLANE5: boolean;
  26421. CLIPPLANE6: boolean;
  26422. ALPHATEST: boolean;
  26423. DEPTHPREPASS: boolean;
  26424. ALPHAFROMDIFFUSE: boolean;
  26425. POINTSIZE: boolean;
  26426. FOG: boolean;
  26427. SPECULARTERM: boolean;
  26428. DIFFUSEFRESNEL: boolean;
  26429. OPACITYFRESNEL: boolean;
  26430. REFLECTIONFRESNEL: boolean;
  26431. REFRACTIONFRESNEL: boolean;
  26432. EMISSIVEFRESNEL: boolean;
  26433. FRESNEL: boolean;
  26434. NORMAL: boolean;
  26435. UV1: boolean;
  26436. UV2: boolean;
  26437. VERTEXCOLOR: boolean;
  26438. VERTEXALPHA: boolean;
  26439. NUM_BONE_INFLUENCERS: number;
  26440. BonesPerMesh: number;
  26441. BONETEXTURE: boolean;
  26442. INSTANCES: boolean;
  26443. GLOSSINESS: boolean;
  26444. ROUGHNESS: boolean;
  26445. EMISSIVEASILLUMINATION: boolean;
  26446. LINKEMISSIVEWITHDIFFUSE: boolean;
  26447. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26448. LIGHTMAP: boolean;
  26449. LIGHTMAPDIRECTUV: number;
  26450. OBJECTSPACE_NORMALMAP: boolean;
  26451. USELIGHTMAPASSHADOWMAP: boolean;
  26452. REFLECTIONMAP_3D: boolean;
  26453. REFLECTIONMAP_SPHERICAL: boolean;
  26454. REFLECTIONMAP_PLANAR: boolean;
  26455. REFLECTIONMAP_CUBIC: boolean;
  26456. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26457. REFLECTIONMAP_PROJECTION: boolean;
  26458. REFLECTIONMAP_SKYBOX: boolean;
  26459. REFLECTIONMAP_EXPLICIT: boolean;
  26460. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26461. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26462. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26463. INVERTCUBICMAP: boolean;
  26464. LOGARITHMICDEPTH: boolean;
  26465. REFRACTION: boolean;
  26466. REFRACTIONMAP_3D: boolean;
  26467. REFLECTIONOVERALPHA: boolean;
  26468. TWOSIDEDLIGHTING: boolean;
  26469. SHADOWFLOAT: boolean;
  26470. MORPHTARGETS: boolean;
  26471. MORPHTARGETS_NORMAL: boolean;
  26472. MORPHTARGETS_TANGENT: boolean;
  26473. MORPHTARGETS_UV: boolean;
  26474. NUM_MORPH_INFLUENCERS: number;
  26475. NONUNIFORMSCALING: boolean;
  26476. PREMULTIPLYALPHA: boolean;
  26477. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26478. ALPHABLEND: boolean;
  26479. IMAGEPROCESSING: boolean;
  26480. VIGNETTE: boolean;
  26481. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26482. VIGNETTEBLENDMODEOPAQUE: boolean;
  26483. TONEMAPPING: boolean;
  26484. TONEMAPPING_ACES: boolean;
  26485. CONTRAST: boolean;
  26486. COLORCURVES: boolean;
  26487. COLORGRADING: boolean;
  26488. COLORGRADING3D: boolean;
  26489. SAMPLER3DGREENDEPTH: boolean;
  26490. SAMPLER3DBGRMAP: boolean;
  26491. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26492. MULTIVIEW: boolean;
  26493. /**
  26494. * If the reflection texture on this material is in linear color space
  26495. * @hidden
  26496. */
  26497. IS_REFLECTION_LINEAR: boolean;
  26498. /**
  26499. * If the refraction texture on this material is in linear color space
  26500. * @hidden
  26501. */
  26502. IS_REFRACTION_LINEAR: boolean;
  26503. EXPOSURE: boolean;
  26504. constructor();
  26505. setReflectionMode(modeToEnable: string): void;
  26506. }
  26507. /**
  26508. * This is the default material used in Babylon. It is the best trade off between quality
  26509. * and performances.
  26510. * @see http://doc.babylonjs.com/babylon101/materials
  26511. */
  26512. export class StandardMaterial extends PushMaterial {
  26513. private _diffuseTexture;
  26514. /**
  26515. * The basic texture of the material as viewed under a light.
  26516. */
  26517. diffuseTexture: Nullable<BaseTexture>;
  26518. private _ambientTexture;
  26519. /**
  26520. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26521. */
  26522. ambientTexture: Nullable<BaseTexture>;
  26523. private _opacityTexture;
  26524. /**
  26525. * Define the transparency of the material from a texture.
  26526. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26527. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26528. */
  26529. opacityTexture: Nullable<BaseTexture>;
  26530. private _reflectionTexture;
  26531. /**
  26532. * Define the texture used to display the reflection.
  26533. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26534. */
  26535. reflectionTexture: Nullable<BaseTexture>;
  26536. private _emissiveTexture;
  26537. /**
  26538. * Define texture of the material as if self lit.
  26539. * This will be mixed in the final result even in the absence of light.
  26540. */
  26541. emissiveTexture: Nullable<BaseTexture>;
  26542. private _specularTexture;
  26543. /**
  26544. * Define how the color and intensity of the highlight given by the light in the material.
  26545. */
  26546. specularTexture: Nullable<BaseTexture>;
  26547. private _bumpTexture;
  26548. /**
  26549. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26550. * 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.
  26551. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26552. */
  26553. bumpTexture: Nullable<BaseTexture>;
  26554. private _lightmapTexture;
  26555. /**
  26556. * Complex lighting can be computationally expensive to compute at runtime.
  26557. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26558. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26559. */
  26560. lightmapTexture: Nullable<BaseTexture>;
  26561. private _refractionTexture;
  26562. /**
  26563. * Define the texture used to display the refraction.
  26564. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26565. */
  26566. refractionTexture: Nullable<BaseTexture>;
  26567. /**
  26568. * The color of the material lit by the environmental background lighting.
  26569. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26570. */
  26571. ambientColor: Color3;
  26572. /**
  26573. * The basic color of the material as viewed under a light.
  26574. */
  26575. diffuseColor: Color3;
  26576. /**
  26577. * Define how the color and intensity of the highlight given by the light in the material.
  26578. */
  26579. specularColor: Color3;
  26580. /**
  26581. * Define the color of the material as if self lit.
  26582. * This will be mixed in the final result even in the absence of light.
  26583. */
  26584. emissiveColor: Color3;
  26585. /**
  26586. * Defines how sharp are the highlights in the material.
  26587. * The bigger the value the sharper giving a more glossy feeling to the result.
  26588. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26589. */
  26590. specularPower: number;
  26591. private _useAlphaFromDiffuseTexture;
  26592. /**
  26593. * Does the transparency come from the diffuse texture alpha channel.
  26594. */
  26595. useAlphaFromDiffuseTexture: boolean;
  26596. private _useEmissiveAsIllumination;
  26597. /**
  26598. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26599. */
  26600. useEmissiveAsIllumination: boolean;
  26601. private _linkEmissiveWithDiffuse;
  26602. /**
  26603. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26604. * the emissive level when the final color is close to one.
  26605. */
  26606. linkEmissiveWithDiffuse: boolean;
  26607. private _useSpecularOverAlpha;
  26608. /**
  26609. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26610. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26611. */
  26612. useSpecularOverAlpha: boolean;
  26613. private _useReflectionOverAlpha;
  26614. /**
  26615. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26616. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26617. */
  26618. useReflectionOverAlpha: boolean;
  26619. private _disableLighting;
  26620. /**
  26621. * Does lights from the scene impacts this material.
  26622. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26623. */
  26624. disableLighting: boolean;
  26625. private _useObjectSpaceNormalMap;
  26626. /**
  26627. * Allows using an object space normal map (instead of tangent space).
  26628. */
  26629. useObjectSpaceNormalMap: boolean;
  26630. private _useParallax;
  26631. /**
  26632. * Is parallax enabled or not.
  26633. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26634. */
  26635. useParallax: boolean;
  26636. private _useParallaxOcclusion;
  26637. /**
  26638. * Is parallax occlusion enabled or not.
  26639. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26640. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26641. */
  26642. useParallaxOcclusion: boolean;
  26643. /**
  26644. * 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.
  26645. */
  26646. parallaxScaleBias: number;
  26647. private _roughness;
  26648. /**
  26649. * Helps to define how blurry the reflections should appears in the material.
  26650. */
  26651. roughness: number;
  26652. /**
  26653. * In case of refraction, define the value of the index of refraction.
  26654. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26655. */
  26656. indexOfRefraction: number;
  26657. /**
  26658. * Invert the refraction texture alongside the y axis.
  26659. * It can be useful with procedural textures or probe for instance.
  26660. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26661. */
  26662. invertRefractionY: boolean;
  26663. /**
  26664. * Defines the alpha limits in alpha test mode.
  26665. */
  26666. alphaCutOff: number;
  26667. private _useLightmapAsShadowmap;
  26668. /**
  26669. * In case of light mapping, define whether the map contains light or shadow informations.
  26670. */
  26671. useLightmapAsShadowmap: boolean;
  26672. private _diffuseFresnelParameters;
  26673. /**
  26674. * Define the diffuse fresnel parameters of the material.
  26675. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26676. */
  26677. diffuseFresnelParameters: FresnelParameters;
  26678. private _opacityFresnelParameters;
  26679. /**
  26680. * Define the opacity fresnel parameters of the material.
  26681. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26682. */
  26683. opacityFresnelParameters: FresnelParameters;
  26684. private _reflectionFresnelParameters;
  26685. /**
  26686. * Define the reflection fresnel parameters of the material.
  26687. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26688. */
  26689. reflectionFresnelParameters: FresnelParameters;
  26690. private _refractionFresnelParameters;
  26691. /**
  26692. * Define the refraction fresnel parameters of the material.
  26693. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26694. */
  26695. refractionFresnelParameters: FresnelParameters;
  26696. private _emissiveFresnelParameters;
  26697. /**
  26698. * Define the emissive fresnel parameters of the material.
  26699. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26700. */
  26701. emissiveFresnelParameters: FresnelParameters;
  26702. private _useReflectionFresnelFromSpecular;
  26703. /**
  26704. * If true automatically deducts the fresnels values from the material specularity.
  26705. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26706. */
  26707. useReflectionFresnelFromSpecular: boolean;
  26708. private _useGlossinessFromSpecularMapAlpha;
  26709. /**
  26710. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26711. */
  26712. useGlossinessFromSpecularMapAlpha: boolean;
  26713. private _maxSimultaneousLights;
  26714. /**
  26715. * Defines the maximum number of lights that can be used in the material
  26716. */
  26717. maxSimultaneousLights: number;
  26718. private _invertNormalMapX;
  26719. /**
  26720. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26721. */
  26722. invertNormalMapX: boolean;
  26723. private _invertNormalMapY;
  26724. /**
  26725. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26726. */
  26727. invertNormalMapY: boolean;
  26728. private _twoSidedLighting;
  26729. /**
  26730. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26731. */
  26732. twoSidedLighting: boolean;
  26733. /**
  26734. * Default configuration related to image processing available in the standard Material.
  26735. */
  26736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26737. /**
  26738. * Gets the image processing configuration used either in this material.
  26739. */
  26740. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26741. /**
  26742. * Sets the Default image processing configuration used either in the this material.
  26743. *
  26744. * If sets to null, the scene one is in use.
  26745. */
  26746. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26747. /**
  26748. * Keep track of the image processing observer to allow dispose and replace.
  26749. */
  26750. private _imageProcessingObserver;
  26751. /**
  26752. * Attaches a new image processing configuration to the Standard Material.
  26753. * @param configuration
  26754. */
  26755. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26756. /**
  26757. * Gets wether the color curves effect is enabled.
  26758. */
  26759. get cameraColorCurvesEnabled(): boolean;
  26760. /**
  26761. * Sets wether the color curves effect is enabled.
  26762. */
  26763. set cameraColorCurvesEnabled(value: boolean);
  26764. /**
  26765. * Gets wether the color grading effect is enabled.
  26766. */
  26767. get cameraColorGradingEnabled(): boolean;
  26768. /**
  26769. * Gets wether the color grading effect is enabled.
  26770. */
  26771. set cameraColorGradingEnabled(value: boolean);
  26772. /**
  26773. * Gets wether tonemapping is enabled or not.
  26774. */
  26775. get cameraToneMappingEnabled(): boolean;
  26776. /**
  26777. * Sets wether tonemapping is enabled or not
  26778. */
  26779. set cameraToneMappingEnabled(value: boolean);
  26780. /**
  26781. * The camera exposure used on this material.
  26782. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26783. * This corresponds to a photographic exposure.
  26784. */
  26785. get cameraExposure(): number;
  26786. /**
  26787. * The camera exposure used on this material.
  26788. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26789. * This corresponds to a photographic exposure.
  26790. */
  26791. set cameraExposure(value: number);
  26792. /**
  26793. * Gets The camera contrast used on this material.
  26794. */
  26795. get cameraContrast(): number;
  26796. /**
  26797. * Sets The camera contrast used on this material.
  26798. */
  26799. set cameraContrast(value: number);
  26800. /**
  26801. * Gets the Color Grading 2D Lookup Texture.
  26802. */
  26803. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26804. /**
  26805. * Sets the Color Grading 2D Lookup Texture.
  26806. */
  26807. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26808. /**
  26809. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26810. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26811. * 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;
  26812. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26813. */
  26814. get cameraColorCurves(): Nullable<ColorCurves>;
  26815. /**
  26816. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26817. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26818. * 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;
  26819. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26820. */
  26821. set cameraColorCurves(value: Nullable<ColorCurves>);
  26822. /**
  26823. * Custom callback helping to override the default shader used in the material.
  26824. */
  26825. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26826. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26827. protected _worldViewProjectionMatrix: Matrix;
  26828. protected _globalAmbientColor: Color3;
  26829. protected _useLogarithmicDepth: boolean;
  26830. protected _rebuildInParallel: boolean;
  26831. /**
  26832. * Instantiates a new standard material.
  26833. * This is the default material used in Babylon. It is the best trade off between quality
  26834. * and performances.
  26835. * @see http://doc.babylonjs.com/babylon101/materials
  26836. * @param name Define the name of the material in the scene
  26837. * @param scene Define the scene the material belong to
  26838. */
  26839. constructor(name: string, scene: Scene);
  26840. /**
  26841. * Gets a boolean indicating that current material needs to register RTT
  26842. */
  26843. get hasRenderTargetTextures(): boolean;
  26844. /**
  26845. * Gets the current class name of the material e.g. "StandardMaterial"
  26846. * Mainly use in serialization.
  26847. * @returns the class name
  26848. */
  26849. getClassName(): string;
  26850. /**
  26851. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26852. * You can try switching to logarithmic depth.
  26853. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26854. */
  26855. get useLogarithmicDepth(): boolean;
  26856. set useLogarithmicDepth(value: boolean);
  26857. /**
  26858. * Specifies if the material will require alpha blending
  26859. * @returns a boolean specifying if alpha blending is needed
  26860. */
  26861. needAlphaBlending(): boolean;
  26862. /**
  26863. * Specifies if this material should be rendered in alpha test mode
  26864. * @returns a boolean specifying if an alpha test is needed.
  26865. */
  26866. needAlphaTesting(): boolean;
  26867. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26868. /**
  26869. * Get the texture used for alpha test purpose.
  26870. * @returns the diffuse texture in case of the standard material.
  26871. */
  26872. getAlphaTestTexture(): Nullable<BaseTexture>;
  26873. /**
  26874. * Get if the submesh is ready to be used and all its information available.
  26875. * Child classes can use it to update shaders
  26876. * @param mesh defines the mesh to check
  26877. * @param subMesh defines which submesh to check
  26878. * @param useInstances specifies that instances should be used
  26879. * @returns a boolean indicating that the submesh is ready or not
  26880. */
  26881. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26882. /**
  26883. * Builds the material UBO layouts.
  26884. * Used internally during the effect preparation.
  26885. */
  26886. buildUniformLayout(): void;
  26887. /**
  26888. * Unbinds the material from the mesh
  26889. */
  26890. unbind(): void;
  26891. /**
  26892. * Binds the submesh to this material by preparing the effect and shader to draw
  26893. * @param world defines the world transformation matrix
  26894. * @param mesh defines the mesh containing the submesh
  26895. * @param subMesh defines the submesh to bind the material to
  26896. */
  26897. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26898. /**
  26899. * Get the list of animatables in the material.
  26900. * @returns the list of animatables object used in the material
  26901. */
  26902. getAnimatables(): IAnimatable[];
  26903. /**
  26904. * Gets the active textures from the material
  26905. * @returns an array of textures
  26906. */
  26907. getActiveTextures(): BaseTexture[];
  26908. /**
  26909. * Specifies if the material uses a texture
  26910. * @param texture defines the texture to check against the material
  26911. * @returns a boolean specifying if the material uses the texture
  26912. */
  26913. hasTexture(texture: BaseTexture): boolean;
  26914. /**
  26915. * Disposes the material
  26916. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26917. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26918. */
  26919. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26920. /**
  26921. * Makes a duplicate of the material, and gives it a new name
  26922. * @param name defines the new name for the duplicated material
  26923. * @returns the cloned material
  26924. */
  26925. clone(name: string): StandardMaterial;
  26926. /**
  26927. * Serializes this material in a JSON representation
  26928. * @returns the serialized material object
  26929. */
  26930. serialize(): any;
  26931. /**
  26932. * Creates a standard material from parsed material data
  26933. * @param source defines the JSON representation of the material
  26934. * @param scene defines the hosting scene
  26935. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26936. * @returns a new standard material
  26937. */
  26938. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26939. /**
  26940. * Are diffuse textures enabled in the application.
  26941. */
  26942. static get DiffuseTextureEnabled(): boolean;
  26943. static set DiffuseTextureEnabled(value: boolean);
  26944. /**
  26945. * Are ambient textures enabled in the application.
  26946. */
  26947. static get AmbientTextureEnabled(): boolean;
  26948. static set AmbientTextureEnabled(value: boolean);
  26949. /**
  26950. * Are opacity textures enabled in the application.
  26951. */
  26952. static get OpacityTextureEnabled(): boolean;
  26953. static set OpacityTextureEnabled(value: boolean);
  26954. /**
  26955. * Are reflection textures enabled in the application.
  26956. */
  26957. static get ReflectionTextureEnabled(): boolean;
  26958. static set ReflectionTextureEnabled(value: boolean);
  26959. /**
  26960. * Are emissive textures enabled in the application.
  26961. */
  26962. static get EmissiveTextureEnabled(): boolean;
  26963. static set EmissiveTextureEnabled(value: boolean);
  26964. /**
  26965. * Are specular textures enabled in the application.
  26966. */
  26967. static get SpecularTextureEnabled(): boolean;
  26968. static set SpecularTextureEnabled(value: boolean);
  26969. /**
  26970. * Are bump textures enabled in the application.
  26971. */
  26972. static get BumpTextureEnabled(): boolean;
  26973. static set BumpTextureEnabled(value: boolean);
  26974. /**
  26975. * Are lightmap textures enabled in the application.
  26976. */
  26977. static get LightmapTextureEnabled(): boolean;
  26978. static set LightmapTextureEnabled(value: boolean);
  26979. /**
  26980. * Are refraction textures enabled in the application.
  26981. */
  26982. static get RefractionTextureEnabled(): boolean;
  26983. static set RefractionTextureEnabled(value: boolean);
  26984. /**
  26985. * Are color grading textures enabled in the application.
  26986. */
  26987. static get ColorGradingTextureEnabled(): boolean;
  26988. static set ColorGradingTextureEnabled(value: boolean);
  26989. /**
  26990. * Are fresnels enabled in the application.
  26991. */
  26992. static get FresnelEnabled(): boolean;
  26993. static set FresnelEnabled(value: boolean);
  26994. }
  26995. }
  26996. declare module BABYLON {
  26997. /**
  26998. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26999. *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.
  27000. * The SPS is also a particle system. It provides some methods to manage the particles.
  27001. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27002. *
  27003. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27004. */
  27005. export class SolidParticleSystem implements IDisposable {
  27006. /**
  27007. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27008. * Example : var p = SPS.particles[i];
  27009. */
  27010. particles: SolidParticle[];
  27011. /**
  27012. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27013. */
  27014. nbParticles: number;
  27015. /**
  27016. * If the particles must ever face the camera (default false). Useful for planar particles.
  27017. */
  27018. billboard: boolean;
  27019. /**
  27020. * Recompute normals when adding a shape
  27021. */
  27022. recomputeNormals: boolean;
  27023. /**
  27024. * This a counter ofr your own usage. It's not set by any SPS functions.
  27025. */
  27026. counter: number;
  27027. /**
  27028. * The SPS name. This name is also given to the underlying mesh.
  27029. */
  27030. name: string;
  27031. /**
  27032. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27033. */
  27034. mesh: Mesh;
  27035. /**
  27036. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27037. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27038. */
  27039. vars: any;
  27040. /**
  27041. * This array is populated when the SPS is set as 'pickable'.
  27042. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27043. * Each element of this array is an object `{idx: int, faceId: int}`.
  27044. * `idx` is the picked particle index in the `SPS.particles` array
  27045. * `faceId` is the picked face index counted within this particle.
  27046. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27047. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27048. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27049. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27050. */
  27051. pickedParticles: {
  27052. idx: number;
  27053. faceId: number;
  27054. }[];
  27055. /**
  27056. * This array is populated when the SPS is set as 'pickable'
  27057. * Each key of this array is a submesh index.
  27058. * Each element of this array is a second array defined like this :
  27059. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27060. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27061. * `idx` is the picked particle index in the `SPS.particles` array
  27062. * `faceId` is the picked face index counted within this particle.
  27063. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27064. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27065. */
  27066. pickedBySubMesh: {
  27067. idx: number;
  27068. faceId: number;
  27069. }[][];
  27070. /**
  27071. * This array is populated when `enableDepthSort` is set to true.
  27072. * Each element of this array is an instance of the class DepthSortedParticle.
  27073. */
  27074. depthSortedParticles: DepthSortedParticle[];
  27075. /**
  27076. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27077. * @hidden
  27078. */
  27079. _bSphereOnly: boolean;
  27080. /**
  27081. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27082. * @hidden
  27083. */
  27084. _bSphereRadiusFactor: number;
  27085. private _scene;
  27086. private _positions;
  27087. private _indices;
  27088. private _normals;
  27089. private _colors;
  27090. private _uvs;
  27091. private _indices32;
  27092. private _positions32;
  27093. private _normals32;
  27094. private _fixedNormal32;
  27095. private _colors32;
  27096. private _uvs32;
  27097. private _index;
  27098. private _updatable;
  27099. private _pickable;
  27100. private _isVisibilityBoxLocked;
  27101. private _alwaysVisible;
  27102. private _depthSort;
  27103. private _expandable;
  27104. private _shapeCounter;
  27105. private _copy;
  27106. private _color;
  27107. private _computeParticleColor;
  27108. private _computeParticleTexture;
  27109. private _computeParticleRotation;
  27110. private _computeParticleVertex;
  27111. private _computeBoundingBox;
  27112. private _depthSortParticles;
  27113. private _camera;
  27114. private _mustUnrotateFixedNormals;
  27115. private _particlesIntersect;
  27116. private _needs32Bits;
  27117. private _isNotBuilt;
  27118. private _lastParticleId;
  27119. private _idxOfId;
  27120. private _multimaterialEnabled;
  27121. private _useModelMaterial;
  27122. private _indicesByMaterial;
  27123. private _materialIndexes;
  27124. private _depthSortFunction;
  27125. private _materialSortFunction;
  27126. private _materials;
  27127. private _multimaterial;
  27128. private _materialIndexesById;
  27129. private _defaultMaterial;
  27130. private _autoUpdateSubMeshes;
  27131. /**
  27132. * Creates a SPS (Solid Particle System) object.
  27133. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27134. * @param scene (Scene) is the scene in which the SPS is added.
  27135. * @param options defines the options of the sps e.g.
  27136. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27137. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27138. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27139. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27140. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27141. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27142. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27143. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27144. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27145. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27146. */
  27147. constructor(name: string, scene: Scene, options?: {
  27148. updatable?: boolean;
  27149. isPickable?: boolean;
  27150. enableDepthSort?: boolean;
  27151. particleIntersection?: boolean;
  27152. boundingSphereOnly?: boolean;
  27153. bSphereRadiusFactor?: number;
  27154. expandable?: boolean;
  27155. useModelMaterial?: boolean;
  27156. enableMultiMaterial?: boolean;
  27157. });
  27158. /**
  27159. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27160. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27161. * @returns the created mesh
  27162. */
  27163. buildMesh(): Mesh;
  27164. /**
  27165. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27166. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27167. * Thus the particles generated from `digest()` have their property `position` set yet.
  27168. * @param mesh ( Mesh ) is the mesh to be digested
  27169. * @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
  27170. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27171. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27172. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27173. * @returns the current SPS
  27174. */
  27175. digest(mesh: Mesh, options?: {
  27176. facetNb?: number;
  27177. number?: number;
  27178. delta?: number;
  27179. storage?: [];
  27180. }): SolidParticleSystem;
  27181. /**
  27182. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27183. * @hidden
  27184. */
  27185. private _unrotateFixedNormals;
  27186. /**
  27187. * Resets the temporary working copy particle
  27188. * @hidden
  27189. */
  27190. private _resetCopy;
  27191. /**
  27192. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27193. * @param p the current index in the positions array to be updated
  27194. * @param ind the current index in the indices array
  27195. * @param shape a Vector3 array, the shape geometry
  27196. * @param positions the positions array to be updated
  27197. * @param meshInd the shape indices array
  27198. * @param indices the indices array to be updated
  27199. * @param meshUV the shape uv array
  27200. * @param uvs the uv array to be updated
  27201. * @param meshCol the shape color array
  27202. * @param colors the color array to be updated
  27203. * @param meshNor the shape normals array
  27204. * @param normals the normals array to be updated
  27205. * @param idx the particle index
  27206. * @param idxInShape the particle index in its shape
  27207. * @param options the addShape() method passed options
  27208. * @model the particle model
  27209. * @hidden
  27210. */
  27211. private _meshBuilder;
  27212. /**
  27213. * Returns a shape Vector3 array from positions float array
  27214. * @param positions float array
  27215. * @returns a vector3 array
  27216. * @hidden
  27217. */
  27218. private _posToShape;
  27219. /**
  27220. * Returns a shapeUV array from a float uvs (array deep copy)
  27221. * @param uvs as a float array
  27222. * @returns a shapeUV array
  27223. * @hidden
  27224. */
  27225. private _uvsToShapeUV;
  27226. /**
  27227. * Adds a new particle object in the particles array
  27228. * @param idx particle index in particles array
  27229. * @param id particle id
  27230. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27231. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27232. * @param model particle ModelShape object
  27233. * @param shapeId model shape identifier
  27234. * @param idxInShape index of the particle in the current model
  27235. * @param bInfo model bounding info object
  27236. * @param storage target storage array, if any
  27237. * @hidden
  27238. */
  27239. private _addParticle;
  27240. /**
  27241. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27242. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27243. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27244. * @param nb (positive integer) the number of particles to be created from this model
  27245. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27246. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27247. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27248. * @returns the number of shapes in the system
  27249. */
  27250. addShape(mesh: Mesh, nb: number, options?: {
  27251. positionFunction?: any;
  27252. vertexFunction?: any;
  27253. storage?: [];
  27254. }): number;
  27255. /**
  27256. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27257. * @hidden
  27258. */
  27259. private _rebuildParticle;
  27260. /**
  27261. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27262. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27263. * @returns the SPS.
  27264. */
  27265. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27266. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27267. * Returns an array with the removed particles.
  27268. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27269. * The SPS can't be empty so at least one particle needs to remain in place.
  27270. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27271. * @param start index of the first particle to remove
  27272. * @param end index of the last particle to remove (included)
  27273. * @returns an array populated with the removed particles
  27274. */
  27275. removeParticles(start: number, end: number): SolidParticle[];
  27276. /**
  27277. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27278. * @param solidParticleArray an array populated with Solid Particles objects
  27279. * @returns the SPS
  27280. */
  27281. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27282. /**
  27283. * Creates a new particle and modifies the SPS mesh geometry :
  27284. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27285. * - calls _addParticle() to populate the particle array
  27286. * factorized code from addShape() and insertParticlesFromArray()
  27287. * @param idx particle index in the particles array
  27288. * @param i particle index in its shape
  27289. * @param modelShape particle ModelShape object
  27290. * @param shape shape vertex array
  27291. * @param meshInd shape indices array
  27292. * @param meshUV shape uv array
  27293. * @param meshCol shape color array
  27294. * @param meshNor shape normals array
  27295. * @param bbInfo shape bounding info
  27296. * @param storage target particle storage
  27297. * @options addShape() passed options
  27298. * @hidden
  27299. */
  27300. private _insertNewParticle;
  27301. /**
  27302. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27303. * This method calls `updateParticle()` for each particle of the SPS.
  27304. * For an animated SPS, it is usually called within the render loop.
  27305. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27306. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27307. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27308. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27309. * @returns the SPS.
  27310. */
  27311. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27312. /**
  27313. * Disposes the SPS.
  27314. */
  27315. dispose(): void;
  27316. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27317. * idx is the particle index in the SPS
  27318. * faceId is the picked face index counted within this particle.
  27319. * Returns null if the pickInfo can't identify a picked particle.
  27320. * @param pickingInfo (PickingInfo object)
  27321. * @returns {idx: number, faceId: number} or null
  27322. */
  27323. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27324. idx: number;
  27325. faceId: number;
  27326. }>;
  27327. /**
  27328. * Returns a SolidParticle object from its identifier : particle.id
  27329. * @param id (integer) the particle Id
  27330. * @returns the searched particle or null if not found in the SPS.
  27331. */
  27332. getParticleById(id: number): Nullable<SolidParticle>;
  27333. /**
  27334. * Returns a new array populated with the particles having the passed shapeId.
  27335. * @param shapeId (integer) the shape identifier
  27336. * @returns a new solid particle array
  27337. */
  27338. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27339. /**
  27340. * Populates the passed array "ref" with the particles having the passed shapeId.
  27341. * @param shapeId the shape identifier
  27342. * @returns the SPS
  27343. * @param ref
  27344. */
  27345. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27346. /**
  27347. * Computes the required SubMeshes according the materials assigned to the particles.
  27348. * @returns the solid particle system.
  27349. * Does nothing if called before the SPS mesh is built.
  27350. */
  27351. computeSubMeshes(): SolidParticleSystem;
  27352. /**
  27353. * Sorts the solid particles by material when MultiMaterial is enabled.
  27354. * Updates the indices32 array.
  27355. * Updates the indicesByMaterial array.
  27356. * Updates the mesh indices array.
  27357. * @returns the SPS
  27358. * @hidden
  27359. */
  27360. private _sortParticlesByMaterial;
  27361. /**
  27362. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27363. * @hidden
  27364. */
  27365. private _setMaterialIndexesById;
  27366. /**
  27367. * Returns an array with unique values of Materials from the passed array
  27368. * @param array the material array to be checked and filtered
  27369. * @hidden
  27370. */
  27371. private _filterUniqueMaterialId;
  27372. /**
  27373. * Sets a new Standard Material as _defaultMaterial if not already set.
  27374. * @hidden
  27375. */
  27376. private _setDefaultMaterial;
  27377. /**
  27378. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27379. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27380. * @returns the SPS.
  27381. */
  27382. refreshVisibleSize(): SolidParticleSystem;
  27383. /**
  27384. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27385. * @param size the size (float) of the visibility box
  27386. * note : this doesn't lock the SPS mesh bounding box.
  27387. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27388. */
  27389. setVisibilityBox(size: number): void;
  27390. /**
  27391. * Gets whether the SPS as always visible or not
  27392. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27393. */
  27394. get isAlwaysVisible(): boolean;
  27395. /**
  27396. * Sets the SPS as always visible or not
  27397. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27398. */
  27399. set isAlwaysVisible(val: boolean);
  27400. /**
  27401. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27402. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27403. */
  27404. set isVisibilityBoxLocked(val: boolean);
  27405. /**
  27406. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27408. */
  27409. get isVisibilityBoxLocked(): boolean;
  27410. /**
  27411. * Tells to `setParticles()` to compute the particle rotations or not.
  27412. * Default value : true. The SPS is faster when it's set to false.
  27413. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27414. */
  27415. set computeParticleRotation(val: boolean);
  27416. /**
  27417. * Tells to `setParticles()` to compute the particle colors or not.
  27418. * Default value : true. The SPS is faster when it's set to false.
  27419. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27420. */
  27421. set computeParticleColor(val: boolean);
  27422. set computeParticleTexture(val: boolean);
  27423. /**
  27424. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27425. * Default value : false. The SPS is faster when it's set to false.
  27426. * Note : the particle custom vertex positions aren't stored values.
  27427. */
  27428. set computeParticleVertex(val: boolean);
  27429. /**
  27430. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27431. */
  27432. set computeBoundingBox(val: boolean);
  27433. /**
  27434. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27435. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27436. * Default : `true`
  27437. */
  27438. set depthSortParticles(val: boolean);
  27439. /**
  27440. * Gets if `setParticles()` computes the particle rotations or not.
  27441. * Default value : true. The SPS is faster when it's set to false.
  27442. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27443. */
  27444. get computeParticleRotation(): boolean;
  27445. /**
  27446. * Gets if `setParticles()` computes the particle colors or not.
  27447. * Default value : true. The SPS is faster when it's set to false.
  27448. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27449. */
  27450. get computeParticleColor(): boolean;
  27451. /**
  27452. * Gets if `setParticles()` computes the particle textures or not.
  27453. * Default value : true. The SPS is faster when it's set to false.
  27454. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27455. */
  27456. get computeParticleTexture(): boolean;
  27457. /**
  27458. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27459. * Default value : false. The SPS is faster when it's set to false.
  27460. * Note : the particle custom vertex positions aren't stored values.
  27461. */
  27462. get computeParticleVertex(): boolean;
  27463. /**
  27464. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27465. */
  27466. get computeBoundingBox(): boolean;
  27467. /**
  27468. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27469. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27470. * Default : `true`
  27471. */
  27472. get depthSortParticles(): boolean;
  27473. /**
  27474. * Gets if the SPS is created as expandable at construction time.
  27475. * Default : `false`
  27476. */
  27477. get expandable(): boolean;
  27478. /**
  27479. * Gets if the SPS supports the Multi Materials
  27480. */
  27481. get multimaterialEnabled(): boolean;
  27482. /**
  27483. * Gets if the SPS uses the model materials for its own multimaterial.
  27484. */
  27485. get useModelMaterial(): boolean;
  27486. /**
  27487. * The SPS used material array.
  27488. */
  27489. get materials(): Material[];
  27490. /**
  27491. * Sets the SPS MultiMaterial from the passed materials.
  27492. * Note : the passed array is internally copied and not used then by reference.
  27493. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27494. */
  27495. setMultiMaterial(materials: Material[]): void;
  27496. /**
  27497. * The SPS computed multimaterial object
  27498. */
  27499. get multimaterial(): MultiMaterial;
  27500. set multimaterial(mm: MultiMaterial);
  27501. /**
  27502. * If the subMeshes must be updated on the next call to setParticles()
  27503. */
  27504. get autoUpdateSubMeshes(): boolean;
  27505. set autoUpdateSubMeshes(val: boolean);
  27506. /**
  27507. * This function does nothing. It may be overwritten to set all the particle first values.
  27508. * The SPS doesn't call this function, you may have to call it by your own.
  27509. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27510. */
  27511. initParticles(): void;
  27512. /**
  27513. * This function does nothing. It may be overwritten to recycle a particle.
  27514. * The SPS doesn't call this function, you may have to call it by your own.
  27515. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27516. * @param particle The particle to recycle
  27517. * @returns the recycled particle
  27518. */
  27519. recycleParticle(particle: SolidParticle): SolidParticle;
  27520. /**
  27521. * Updates a particle : this function should be overwritten by the user.
  27522. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27523. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27524. * @example : just set a particle position or velocity and recycle conditions
  27525. * @param particle The particle to update
  27526. * @returns the updated particle
  27527. */
  27528. updateParticle(particle: SolidParticle): SolidParticle;
  27529. /**
  27530. * Updates a vertex of a particle : it can be overwritten by the user.
  27531. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27532. * @param particle the current particle
  27533. * @param vertex the current index of the current particle
  27534. * @param pt the index of the current vertex in the particle shape
  27535. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27536. * @example : just set a vertex particle position
  27537. * @returns the updated vertex
  27538. */
  27539. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27540. /**
  27541. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27542. * This does nothing and may be overwritten by the user.
  27543. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27544. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27545. * @param update the boolean update value actually passed to setParticles()
  27546. */
  27547. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27548. /**
  27549. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27550. * This will be passed three parameters.
  27551. * This does nothing and may be overwritten by the user.
  27552. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27553. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27554. * @param update the boolean update value actually passed to setParticles()
  27555. */
  27556. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27557. }
  27558. }
  27559. declare module BABYLON {
  27560. /**
  27561. * Represents one particle of a solid particle system.
  27562. */
  27563. export class SolidParticle {
  27564. /**
  27565. * particle global index
  27566. */
  27567. idx: number;
  27568. /**
  27569. * particle identifier
  27570. */
  27571. id: number;
  27572. /**
  27573. * The color of the particle
  27574. */
  27575. color: Nullable<Color4>;
  27576. /**
  27577. * The world space position of the particle.
  27578. */
  27579. position: Vector3;
  27580. /**
  27581. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27582. */
  27583. rotation: Vector3;
  27584. /**
  27585. * The world space rotation quaternion of the particle.
  27586. */
  27587. rotationQuaternion: Nullable<Quaternion>;
  27588. /**
  27589. * The scaling of the particle.
  27590. */
  27591. scaling: Vector3;
  27592. /**
  27593. * The uvs of the particle.
  27594. */
  27595. uvs: Vector4;
  27596. /**
  27597. * The current speed of the particle.
  27598. */
  27599. velocity: Vector3;
  27600. /**
  27601. * The pivot point in the particle local space.
  27602. */
  27603. pivot: Vector3;
  27604. /**
  27605. * Must the particle be translated from its pivot point in its local space ?
  27606. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27607. * Default : false
  27608. */
  27609. translateFromPivot: boolean;
  27610. /**
  27611. * Is the particle active or not ?
  27612. */
  27613. alive: boolean;
  27614. /**
  27615. * Is the particle visible or not ?
  27616. */
  27617. isVisible: boolean;
  27618. /**
  27619. * Index of this particle in the global "positions" array (Internal use)
  27620. * @hidden
  27621. */
  27622. _pos: number;
  27623. /**
  27624. * @hidden Index of this particle in the global "indices" array (Internal use)
  27625. */
  27626. _ind: number;
  27627. /**
  27628. * @hidden ModelShape of this particle (Internal use)
  27629. */
  27630. _model: ModelShape;
  27631. /**
  27632. * ModelShape id of this particle
  27633. */
  27634. shapeId: number;
  27635. /**
  27636. * Index of the particle in its shape id
  27637. */
  27638. idxInShape: number;
  27639. /**
  27640. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27641. */
  27642. _modelBoundingInfo: BoundingInfo;
  27643. /**
  27644. * @hidden Particle BoundingInfo object (Internal use)
  27645. */
  27646. _boundingInfo: BoundingInfo;
  27647. /**
  27648. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27649. */
  27650. _sps: SolidParticleSystem;
  27651. /**
  27652. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27653. */
  27654. _stillInvisible: boolean;
  27655. /**
  27656. * @hidden Last computed particle rotation matrix
  27657. */
  27658. _rotationMatrix: number[];
  27659. /**
  27660. * Parent particle Id, if any.
  27661. * Default null.
  27662. */
  27663. parentId: Nullable<number>;
  27664. /**
  27665. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27666. */
  27667. materialIndex: Nullable<number>;
  27668. /**
  27669. * Custom object or properties.
  27670. */
  27671. props: Nullable<any>;
  27672. /**
  27673. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27674. * The possible values are :
  27675. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27676. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27677. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27678. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27679. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27680. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27681. * */
  27682. cullingStrategy: number;
  27683. /**
  27684. * @hidden Internal global position in the SPS.
  27685. */
  27686. _globalPosition: Vector3;
  27687. /**
  27688. * Creates a Solid Particle object.
  27689. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27690. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27691. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27692. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27693. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27694. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27695. * @param shapeId (integer) is the model shape identifier in the SPS.
  27696. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27697. * @param sps defines the sps it is associated to
  27698. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27699. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27700. */
  27701. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27702. /**
  27703. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27704. * @param target the particle target
  27705. * @returns the current particle
  27706. */
  27707. copyToRef(target: SolidParticle): SolidParticle;
  27708. /**
  27709. * Legacy support, changed scale to scaling
  27710. */
  27711. get scale(): Vector3;
  27712. /**
  27713. * Legacy support, changed scale to scaling
  27714. */
  27715. set scale(scale: Vector3);
  27716. /**
  27717. * Legacy support, changed quaternion to rotationQuaternion
  27718. */
  27719. get quaternion(): Nullable<Quaternion>;
  27720. /**
  27721. * Legacy support, changed quaternion to rotationQuaternion
  27722. */
  27723. set quaternion(q: Nullable<Quaternion>);
  27724. /**
  27725. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27726. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27727. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27728. * @returns true if it intersects
  27729. */
  27730. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27731. /**
  27732. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27733. * A particle is in the frustum if its bounding box intersects the frustum
  27734. * @param frustumPlanes defines the frustum to test
  27735. * @returns true if the particle is in the frustum planes
  27736. */
  27737. isInFrustum(frustumPlanes: Plane[]): boolean;
  27738. /**
  27739. * get the rotation matrix of the particle
  27740. * @hidden
  27741. */
  27742. getRotationMatrix(m: Matrix): void;
  27743. }
  27744. /**
  27745. * Represents the shape of the model used by one particle of a solid particle system.
  27746. * SPS internal tool, don't use it manually.
  27747. */
  27748. export class ModelShape {
  27749. /**
  27750. * The shape id
  27751. * @hidden
  27752. */
  27753. shapeID: number;
  27754. /**
  27755. * flat array of model positions (internal use)
  27756. * @hidden
  27757. */
  27758. _shape: Vector3[];
  27759. /**
  27760. * flat array of model UVs (internal use)
  27761. * @hidden
  27762. */
  27763. _shapeUV: number[];
  27764. /**
  27765. * color array of the model
  27766. * @hidden
  27767. */
  27768. _shapeColors: number[];
  27769. /**
  27770. * indices array of the model
  27771. * @hidden
  27772. */
  27773. _indices: number[];
  27774. /**
  27775. * normals array of the model
  27776. * @hidden
  27777. */
  27778. _normals: number[];
  27779. /**
  27780. * length of the shape in the model indices array (internal use)
  27781. * @hidden
  27782. */
  27783. _indicesLength: number;
  27784. /**
  27785. * Custom position function (internal use)
  27786. * @hidden
  27787. */
  27788. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27789. /**
  27790. * Custom vertex function (internal use)
  27791. * @hidden
  27792. */
  27793. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27794. /**
  27795. * Model material (internal use)
  27796. * @hidden
  27797. */
  27798. _material: Nullable<Material>;
  27799. /**
  27800. * 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.
  27801. * SPS internal tool, don't use it manually.
  27802. * @hidden
  27803. */
  27804. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  27805. }
  27806. /**
  27807. * Represents a Depth Sorted Particle in the solid particle system.
  27808. * @hidden
  27809. */
  27810. export class DepthSortedParticle {
  27811. /**
  27812. * Particle index
  27813. */
  27814. idx: number;
  27815. /**
  27816. * Index of the particle in the "indices" array
  27817. */
  27818. ind: number;
  27819. /**
  27820. * Length of the particle shape in the "indices" array
  27821. */
  27822. indicesLength: number;
  27823. /**
  27824. * Squared distance from the particle to the camera
  27825. */
  27826. sqDistance: number;
  27827. /**
  27828. * Material index when used with MultiMaterials
  27829. */
  27830. materialIndex: number;
  27831. /**
  27832. * Creates a new sorted particle
  27833. * @param materialIndex
  27834. */
  27835. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  27836. }
  27837. }
  27838. declare module BABYLON {
  27839. /**
  27840. * @hidden
  27841. */
  27842. export class _MeshCollisionData {
  27843. _checkCollisions: boolean;
  27844. _collisionMask: number;
  27845. _collisionGroup: number;
  27846. _collider: Nullable<Collider>;
  27847. _oldPositionForCollisions: Vector3;
  27848. _diffPositionForCollisions: Vector3;
  27849. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27850. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27851. }
  27852. }
  27853. declare module BABYLON {
  27854. /** @hidden */
  27855. class _FacetDataStorage {
  27856. facetPositions: Vector3[];
  27857. facetNormals: Vector3[];
  27858. facetPartitioning: number[][];
  27859. facetNb: number;
  27860. partitioningSubdivisions: number;
  27861. partitioningBBoxRatio: number;
  27862. facetDataEnabled: boolean;
  27863. facetParameters: any;
  27864. bbSize: Vector3;
  27865. subDiv: {
  27866. max: number;
  27867. X: number;
  27868. Y: number;
  27869. Z: number;
  27870. };
  27871. facetDepthSort: boolean;
  27872. facetDepthSortEnabled: boolean;
  27873. depthSortedIndices: IndicesArray;
  27874. depthSortedFacets: {
  27875. ind: number;
  27876. sqDistance: number;
  27877. }[];
  27878. facetDepthSortFunction: (f1: {
  27879. ind: number;
  27880. sqDistance: number;
  27881. }, f2: {
  27882. ind: number;
  27883. sqDistance: number;
  27884. }) => number;
  27885. facetDepthSortFrom: Vector3;
  27886. facetDepthSortOrigin: Vector3;
  27887. invertedMatrix: Matrix;
  27888. }
  27889. /**
  27890. * @hidden
  27891. **/
  27892. class _InternalAbstractMeshDataInfo {
  27893. _hasVertexAlpha: boolean;
  27894. _useVertexColors: boolean;
  27895. _numBoneInfluencers: number;
  27896. _applyFog: boolean;
  27897. _receiveShadows: boolean;
  27898. _facetData: _FacetDataStorage;
  27899. _visibility: number;
  27900. _skeleton: Nullable<Skeleton>;
  27901. _layerMask: number;
  27902. _computeBonesUsingShaders: boolean;
  27903. _isActive: boolean;
  27904. _onlyForInstances: boolean;
  27905. _isActiveIntermediate: boolean;
  27906. _onlyForInstancesIntermediate: boolean;
  27907. _actAsRegularMesh: boolean;
  27908. }
  27909. /**
  27910. * Class used to store all common mesh properties
  27911. */
  27912. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27913. /** No occlusion */
  27914. static OCCLUSION_TYPE_NONE: number;
  27915. /** Occlusion set to optimisitic */
  27916. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27917. /** Occlusion set to strict */
  27918. static OCCLUSION_TYPE_STRICT: number;
  27919. /** Use an accurante occlusion algorithm */
  27920. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27921. /** Use a conservative occlusion algorithm */
  27922. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27923. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27924. * Test order :
  27925. * Is the bounding sphere outside the frustum ?
  27926. * If not, are the bounding box vertices outside the frustum ?
  27927. * It not, then the cullable object is in the frustum.
  27928. */
  27929. static readonly CULLINGSTRATEGY_STANDARD: number;
  27930. /** Culling strategy : Bounding Sphere Only.
  27931. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27932. * It's also less accurate than the standard because some not visible objects can still be selected.
  27933. * Test : is the bounding sphere outside the frustum ?
  27934. * If not, then the cullable object is in the frustum.
  27935. */
  27936. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27937. /** Culling strategy : Optimistic Inclusion.
  27938. * This in an inclusion test first, then the standard exclusion test.
  27939. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27940. * 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.
  27941. * Anyway, it's as accurate as the standard strategy.
  27942. * Test :
  27943. * Is the cullable object bounding sphere center in the frustum ?
  27944. * If not, apply the default culling strategy.
  27945. */
  27946. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27947. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27948. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27949. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27950. * 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.
  27951. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27952. * Test :
  27953. * Is the cullable object bounding sphere center in the frustum ?
  27954. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27955. */
  27956. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27957. /**
  27958. * No billboard
  27959. */
  27960. static get BILLBOARDMODE_NONE(): number;
  27961. /** Billboard on X axis */
  27962. static get BILLBOARDMODE_X(): number;
  27963. /** Billboard on Y axis */
  27964. static get BILLBOARDMODE_Y(): number;
  27965. /** Billboard on Z axis */
  27966. static get BILLBOARDMODE_Z(): number;
  27967. /** Billboard on all axes */
  27968. static get BILLBOARDMODE_ALL(): number;
  27969. /** Billboard on using position instead of orientation */
  27970. static get BILLBOARDMODE_USE_POSITION(): number;
  27971. /** @hidden */
  27972. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27973. /**
  27974. * The culling strategy to use to check whether the mesh must be rendered or not.
  27975. * This value can be changed at any time and will be used on the next render mesh selection.
  27976. * The possible values are :
  27977. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27978. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27979. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27980. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27981. * Please read each static variable documentation to get details about the culling process.
  27982. * */
  27983. cullingStrategy: number;
  27984. /**
  27985. * Gets the number of facets in the mesh
  27986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27987. */
  27988. get facetNb(): number;
  27989. /**
  27990. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27992. */
  27993. get partitioningSubdivisions(): number;
  27994. set partitioningSubdivisions(nb: number);
  27995. /**
  27996. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27997. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27999. */
  28000. get partitioningBBoxRatio(): number;
  28001. set partitioningBBoxRatio(ratio: number);
  28002. /**
  28003. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28004. * Works only for updatable meshes.
  28005. * Doesn't work with multi-materials
  28006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28007. */
  28008. get mustDepthSortFacets(): boolean;
  28009. set mustDepthSortFacets(sort: boolean);
  28010. /**
  28011. * The location (Vector3) where the facet depth sort must be computed from.
  28012. * By default, the active camera position.
  28013. * Used only when facet depth sort is enabled
  28014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28015. */
  28016. get facetDepthSortFrom(): Vector3;
  28017. set facetDepthSortFrom(location: Vector3);
  28018. /**
  28019. * gets a boolean indicating if facetData is enabled
  28020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28021. */
  28022. get isFacetDataEnabled(): boolean;
  28023. /** @hidden */
  28024. _updateNonUniformScalingState(value: boolean): boolean;
  28025. /**
  28026. * An event triggered when this mesh collides with another one
  28027. */
  28028. onCollideObservable: Observable<AbstractMesh>;
  28029. /** Set a function to call when this mesh collides with another one */
  28030. set onCollide(callback: () => void);
  28031. /**
  28032. * An event triggered when the collision's position changes
  28033. */
  28034. onCollisionPositionChangeObservable: Observable<Vector3>;
  28035. /** Set a function to call when the collision's position changes */
  28036. set onCollisionPositionChange(callback: () => void);
  28037. /**
  28038. * An event triggered when material is changed
  28039. */
  28040. onMaterialChangedObservable: Observable<AbstractMesh>;
  28041. /**
  28042. * Gets or sets the orientation for POV movement & rotation
  28043. */
  28044. definedFacingForward: boolean;
  28045. /** @hidden */
  28046. _occlusionQuery: Nullable<WebGLQuery>;
  28047. /** @hidden */
  28048. _renderingGroup: Nullable<RenderingGroup>;
  28049. /**
  28050. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28051. */
  28052. get visibility(): number;
  28053. /**
  28054. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28055. */
  28056. set visibility(value: number);
  28057. /** Gets or sets the alpha index used to sort transparent meshes
  28058. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28059. */
  28060. alphaIndex: number;
  28061. /**
  28062. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28063. */
  28064. isVisible: boolean;
  28065. /**
  28066. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28067. */
  28068. isPickable: boolean;
  28069. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28070. showSubMeshesBoundingBox: boolean;
  28071. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28073. */
  28074. isBlocker: boolean;
  28075. /**
  28076. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28077. */
  28078. enablePointerMoveEvents: boolean;
  28079. /**
  28080. * Specifies the rendering group id for this mesh (0 by default)
  28081. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28082. */
  28083. renderingGroupId: number;
  28084. private _material;
  28085. /** Gets or sets current material */
  28086. get material(): Nullable<Material>;
  28087. set material(value: Nullable<Material>);
  28088. /**
  28089. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28090. * @see http://doc.babylonjs.com/babylon101/shadows
  28091. */
  28092. get receiveShadows(): boolean;
  28093. set receiveShadows(value: boolean);
  28094. /** Defines color to use when rendering outline */
  28095. outlineColor: Color3;
  28096. /** Define width to use when rendering outline */
  28097. outlineWidth: number;
  28098. /** Defines color to use when rendering overlay */
  28099. overlayColor: Color3;
  28100. /** Defines alpha to use when rendering overlay */
  28101. overlayAlpha: number;
  28102. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28103. get hasVertexAlpha(): boolean;
  28104. set hasVertexAlpha(value: boolean);
  28105. /** 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) */
  28106. get useVertexColors(): boolean;
  28107. set useVertexColors(value: boolean);
  28108. /**
  28109. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28110. */
  28111. get computeBonesUsingShaders(): boolean;
  28112. set computeBonesUsingShaders(value: boolean);
  28113. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28114. get numBoneInfluencers(): number;
  28115. set numBoneInfluencers(value: number);
  28116. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28117. get applyFog(): boolean;
  28118. set applyFog(value: boolean);
  28119. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28120. useOctreeForRenderingSelection: boolean;
  28121. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28122. useOctreeForPicking: boolean;
  28123. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28124. useOctreeForCollisions: boolean;
  28125. /**
  28126. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28127. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28128. */
  28129. get layerMask(): number;
  28130. set layerMask(value: number);
  28131. /**
  28132. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28133. */
  28134. alwaysSelectAsActiveMesh: boolean;
  28135. /**
  28136. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28137. */
  28138. doNotSyncBoundingInfo: boolean;
  28139. /**
  28140. * Gets or sets the current action manager
  28141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28142. */
  28143. actionManager: Nullable<AbstractActionManager>;
  28144. private _meshCollisionData;
  28145. /**
  28146. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28148. */
  28149. ellipsoid: Vector3;
  28150. /**
  28151. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28153. */
  28154. ellipsoidOffset: Vector3;
  28155. /**
  28156. * Gets or sets a collision mask used to mask collisions (default is -1).
  28157. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28158. */
  28159. get collisionMask(): number;
  28160. set collisionMask(mask: number);
  28161. /**
  28162. * Gets or sets the current collision group mask (-1 by default).
  28163. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28164. */
  28165. get collisionGroup(): number;
  28166. set collisionGroup(mask: number);
  28167. /**
  28168. * Defines edge width used when edgesRenderer is enabled
  28169. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28170. */
  28171. edgesWidth: number;
  28172. /**
  28173. * Defines edge color used when edgesRenderer is enabled
  28174. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28175. */
  28176. edgesColor: Color4;
  28177. /** @hidden */
  28178. _edgesRenderer: Nullable<IEdgesRenderer>;
  28179. /** @hidden */
  28180. _masterMesh: Nullable<AbstractMesh>;
  28181. /** @hidden */
  28182. _boundingInfo: Nullable<BoundingInfo>;
  28183. /** @hidden */
  28184. _renderId: number;
  28185. /**
  28186. * Gets or sets the list of subMeshes
  28187. * @see http://doc.babylonjs.com/how_to/multi_materials
  28188. */
  28189. subMeshes: SubMesh[];
  28190. /** @hidden */
  28191. _intersectionsInProgress: AbstractMesh[];
  28192. /** @hidden */
  28193. _unIndexed: boolean;
  28194. /** @hidden */
  28195. _lightSources: Light[];
  28196. /** Gets the list of lights affecting that mesh */
  28197. get lightSources(): Light[];
  28198. /** @hidden */
  28199. get _positions(): Nullable<Vector3[]>;
  28200. /** @hidden */
  28201. _waitingData: {
  28202. lods: Nullable<any>;
  28203. actions: Nullable<any>;
  28204. freezeWorldMatrix: Nullable<boolean>;
  28205. };
  28206. /** @hidden */
  28207. _bonesTransformMatrices: Nullable<Float32Array>;
  28208. /** @hidden */
  28209. _transformMatrixTexture: Nullable<RawTexture>;
  28210. /**
  28211. * Gets or sets a skeleton to apply skining transformations
  28212. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28213. */
  28214. set skeleton(value: Nullable<Skeleton>);
  28215. get skeleton(): Nullable<Skeleton>;
  28216. /**
  28217. * An event triggered when the mesh is rebuilt.
  28218. */
  28219. onRebuildObservable: Observable<AbstractMesh>;
  28220. /**
  28221. * Creates a new AbstractMesh
  28222. * @param name defines the name of the mesh
  28223. * @param scene defines the hosting scene
  28224. */
  28225. constructor(name: string, scene?: Nullable<Scene>);
  28226. /**
  28227. * Returns the string "AbstractMesh"
  28228. * @returns "AbstractMesh"
  28229. */
  28230. getClassName(): string;
  28231. /**
  28232. * Gets a string representation of the current mesh
  28233. * @param fullDetails defines a boolean indicating if full details must be included
  28234. * @returns a string representation of the current mesh
  28235. */
  28236. toString(fullDetails?: boolean): string;
  28237. /**
  28238. * @hidden
  28239. */
  28240. protected _getEffectiveParent(): Nullable<Node>;
  28241. /** @hidden */
  28242. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28243. /** @hidden */
  28244. _rebuild(): void;
  28245. /** @hidden */
  28246. _resyncLightSources(): void;
  28247. /** @hidden */
  28248. _resyncLightSource(light: Light): void;
  28249. /** @hidden */
  28250. _unBindEffect(): void;
  28251. /** @hidden */
  28252. _removeLightSource(light: Light, dispose: boolean): void;
  28253. private _markSubMeshesAsDirty;
  28254. /** @hidden */
  28255. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28256. /** @hidden */
  28257. _markSubMeshesAsAttributesDirty(): void;
  28258. /** @hidden */
  28259. _markSubMeshesAsMiscDirty(): void;
  28260. /**
  28261. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28262. */
  28263. get scaling(): Vector3;
  28264. set scaling(newScaling: Vector3);
  28265. /**
  28266. * Returns true if the mesh is blocked. Implemented by child classes
  28267. */
  28268. get isBlocked(): boolean;
  28269. /**
  28270. * Returns the mesh itself by default. Implemented by child classes
  28271. * @param camera defines the camera to use to pick the right LOD level
  28272. * @returns the currentAbstractMesh
  28273. */
  28274. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28275. /**
  28276. * Returns 0 by default. Implemented by child classes
  28277. * @returns an integer
  28278. */
  28279. getTotalVertices(): number;
  28280. /**
  28281. * Returns a positive integer : the total number of indices in this mesh geometry.
  28282. * @returns the numner of indices or zero if the mesh has no geometry.
  28283. */
  28284. getTotalIndices(): number;
  28285. /**
  28286. * Returns null by default. Implemented by child classes
  28287. * @returns null
  28288. */
  28289. getIndices(): Nullable<IndicesArray>;
  28290. /**
  28291. * Returns the array of the requested vertex data kind. Implemented by child classes
  28292. * @param kind defines the vertex data kind to use
  28293. * @returns null
  28294. */
  28295. getVerticesData(kind: string): Nullable<FloatArray>;
  28296. /**
  28297. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28298. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28299. * Note that a new underlying VertexBuffer object is created each call.
  28300. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28301. * @param kind defines vertex data kind:
  28302. * * VertexBuffer.PositionKind
  28303. * * VertexBuffer.UVKind
  28304. * * VertexBuffer.UV2Kind
  28305. * * VertexBuffer.UV3Kind
  28306. * * VertexBuffer.UV4Kind
  28307. * * VertexBuffer.UV5Kind
  28308. * * VertexBuffer.UV6Kind
  28309. * * VertexBuffer.ColorKind
  28310. * * VertexBuffer.MatricesIndicesKind
  28311. * * VertexBuffer.MatricesIndicesExtraKind
  28312. * * VertexBuffer.MatricesWeightsKind
  28313. * * VertexBuffer.MatricesWeightsExtraKind
  28314. * @param data defines the data source
  28315. * @param updatable defines if the data must be flagged as updatable (or static)
  28316. * @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
  28317. * @returns the current mesh
  28318. */
  28319. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28320. /**
  28321. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28322. * If the mesh has no geometry, it is simply returned as it is.
  28323. * @param kind defines vertex data kind:
  28324. * * VertexBuffer.PositionKind
  28325. * * VertexBuffer.UVKind
  28326. * * VertexBuffer.UV2Kind
  28327. * * VertexBuffer.UV3Kind
  28328. * * VertexBuffer.UV4Kind
  28329. * * VertexBuffer.UV5Kind
  28330. * * VertexBuffer.UV6Kind
  28331. * * VertexBuffer.ColorKind
  28332. * * VertexBuffer.MatricesIndicesKind
  28333. * * VertexBuffer.MatricesIndicesExtraKind
  28334. * * VertexBuffer.MatricesWeightsKind
  28335. * * VertexBuffer.MatricesWeightsExtraKind
  28336. * @param data defines the data source
  28337. * @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
  28338. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28339. * @returns the current mesh
  28340. */
  28341. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28342. /**
  28343. * Sets the mesh indices,
  28344. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28345. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28346. * @param totalVertices Defines the total number of vertices
  28347. * @returns the current mesh
  28348. */
  28349. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28350. /**
  28351. * Gets a boolean indicating if specific vertex data is present
  28352. * @param kind defines the vertex data kind to use
  28353. * @returns true is data kind is present
  28354. */
  28355. isVerticesDataPresent(kind: string): boolean;
  28356. /**
  28357. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28358. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28359. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28360. * @returns a BoundingInfo
  28361. */
  28362. getBoundingInfo(): BoundingInfo;
  28363. /**
  28364. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28365. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28366. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28367. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28368. * @returns the current mesh
  28369. */
  28370. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28371. /**
  28372. * Overwrite the current bounding info
  28373. * @param boundingInfo defines the new bounding info
  28374. * @returns the current mesh
  28375. */
  28376. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28377. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28378. get useBones(): boolean;
  28379. /** @hidden */
  28380. _preActivate(): void;
  28381. /** @hidden */
  28382. _preActivateForIntermediateRendering(renderId: number): void;
  28383. /** @hidden */
  28384. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28385. /** @hidden */
  28386. _postActivate(): void;
  28387. /** @hidden */
  28388. _freeze(): void;
  28389. /** @hidden */
  28390. _unFreeze(): void;
  28391. /**
  28392. * Gets the current world matrix
  28393. * @returns a Matrix
  28394. */
  28395. getWorldMatrix(): Matrix;
  28396. /** @hidden */
  28397. _getWorldMatrixDeterminant(): number;
  28398. /**
  28399. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28400. */
  28401. get isAnInstance(): boolean;
  28402. /**
  28403. * Gets a boolean indicating if this mesh has instances
  28404. */
  28405. get hasInstances(): boolean;
  28406. /**
  28407. * Perform relative position change from the point of view of behind the front of the mesh.
  28408. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28409. * Supports definition of mesh facing forward or backward
  28410. * @param amountRight defines the distance on the right axis
  28411. * @param amountUp defines the distance on the up axis
  28412. * @param amountForward defines the distance on the forward axis
  28413. * @returns the current mesh
  28414. */
  28415. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28416. /**
  28417. * Calculate relative position change from the point of view of behind the front of the mesh.
  28418. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28419. * Supports definition of mesh facing forward or backward
  28420. * @param amountRight defines the distance on the right axis
  28421. * @param amountUp defines the distance on the up axis
  28422. * @param amountForward defines the distance on the forward axis
  28423. * @returns the new displacement vector
  28424. */
  28425. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28426. /**
  28427. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28428. * Supports definition of mesh facing forward or backward
  28429. * @param flipBack defines the flip
  28430. * @param twirlClockwise defines the twirl
  28431. * @param tiltRight defines the tilt
  28432. * @returns the current mesh
  28433. */
  28434. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28435. /**
  28436. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28437. * Supports definition of mesh facing forward or backward.
  28438. * @param flipBack defines the flip
  28439. * @param twirlClockwise defines the twirl
  28440. * @param tiltRight defines the tilt
  28441. * @returns the new rotation vector
  28442. */
  28443. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28444. /**
  28445. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28446. * This means the mesh underlying bounding box and sphere are recomputed.
  28447. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28448. * @returns the current mesh
  28449. */
  28450. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28451. /** @hidden */
  28452. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28453. /** @hidden */
  28454. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28455. /** @hidden */
  28456. _updateBoundingInfo(): AbstractMesh;
  28457. /** @hidden */
  28458. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28459. /** @hidden */
  28460. protected _afterComputeWorldMatrix(): void;
  28461. /** @hidden */
  28462. get _effectiveMesh(): AbstractMesh;
  28463. /**
  28464. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28465. * A mesh is in the frustum if its bounding box intersects the frustum
  28466. * @param frustumPlanes defines the frustum to test
  28467. * @returns true if the mesh is in the frustum planes
  28468. */
  28469. isInFrustum(frustumPlanes: Plane[]): boolean;
  28470. /**
  28471. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28472. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28473. * @param frustumPlanes defines the frustum to test
  28474. * @returns true if the mesh is completely in the frustum planes
  28475. */
  28476. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28477. /**
  28478. * True if the mesh intersects another mesh or a SolidParticle object
  28479. * @param mesh defines a target mesh or SolidParticle to test
  28480. * @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)
  28481. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28482. * @returns true if there is an intersection
  28483. */
  28484. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28485. /**
  28486. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28487. * @param point defines the point to test
  28488. * @returns true if there is an intersection
  28489. */
  28490. intersectsPoint(point: Vector3): boolean;
  28491. /**
  28492. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28493. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28494. */
  28495. get checkCollisions(): boolean;
  28496. set checkCollisions(collisionEnabled: boolean);
  28497. /**
  28498. * Gets Collider object used to compute collisions (not physics)
  28499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28500. */
  28501. get collider(): Nullable<Collider>;
  28502. /**
  28503. * Move the mesh using collision engine
  28504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28505. * @param displacement defines the requested displacement vector
  28506. * @returns the current mesh
  28507. */
  28508. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28509. private _onCollisionPositionChange;
  28510. /** @hidden */
  28511. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28512. /** @hidden */
  28513. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28514. /** @hidden */
  28515. _checkCollision(collider: Collider): AbstractMesh;
  28516. /** @hidden */
  28517. _generatePointsArray(): boolean;
  28518. /**
  28519. * Checks if the passed Ray intersects with the mesh
  28520. * @param ray defines the ray to use
  28521. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28522. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28523. * @returns the picking info
  28524. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28525. */
  28526. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28527. /**
  28528. * Clones the current mesh
  28529. * @param name defines the mesh name
  28530. * @param newParent defines the new mesh parent
  28531. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28532. * @returns the new mesh
  28533. */
  28534. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28535. /**
  28536. * Disposes all the submeshes of the current meshnp
  28537. * @returns the current mesh
  28538. */
  28539. releaseSubMeshes(): AbstractMesh;
  28540. /**
  28541. * Releases resources associated with this abstract mesh.
  28542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28544. */
  28545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28546. /**
  28547. * Adds the passed mesh as a child to the current mesh
  28548. * @param mesh defines the child mesh
  28549. * @returns the current mesh
  28550. */
  28551. addChild(mesh: AbstractMesh): AbstractMesh;
  28552. /**
  28553. * Removes the passed mesh from the current mesh children list
  28554. * @param mesh defines the child mesh
  28555. * @returns the current mesh
  28556. */
  28557. removeChild(mesh: AbstractMesh): AbstractMesh;
  28558. /** @hidden */
  28559. private _initFacetData;
  28560. /**
  28561. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28562. * This method can be called within the render loop.
  28563. * 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
  28564. * @returns the current mesh
  28565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28566. */
  28567. updateFacetData(): AbstractMesh;
  28568. /**
  28569. * Returns the facetLocalNormals array.
  28570. * The normals are expressed in the mesh local spac
  28571. * @returns an array of Vector3
  28572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28573. */
  28574. getFacetLocalNormals(): Vector3[];
  28575. /**
  28576. * Returns the facetLocalPositions array.
  28577. * The facet positions are expressed in the mesh local space
  28578. * @returns an array of Vector3
  28579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28580. */
  28581. getFacetLocalPositions(): Vector3[];
  28582. /**
  28583. * Returns the facetLocalPartioning array
  28584. * @returns an array of array of numbers
  28585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28586. */
  28587. getFacetLocalPartitioning(): number[][];
  28588. /**
  28589. * Returns the i-th facet position in the world system.
  28590. * This method allocates a new Vector3 per call
  28591. * @param i defines the facet index
  28592. * @returns a new Vector3
  28593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28594. */
  28595. getFacetPosition(i: number): Vector3;
  28596. /**
  28597. * Sets the reference Vector3 with the i-th facet position in the world system
  28598. * @param i defines the facet index
  28599. * @param ref defines the target vector
  28600. * @returns the current mesh
  28601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28602. */
  28603. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28604. /**
  28605. * Returns the i-th facet normal in the world system.
  28606. * This method allocates a new Vector3 per call
  28607. * @param i defines the facet index
  28608. * @returns a new Vector3
  28609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28610. */
  28611. getFacetNormal(i: number): Vector3;
  28612. /**
  28613. * Sets the reference Vector3 with the i-th facet normal in the world system
  28614. * @param i defines the facet index
  28615. * @param ref defines the target vector
  28616. * @returns the current mesh
  28617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28618. */
  28619. getFacetNormalToRef(i: number, ref: Vector3): this;
  28620. /**
  28621. * 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)
  28622. * @param x defines x coordinate
  28623. * @param y defines y coordinate
  28624. * @param z defines z coordinate
  28625. * @returns the array of facet indexes
  28626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28627. */
  28628. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28629. /**
  28630. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28631. * @param projected sets as the (x,y,z) world projection on the facet
  28632. * @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
  28633. * @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
  28634. * @param x defines x coordinate
  28635. * @param y defines y coordinate
  28636. * @param z defines z coordinate
  28637. * @returns the face index if found (or null instead)
  28638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28639. */
  28640. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28641. /**
  28642. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28643. * @param projected sets as the (x,y,z) local projection on the facet
  28644. * @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
  28645. * @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
  28646. * @param x defines x coordinate
  28647. * @param y defines y coordinate
  28648. * @param z defines z coordinate
  28649. * @returns the face index if found (or null instead)
  28650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28651. */
  28652. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28653. /**
  28654. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28655. * @returns the parameters
  28656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28657. */
  28658. getFacetDataParameters(): any;
  28659. /**
  28660. * Disables the feature FacetData and frees the related memory
  28661. * @returns the current mesh
  28662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28663. */
  28664. disableFacetData(): AbstractMesh;
  28665. /**
  28666. * Updates the AbstractMesh indices array
  28667. * @param indices defines the data source
  28668. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28669. * @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)
  28670. * @returns the current mesh
  28671. */
  28672. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28673. /**
  28674. * Creates new normals data for the mesh
  28675. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28676. * @returns the current mesh
  28677. */
  28678. createNormals(updatable: boolean): AbstractMesh;
  28679. /**
  28680. * Align the mesh with a normal
  28681. * @param normal defines the normal to use
  28682. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28683. * @returns the current mesh
  28684. */
  28685. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28686. /** @hidden */
  28687. _checkOcclusionQuery(): boolean;
  28688. /**
  28689. * Disables the mesh edge rendering mode
  28690. * @returns the currentAbstractMesh
  28691. */
  28692. disableEdgesRendering(): AbstractMesh;
  28693. /**
  28694. * Enables the edge rendering mode on the mesh.
  28695. * This mode makes the mesh edges visible
  28696. * @param epsilon defines the maximal distance between two angles to detect a face
  28697. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28698. * @returns the currentAbstractMesh
  28699. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28700. */
  28701. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28702. }
  28703. }
  28704. declare module BABYLON {
  28705. /**
  28706. * Interface used to define ActionEvent
  28707. */
  28708. export interface IActionEvent {
  28709. /** The mesh or sprite that triggered the action */
  28710. source: any;
  28711. /** The X mouse cursor position at the time of the event */
  28712. pointerX: number;
  28713. /** The Y mouse cursor position at the time of the event */
  28714. pointerY: number;
  28715. /** The mesh that is currently pointed at (can be null) */
  28716. meshUnderPointer: Nullable<AbstractMesh>;
  28717. /** the original (browser) event that triggered the ActionEvent */
  28718. sourceEvent?: any;
  28719. /** additional data for the event */
  28720. additionalData?: any;
  28721. }
  28722. /**
  28723. * ActionEvent is the event being sent when an action is triggered.
  28724. */
  28725. export class ActionEvent implements IActionEvent {
  28726. /** The mesh or sprite that triggered the action */
  28727. source: any;
  28728. /** The X mouse cursor position at the time of the event */
  28729. pointerX: number;
  28730. /** The Y mouse cursor position at the time of the event */
  28731. pointerY: number;
  28732. /** The mesh that is currently pointed at (can be null) */
  28733. meshUnderPointer: Nullable<AbstractMesh>;
  28734. /** the original (browser) event that triggered the ActionEvent */
  28735. sourceEvent?: any;
  28736. /** additional data for the event */
  28737. additionalData?: any;
  28738. /**
  28739. * Creates a new ActionEvent
  28740. * @param source The mesh or sprite that triggered the action
  28741. * @param pointerX The X mouse cursor position at the time of the event
  28742. * @param pointerY The Y mouse cursor position at the time of the event
  28743. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28744. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28745. * @param additionalData additional data for the event
  28746. */
  28747. constructor(
  28748. /** The mesh or sprite that triggered the action */
  28749. source: any,
  28750. /** The X mouse cursor position at the time of the event */
  28751. pointerX: number,
  28752. /** The Y mouse cursor position at the time of the event */
  28753. pointerY: number,
  28754. /** The mesh that is currently pointed at (can be null) */
  28755. meshUnderPointer: Nullable<AbstractMesh>,
  28756. /** the original (browser) event that triggered the ActionEvent */
  28757. sourceEvent?: any,
  28758. /** additional data for the event */
  28759. additionalData?: any);
  28760. /**
  28761. * Helper function to auto-create an ActionEvent from a source mesh.
  28762. * @param source The source mesh that triggered the event
  28763. * @param evt The original (browser) event
  28764. * @param additionalData additional data for the event
  28765. * @returns the new ActionEvent
  28766. */
  28767. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28768. /**
  28769. * Helper function to auto-create an ActionEvent from a source sprite
  28770. * @param source The source sprite that triggered the event
  28771. * @param scene Scene associated with the sprite
  28772. * @param evt The original (browser) event
  28773. * @param additionalData additional data for the event
  28774. * @returns the new ActionEvent
  28775. */
  28776. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28777. /**
  28778. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28779. * @param scene the scene where the event occurred
  28780. * @param evt The original (browser) event
  28781. * @returns the new ActionEvent
  28782. */
  28783. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28784. /**
  28785. * Helper function to auto-create an ActionEvent from a primitive
  28786. * @param prim defines the target primitive
  28787. * @param pointerPos defines the pointer position
  28788. * @param evt The original (browser) event
  28789. * @param additionalData additional data for the event
  28790. * @returns the new ActionEvent
  28791. */
  28792. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28793. }
  28794. }
  28795. declare module BABYLON {
  28796. /**
  28797. * Abstract class used to decouple action Manager from scene and meshes.
  28798. * Do not instantiate.
  28799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28800. */
  28801. export abstract class AbstractActionManager implements IDisposable {
  28802. /** Gets the list of active triggers */
  28803. static Triggers: {
  28804. [key: string]: number;
  28805. };
  28806. /** Gets the cursor to use when hovering items */
  28807. hoverCursor: string;
  28808. /** Gets the list of actions */
  28809. actions: IAction[];
  28810. /**
  28811. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28812. */
  28813. isRecursive: boolean;
  28814. /**
  28815. * Releases all associated resources
  28816. */
  28817. abstract dispose(): void;
  28818. /**
  28819. * Does this action manager has pointer triggers
  28820. */
  28821. abstract get hasPointerTriggers(): boolean;
  28822. /**
  28823. * Does this action manager has pick triggers
  28824. */
  28825. abstract get hasPickTriggers(): boolean;
  28826. /**
  28827. * Process a specific trigger
  28828. * @param trigger defines the trigger to process
  28829. * @param evt defines the event details to be processed
  28830. */
  28831. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28832. /**
  28833. * Does this action manager handles actions of any of the given triggers
  28834. * @param triggers defines the triggers to be tested
  28835. * @return a boolean indicating whether one (or more) of the triggers is handled
  28836. */
  28837. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28838. /**
  28839. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28840. * speed.
  28841. * @param triggerA defines the trigger to be tested
  28842. * @param triggerB defines the trigger to be tested
  28843. * @return a boolean indicating whether one (or more) of the triggers is handled
  28844. */
  28845. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28846. /**
  28847. * Does this action manager handles actions of a given trigger
  28848. * @param trigger defines the trigger to be tested
  28849. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28850. * @return whether the trigger is handled
  28851. */
  28852. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28853. /**
  28854. * Serialize this manager to a JSON object
  28855. * @param name defines the property name to store this manager
  28856. * @returns a JSON representation of this manager
  28857. */
  28858. abstract serialize(name: string): any;
  28859. /**
  28860. * Registers an action to this action manager
  28861. * @param action defines the action to be registered
  28862. * @return the action amended (prepared) after registration
  28863. */
  28864. abstract registerAction(action: IAction): Nullable<IAction>;
  28865. /**
  28866. * Unregisters an action to this action manager
  28867. * @param action defines the action to be unregistered
  28868. * @return a boolean indicating whether the action has been unregistered
  28869. */
  28870. abstract unregisterAction(action: IAction): Boolean;
  28871. /**
  28872. * Does exist one action manager with at least one trigger
  28873. **/
  28874. static get HasTriggers(): boolean;
  28875. /**
  28876. * Does exist one action manager with at least one pick trigger
  28877. **/
  28878. static get HasPickTriggers(): boolean;
  28879. /**
  28880. * Does exist one action manager that handles actions of a given trigger
  28881. * @param trigger defines the trigger to be tested
  28882. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28883. **/
  28884. static HasSpecificTrigger(trigger: number): boolean;
  28885. }
  28886. }
  28887. declare module BABYLON {
  28888. /**
  28889. * Defines how a node can be built from a string name.
  28890. */
  28891. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28892. /**
  28893. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28894. */
  28895. export class Node implements IBehaviorAware<Node> {
  28896. /** @hidden */
  28897. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28898. private static _NodeConstructors;
  28899. /**
  28900. * Add a new node constructor
  28901. * @param type defines the type name of the node to construct
  28902. * @param constructorFunc defines the constructor function
  28903. */
  28904. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28905. /**
  28906. * Returns a node constructor based on type name
  28907. * @param type defines the type name
  28908. * @param name defines the new node name
  28909. * @param scene defines the hosting scene
  28910. * @param options defines optional options to transmit to constructors
  28911. * @returns the new constructor or null
  28912. */
  28913. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28914. /**
  28915. * Gets or sets the name of the node
  28916. */
  28917. name: string;
  28918. /**
  28919. * Gets or sets the id of the node
  28920. */
  28921. id: string;
  28922. /**
  28923. * Gets or sets the unique id of the node
  28924. */
  28925. uniqueId: number;
  28926. /**
  28927. * Gets or sets a string used to store user defined state for the node
  28928. */
  28929. state: string;
  28930. /**
  28931. * Gets or sets an object used to store user defined information for the node
  28932. */
  28933. metadata: any;
  28934. /**
  28935. * For internal use only. Please do not use.
  28936. */
  28937. reservedDataStore: any;
  28938. /**
  28939. * List of inspectable custom properties (used by the Inspector)
  28940. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28941. */
  28942. inspectableCustomProperties: IInspectable[];
  28943. private _doNotSerialize;
  28944. /**
  28945. * Gets or sets a boolean used to define if the node must be serialized
  28946. */
  28947. get doNotSerialize(): boolean;
  28948. set doNotSerialize(value: boolean);
  28949. /** @hidden */
  28950. _isDisposed: boolean;
  28951. /**
  28952. * Gets a list of Animations associated with the node
  28953. */
  28954. animations: Animation[];
  28955. protected _ranges: {
  28956. [name: string]: Nullable<AnimationRange>;
  28957. };
  28958. /**
  28959. * Callback raised when the node is ready to be used
  28960. */
  28961. onReady: Nullable<(node: Node) => void>;
  28962. private _isEnabled;
  28963. private _isParentEnabled;
  28964. private _isReady;
  28965. /** @hidden */
  28966. _currentRenderId: number;
  28967. private _parentUpdateId;
  28968. /** @hidden */
  28969. _childUpdateId: number;
  28970. /** @hidden */
  28971. _waitingParentId: Nullable<string>;
  28972. /** @hidden */
  28973. _scene: Scene;
  28974. /** @hidden */
  28975. _cache: any;
  28976. private _parentNode;
  28977. private _children;
  28978. /** @hidden */
  28979. _worldMatrix: Matrix;
  28980. /** @hidden */
  28981. _worldMatrixDeterminant: number;
  28982. /** @hidden */
  28983. _worldMatrixDeterminantIsDirty: boolean;
  28984. /** @hidden */
  28985. private _sceneRootNodesIndex;
  28986. /**
  28987. * Gets a boolean indicating if the node has been disposed
  28988. * @returns true if the node was disposed
  28989. */
  28990. isDisposed(): boolean;
  28991. /**
  28992. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28993. * @see https://doc.babylonjs.com/how_to/parenting
  28994. */
  28995. set parent(parent: Nullable<Node>);
  28996. get parent(): Nullable<Node>;
  28997. /** @hidden */
  28998. _addToSceneRootNodes(): void;
  28999. /** @hidden */
  29000. _removeFromSceneRootNodes(): void;
  29001. private _animationPropertiesOverride;
  29002. /**
  29003. * Gets or sets the animation properties override
  29004. */
  29005. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29006. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29007. /**
  29008. * Gets a string idenfifying the name of the class
  29009. * @returns "Node" string
  29010. */
  29011. getClassName(): string;
  29012. /** @hidden */
  29013. readonly _isNode: boolean;
  29014. /**
  29015. * An event triggered when the mesh is disposed
  29016. */
  29017. onDisposeObservable: Observable<Node>;
  29018. private _onDisposeObserver;
  29019. /**
  29020. * Sets a callback that will be raised when the node will be disposed
  29021. */
  29022. set onDispose(callback: () => void);
  29023. /**
  29024. * Creates a new Node
  29025. * @param name the name and id to be given to this node
  29026. * @param scene the scene this node will be added to
  29027. */
  29028. constructor(name: string, scene?: Nullable<Scene>);
  29029. /**
  29030. * Gets the scene of the node
  29031. * @returns a scene
  29032. */
  29033. getScene(): Scene;
  29034. /**
  29035. * Gets the engine of the node
  29036. * @returns a Engine
  29037. */
  29038. getEngine(): Engine;
  29039. private _behaviors;
  29040. /**
  29041. * Attach a behavior to the node
  29042. * @see http://doc.babylonjs.com/features/behaviour
  29043. * @param behavior defines the behavior to attach
  29044. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29045. * @returns the current Node
  29046. */
  29047. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29048. /**
  29049. * Remove an attached behavior
  29050. * @see http://doc.babylonjs.com/features/behaviour
  29051. * @param behavior defines the behavior to attach
  29052. * @returns the current Node
  29053. */
  29054. removeBehavior(behavior: Behavior<Node>): Node;
  29055. /**
  29056. * Gets the list of attached behaviors
  29057. * @see http://doc.babylonjs.com/features/behaviour
  29058. */
  29059. get behaviors(): Behavior<Node>[];
  29060. /**
  29061. * Gets an attached behavior by name
  29062. * @param name defines the name of the behavior to look for
  29063. * @see http://doc.babylonjs.com/features/behaviour
  29064. * @returns null if behavior was not found else the requested behavior
  29065. */
  29066. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29067. /**
  29068. * Returns the latest update of the World matrix
  29069. * @returns a Matrix
  29070. */
  29071. getWorldMatrix(): Matrix;
  29072. /** @hidden */
  29073. _getWorldMatrixDeterminant(): number;
  29074. /**
  29075. * Returns directly the latest state of the mesh World matrix.
  29076. * A Matrix is returned.
  29077. */
  29078. get worldMatrixFromCache(): Matrix;
  29079. /** @hidden */
  29080. _initCache(): void;
  29081. /** @hidden */
  29082. updateCache(force?: boolean): void;
  29083. /** @hidden */
  29084. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29085. /** @hidden */
  29086. _updateCache(ignoreParentClass?: boolean): void;
  29087. /** @hidden */
  29088. _isSynchronized(): boolean;
  29089. /** @hidden */
  29090. _markSyncedWithParent(): void;
  29091. /** @hidden */
  29092. isSynchronizedWithParent(): boolean;
  29093. /** @hidden */
  29094. isSynchronized(): boolean;
  29095. /**
  29096. * Is this node ready to be used/rendered
  29097. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29098. * @return true if the node is ready
  29099. */
  29100. isReady(completeCheck?: boolean): boolean;
  29101. /**
  29102. * Is this node enabled?
  29103. * 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
  29104. * @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
  29105. * @return whether this node (and its parent) is enabled
  29106. */
  29107. isEnabled(checkAncestors?: boolean): boolean;
  29108. /** @hidden */
  29109. protected _syncParentEnabledState(): void;
  29110. /**
  29111. * Set the enabled state of this node
  29112. * @param value defines the new enabled state
  29113. */
  29114. setEnabled(value: boolean): void;
  29115. /**
  29116. * Is this node a descendant of the given node?
  29117. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29118. * @param ancestor defines the parent node to inspect
  29119. * @returns a boolean indicating if this node is a descendant of the given node
  29120. */
  29121. isDescendantOf(ancestor: Node): boolean;
  29122. /** @hidden */
  29123. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29124. /**
  29125. * Will return all nodes that have this node as ascendant
  29126. * @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
  29127. * @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
  29128. * @return all children nodes of all types
  29129. */
  29130. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29131. /**
  29132. * Get all child-meshes of this node
  29133. * @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)
  29134. * @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
  29135. * @returns an array of AbstractMesh
  29136. */
  29137. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29138. /**
  29139. * Get all direct children of this node
  29140. * @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
  29141. * @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)
  29142. * @returns an array of Node
  29143. */
  29144. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29145. /** @hidden */
  29146. _setReady(state: boolean): void;
  29147. /**
  29148. * Get an animation by name
  29149. * @param name defines the name of the animation to look for
  29150. * @returns null if not found else the requested animation
  29151. */
  29152. getAnimationByName(name: string): Nullable<Animation>;
  29153. /**
  29154. * Creates an animation range for this node
  29155. * @param name defines the name of the range
  29156. * @param from defines the starting key
  29157. * @param to defines the end key
  29158. */
  29159. createAnimationRange(name: string, from: number, to: number): void;
  29160. /**
  29161. * Delete a specific animation range
  29162. * @param name defines the name of the range to delete
  29163. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29164. */
  29165. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29166. /**
  29167. * Get an animation range by name
  29168. * @param name defines the name of the animation range to look for
  29169. * @returns null if not found else the requested animation range
  29170. */
  29171. getAnimationRange(name: string): Nullable<AnimationRange>;
  29172. /**
  29173. * Gets the list of all animation ranges defined on this node
  29174. * @returns an array
  29175. */
  29176. getAnimationRanges(): Nullable<AnimationRange>[];
  29177. /**
  29178. * Will start the animation sequence
  29179. * @param name defines the range frames for animation sequence
  29180. * @param loop defines if the animation should loop (false by default)
  29181. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29182. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29183. * @returns the object created for this animation. If range does not exist, it will return null
  29184. */
  29185. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29186. /**
  29187. * Serialize animation ranges into a JSON compatible object
  29188. * @returns serialization object
  29189. */
  29190. serializeAnimationRanges(): any;
  29191. /**
  29192. * Computes the world matrix of the node
  29193. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29194. * @returns the world matrix
  29195. */
  29196. computeWorldMatrix(force?: boolean): Matrix;
  29197. /**
  29198. * Releases resources associated with this node.
  29199. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29200. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29201. */
  29202. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29203. /**
  29204. * Parse animation range data from a serialization object and store them into a given node
  29205. * @param node defines where to store the animation ranges
  29206. * @param parsedNode defines the serialization object to read data from
  29207. * @param scene defines the hosting scene
  29208. */
  29209. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29210. /**
  29211. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29212. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29213. * @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
  29214. * @returns the new bounding vectors
  29215. */
  29216. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29217. min: Vector3;
  29218. max: Vector3;
  29219. };
  29220. }
  29221. }
  29222. declare module BABYLON {
  29223. /**
  29224. * @hidden
  29225. */
  29226. export class _IAnimationState {
  29227. key: number;
  29228. repeatCount: number;
  29229. workValue?: any;
  29230. loopMode?: number;
  29231. offsetValue?: any;
  29232. highLimitValue?: any;
  29233. }
  29234. /**
  29235. * Class used to store any kind of animation
  29236. */
  29237. export class Animation {
  29238. /**Name of the animation */
  29239. name: string;
  29240. /**Property to animate */
  29241. targetProperty: string;
  29242. /**The frames per second of the animation */
  29243. framePerSecond: number;
  29244. /**The data type of the animation */
  29245. dataType: number;
  29246. /**The loop mode of the animation */
  29247. loopMode?: number | undefined;
  29248. /**Specifies if blending should be enabled */
  29249. enableBlending?: boolean | undefined;
  29250. /**
  29251. * Use matrix interpolation instead of using direct key value when animating matrices
  29252. */
  29253. static AllowMatricesInterpolation: boolean;
  29254. /**
  29255. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29256. */
  29257. static AllowMatrixDecomposeForInterpolation: boolean;
  29258. /**
  29259. * Stores the key frames of the animation
  29260. */
  29261. private _keys;
  29262. /**
  29263. * Stores the easing function of the animation
  29264. */
  29265. private _easingFunction;
  29266. /**
  29267. * @hidden Internal use only
  29268. */
  29269. _runtimeAnimations: RuntimeAnimation[];
  29270. /**
  29271. * The set of event that will be linked to this animation
  29272. */
  29273. private _events;
  29274. /**
  29275. * Stores an array of target property paths
  29276. */
  29277. targetPropertyPath: string[];
  29278. /**
  29279. * Stores the blending speed of the animation
  29280. */
  29281. blendingSpeed: number;
  29282. /**
  29283. * Stores the animation ranges for the animation
  29284. */
  29285. private _ranges;
  29286. /**
  29287. * @hidden Internal use
  29288. */
  29289. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29290. /**
  29291. * Sets up an animation
  29292. * @param property The property to animate
  29293. * @param animationType The animation type to apply
  29294. * @param framePerSecond The frames per second of the animation
  29295. * @param easingFunction The easing function used in the animation
  29296. * @returns The created animation
  29297. */
  29298. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29299. /**
  29300. * Create and start an animation on a node
  29301. * @param name defines the name of the global animation that will be run on all nodes
  29302. * @param node defines the root node where the animation will take place
  29303. * @param targetProperty defines property to animate
  29304. * @param framePerSecond defines the number of frame per second yo use
  29305. * @param totalFrame defines the number of frames in total
  29306. * @param from defines the initial value
  29307. * @param to defines the final value
  29308. * @param loopMode defines which loop mode you want to use (off by default)
  29309. * @param easingFunction defines the easing function to use (linear by default)
  29310. * @param onAnimationEnd defines the callback to call when animation end
  29311. * @returns the animatable created for this animation
  29312. */
  29313. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29314. /**
  29315. * Create and start an animation on a node and its descendants
  29316. * @param name defines the name of the global animation that will be run on all nodes
  29317. * @param node defines the root node where the animation will take place
  29318. * @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
  29319. * @param targetProperty defines property to animate
  29320. * @param framePerSecond defines the number of frame per second to use
  29321. * @param totalFrame defines the number of frames in total
  29322. * @param from defines the initial value
  29323. * @param to defines the final value
  29324. * @param loopMode defines which loop mode you want to use (off by default)
  29325. * @param easingFunction defines the easing function to use (linear by default)
  29326. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29327. * @returns the list of animatables created for all nodes
  29328. * @example https://www.babylonjs-playground.com/#MH0VLI
  29329. */
  29330. 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[]>;
  29331. /**
  29332. * Creates a new animation, merges it with the existing animations and starts it
  29333. * @param name Name of the animation
  29334. * @param node Node which contains the scene that begins the animations
  29335. * @param targetProperty Specifies which property to animate
  29336. * @param framePerSecond The frames per second of the animation
  29337. * @param totalFrame The total number of frames
  29338. * @param from The frame at the beginning of the animation
  29339. * @param to The frame at the end of the animation
  29340. * @param loopMode Specifies the loop mode of the animation
  29341. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29342. * @param onAnimationEnd Callback to run once the animation is complete
  29343. * @returns Nullable animation
  29344. */
  29345. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29346. /**
  29347. * Transition property of an host to the target Value
  29348. * @param property The property to transition
  29349. * @param targetValue The target Value of the property
  29350. * @param host The object where the property to animate belongs
  29351. * @param scene Scene used to run the animation
  29352. * @param frameRate Framerate (in frame/s) to use
  29353. * @param transition The transition type we want to use
  29354. * @param duration The duration of the animation, in milliseconds
  29355. * @param onAnimationEnd Callback trigger at the end of the animation
  29356. * @returns Nullable animation
  29357. */
  29358. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29359. /**
  29360. * Return the array of runtime animations currently using this animation
  29361. */
  29362. get runtimeAnimations(): RuntimeAnimation[];
  29363. /**
  29364. * Specifies if any of the runtime animations are currently running
  29365. */
  29366. get hasRunningRuntimeAnimations(): boolean;
  29367. /**
  29368. * Initializes the animation
  29369. * @param name Name of the animation
  29370. * @param targetProperty Property to animate
  29371. * @param framePerSecond The frames per second of the animation
  29372. * @param dataType The data type of the animation
  29373. * @param loopMode The loop mode of the animation
  29374. * @param enableBlending Specifies if blending should be enabled
  29375. */
  29376. constructor(
  29377. /**Name of the animation */
  29378. name: string,
  29379. /**Property to animate */
  29380. targetProperty: string,
  29381. /**The frames per second of the animation */
  29382. framePerSecond: number,
  29383. /**The data type of the animation */
  29384. dataType: number,
  29385. /**The loop mode of the animation */
  29386. loopMode?: number | undefined,
  29387. /**Specifies if blending should be enabled */
  29388. enableBlending?: boolean | undefined);
  29389. /**
  29390. * Converts the animation to a string
  29391. * @param fullDetails support for multiple levels of logging within scene loading
  29392. * @returns String form of the animation
  29393. */
  29394. toString(fullDetails?: boolean): string;
  29395. /**
  29396. * Add an event to this animation
  29397. * @param event Event to add
  29398. */
  29399. addEvent(event: AnimationEvent): void;
  29400. /**
  29401. * Remove all events found at the given frame
  29402. * @param frame The frame to remove events from
  29403. */
  29404. removeEvents(frame: number): void;
  29405. /**
  29406. * Retrieves all the events from the animation
  29407. * @returns Events from the animation
  29408. */
  29409. getEvents(): AnimationEvent[];
  29410. /**
  29411. * Creates an animation range
  29412. * @param name Name of the animation range
  29413. * @param from Starting frame of the animation range
  29414. * @param to Ending frame of the animation
  29415. */
  29416. createRange(name: string, from: number, to: number): void;
  29417. /**
  29418. * Deletes an animation range by name
  29419. * @param name Name of the animation range to delete
  29420. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29421. */
  29422. deleteRange(name: string, deleteFrames?: boolean): void;
  29423. /**
  29424. * Gets the animation range by name, or null if not defined
  29425. * @param name Name of the animation range
  29426. * @returns Nullable animation range
  29427. */
  29428. getRange(name: string): Nullable<AnimationRange>;
  29429. /**
  29430. * Gets the key frames from the animation
  29431. * @returns The key frames of the animation
  29432. */
  29433. getKeys(): Array<IAnimationKey>;
  29434. /**
  29435. * Gets the highest frame rate of the animation
  29436. * @returns Highest frame rate of the animation
  29437. */
  29438. getHighestFrame(): number;
  29439. /**
  29440. * Gets the easing function of the animation
  29441. * @returns Easing function of the animation
  29442. */
  29443. getEasingFunction(): IEasingFunction;
  29444. /**
  29445. * Sets the easing function of the animation
  29446. * @param easingFunction A custom mathematical formula for animation
  29447. */
  29448. setEasingFunction(easingFunction: EasingFunction): void;
  29449. /**
  29450. * Interpolates a scalar linearly
  29451. * @param startValue Start value of the animation curve
  29452. * @param endValue End value of the animation curve
  29453. * @param gradient Scalar amount to interpolate
  29454. * @returns Interpolated scalar value
  29455. */
  29456. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29457. /**
  29458. * Interpolates a scalar cubically
  29459. * @param startValue Start value of the animation curve
  29460. * @param outTangent End tangent of the animation
  29461. * @param endValue End value of the animation curve
  29462. * @param inTangent Start tangent of the animation curve
  29463. * @param gradient Scalar amount to interpolate
  29464. * @returns Interpolated scalar value
  29465. */
  29466. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29467. /**
  29468. * Interpolates a quaternion using a spherical linear interpolation
  29469. * @param startValue Start value of the animation curve
  29470. * @param endValue End value of the animation curve
  29471. * @param gradient Scalar amount to interpolate
  29472. * @returns Interpolated quaternion value
  29473. */
  29474. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29475. /**
  29476. * Interpolates a quaternion cubically
  29477. * @param startValue Start value of the animation curve
  29478. * @param outTangent End tangent of the animation curve
  29479. * @param endValue End value of the animation curve
  29480. * @param inTangent Start tangent of the animation curve
  29481. * @param gradient Scalar amount to interpolate
  29482. * @returns Interpolated quaternion value
  29483. */
  29484. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29485. /**
  29486. * Interpolates a Vector3 linearl
  29487. * @param startValue Start value of the animation curve
  29488. * @param endValue End value of the animation curve
  29489. * @param gradient Scalar amount to interpolate
  29490. * @returns Interpolated scalar value
  29491. */
  29492. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29493. /**
  29494. * Interpolates a Vector3 cubically
  29495. * @param startValue Start value of the animation curve
  29496. * @param outTangent End tangent of the animation
  29497. * @param endValue End value of the animation curve
  29498. * @param inTangent Start tangent of the animation curve
  29499. * @param gradient Scalar amount to interpolate
  29500. * @returns InterpolatedVector3 value
  29501. */
  29502. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29503. /**
  29504. * Interpolates a Vector2 linearly
  29505. * @param startValue Start value of the animation curve
  29506. * @param endValue End value of the animation curve
  29507. * @param gradient Scalar amount to interpolate
  29508. * @returns Interpolated Vector2 value
  29509. */
  29510. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29511. /**
  29512. * Interpolates a Vector2 cubically
  29513. * @param startValue Start value of the animation curve
  29514. * @param outTangent End tangent of the animation
  29515. * @param endValue End value of the animation curve
  29516. * @param inTangent Start tangent of the animation curve
  29517. * @param gradient Scalar amount to interpolate
  29518. * @returns Interpolated Vector2 value
  29519. */
  29520. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29521. /**
  29522. * Interpolates a size linearly
  29523. * @param startValue Start value of the animation curve
  29524. * @param endValue End value of the animation curve
  29525. * @param gradient Scalar amount to interpolate
  29526. * @returns Interpolated Size value
  29527. */
  29528. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29529. /**
  29530. * Interpolates a Color3 linearly
  29531. * @param startValue Start value of the animation curve
  29532. * @param endValue End value of the animation curve
  29533. * @param gradient Scalar amount to interpolate
  29534. * @returns Interpolated Color3 value
  29535. */
  29536. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29537. /**
  29538. * Interpolates a Color4 linearly
  29539. * @param startValue Start value of the animation curve
  29540. * @param endValue End value of the animation curve
  29541. * @param gradient Scalar amount to interpolate
  29542. * @returns Interpolated Color3 value
  29543. */
  29544. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29545. /**
  29546. * @hidden Internal use only
  29547. */
  29548. _getKeyValue(value: any): any;
  29549. /**
  29550. * @hidden Internal use only
  29551. */
  29552. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29553. /**
  29554. * Defines the function to use to interpolate matrices
  29555. * @param startValue defines the start matrix
  29556. * @param endValue defines the end matrix
  29557. * @param gradient defines the gradient between both matrices
  29558. * @param result defines an optional target matrix where to store the interpolation
  29559. * @returns the interpolated matrix
  29560. */
  29561. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29562. /**
  29563. * Makes a copy of the animation
  29564. * @returns Cloned animation
  29565. */
  29566. clone(): Animation;
  29567. /**
  29568. * Sets the key frames of the animation
  29569. * @param values The animation key frames to set
  29570. */
  29571. setKeys(values: Array<IAnimationKey>): void;
  29572. /**
  29573. * Serializes the animation to an object
  29574. * @returns Serialized object
  29575. */
  29576. serialize(): any;
  29577. /**
  29578. * Float animation type
  29579. */
  29580. static readonly ANIMATIONTYPE_FLOAT: number;
  29581. /**
  29582. * Vector3 animation type
  29583. */
  29584. static readonly ANIMATIONTYPE_VECTOR3: number;
  29585. /**
  29586. * Quaternion animation type
  29587. */
  29588. static readonly ANIMATIONTYPE_QUATERNION: number;
  29589. /**
  29590. * Matrix animation type
  29591. */
  29592. static readonly ANIMATIONTYPE_MATRIX: number;
  29593. /**
  29594. * Color3 animation type
  29595. */
  29596. static readonly ANIMATIONTYPE_COLOR3: number;
  29597. /**
  29598. * Color3 animation type
  29599. */
  29600. static readonly ANIMATIONTYPE_COLOR4: number;
  29601. /**
  29602. * Vector2 animation type
  29603. */
  29604. static readonly ANIMATIONTYPE_VECTOR2: number;
  29605. /**
  29606. * Size animation type
  29607. */
  29608. static readonly ANIMATIONTYPE_SIZE: number;
  29609. /**
  29610. * Relative Loop Mode
  29611. */
  29612. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29613. /**
  29614. * Cycle Loop Mode
  29615. */
  29616. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29617. /**
  29618. * Constant Loop Mode
  29619. */
  29620. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29621. /** @hidden */
  29622. static _UniversalLerp(left: any, right: any, amount: number): any;
  29623. /**
  29624. * Parses an animation object and creates an animation
  29625. * @param parsedAnimation Parsed animation object
  29626. * @returns Animation object
  29627. */
  29628. static Parse(parsedAnimation: any): Animation;
  29629. /**
  29630. * Appends the serialized animations from the source animations
  29631. * @param source Source containing the animations
  29632. * @param destination Target to store the animations
  29633. */
  29634. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29635. }
  29636. }
  29637. declare module BABYLON {
  29638. /**
  29639. * Interface containing an array of animations
  29640. */
  29641. export interface IAnimatable {
  29642. /**
  29643. * Array of animations
  29644. */
  29645. animations: Nullable<Array<Animation>>;
  29646. }
  29647. }
  29648. declare module BABYLON {
  29649. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29650. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29651. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29652. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29653. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29654. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29655. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29656. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29657. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29658. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29659. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29660. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29661. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29662. /**
  29663. * Decorator used to define property that can be serialized as reference to a camera
  29664. * @param sourceName defines the name of the property to decorate
  29665. */
  29666. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29667. /**
  29668. * Class used to help serialization objects
  29669. */
  29670. export class SerializationHelper {
  29671. /** @hidden */
  29672. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29673. /** @hidden */
  29674. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29675. /** @hidden */
  29676. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29677. /** @hidden */
  29678. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29679. /**
  29680. * Appends the serialized animations from the source animations
  29681. * @param source Source containing the animations
  29682. * @param destination Target to store the animations
  29683. */
  29684. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29685. /**
  29686. * Static function used to serialized a specific entity
  29687. * @param entity defines the entity to serialize
  29688. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29689. * @returns a JSON compatible object representing the serialization of the entity
  29690. */
  29691. static Serialize<T>(entity: T, serializationObject?: any): any;
  29692. /**
  29693. * Creates a new entity from a serialization data object
  29694. * @param creationFunction defines a function used to instanciated the new entity
  29695. * @param source defines the source serialization data
  29696. * @param scene defines the hosting scene
  29697. * @param rootUrl defines the root url for resources
  29698. * @returns a new entity
  29699. */
  29700. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29701. /**
  29702. * Clones an object
  29703. * @param creationFunction defines the function used to instanciate the new object
  29704. * @param source defines the source object
  29705. * @returns the cloned object
  29706. */
  29707. static Clone<T>(creationFunction: () => T, source: T): T;
  29708. /**
  29709. * Instanciates a new object based on a source one (some data will be shared between both object)
  29710. * @param creationFunction defines the function used to instanciate the new object
  29711. * @param source defines the source object
  29712. * @returns the new object
  29713. */
  29714. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29715. }
  29716. }
  29717. declare module BABYLON {
  29718. /**
  29719. * Class used to manipulate GUIDs
  29720. */
  29721. export class GUID {
  29722. /**
  29723. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29724. * Be aware Math.random() could cause collisions, but:
  29725. * "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"
  29726. * @returns a pseudo random id
  29727. */
  29728. static RandomId(): string;
  29729. }
  29730. }
  29731. declare module BABYLON {
  29732. /**
  29733. * Base class of all the textures in babylon.
  29734. * It groups all the common properties the materials, post process, lights... might need
  29735. * in order to make a correct use of the texture.
  29736. */
  29737. export class BaseTexture implements IAnimatable {
  29738. /**
  29739. * Default anisotropic filtering level for the application.
  29740. * It is set to 4 as a good tradeoff between perf and quality.
  29741. */
  29742. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29743. /**
  29744. * Gets or sets the unique id of the texture
  29745. */
  29746. uniqueId: number;
  29747. /**
  29748. * Define the name of the texture.
  29749. */
  29750. name: string;
  29751. /**
  29752. * Gets or sets an object used to store user defined information.
  29753. */
  29754. metadata: any;
  29755. /**
  29756. * For internal use only. Please do not use.
  29757. */
  29758. reservedDataStore: any;
  29759. private _hasAlpha;
  29760. /**
  29761. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29762. */
  29763. set hasAlpha(value: boolean);
  29764. get hasAlpha(): boolean;
  29765. /**
  29766. * Defines if the alpha value should be determined via the rgb values.
  29767. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29768. */
  29769. getAlphaFromRGB: boolean;
  29770. /**
  29771. * Intensity or strength of the texture.
  29772. * It is commonly used by materials to fine tune the intensity of the texture
  29773. */
  29774. level: number;
  29775. /**
  29776. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29777. * This is part of the texture as textures usually maps to one uv set.
  29778. */
  29779. coordinatesIndex: number;
  29780. private _coordinatesMode;
  29781. /**
  29782. * How a texture is mapped.
  29783. *
  29784. * | Value | Type | Description |
  29785. * | ----- | ----------------------------------- | ----------- |
  29786. * | 0 | EXPLICIT_MODE | |
  29787. * | 1 | SPHERICAL_MODE | |
  29788. * | 2 | PLANAR_MODE | |
  29789. * | 3 | CUBIC_MODE | |
  29790. * | 4 | PROJECTION_MODE | |
  29791. * | 5 | SKYBOX_MODE | |
  29792. * | 6 | INVCUBIC_MODE | |
  29793. * | 7 | EQUIRECTANGULAR_MODE | |
  29794. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29795. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29796. */
  29797. set coordinatesMode(value: number);
  29798. get coordinatesMode(): number;
  29799. /**
  29800. * | Value | Type | Description |
  29801. * | ----- | ------------------ | ----------- |
  29802. * | 0 | CLAMP_ADDRESSMODE | |
  29803. * | 1 | WRAP_ADDRESSMODE | |
  29804. * | 2 | MIRROR_ADDRESSMODE | |
  29805. */
  29806. wrapU: number;
  29807. /**
  29808. * | Value | Type | Description |
  29809. * | ----- | ------------------ | ----------- |
  29810. * | 0 | CLAMP_ADDRESSMODE | |
  29811. * | 1 | WRAP_ADDRESSMODE | |
  29812. * | 2 | MIRROR_ADDRESSMODE | |
  29813. */
  29814. wrapV: number;
  29815. /**
  29816. * | Value | Type | Description |
  29817. * | ----- | ------------------ | ----------- |
  29818. * | 0 | CLAMP_ADDRESSMODE | |
  29819. * | 1 | WRAP_ADDRESSMODE | |
  29820. * | 2 | MIRROR_ADDRESSMODE | |
  29821. */
  29822. wrapR: number;
  29823. /**
  29824. * With compliant hardware and browser (supporting anisotropic filtering)
  29825. * this defines the level of anisotropic filtering in the texture.
  29826. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29827. */
  29828. anisotropicFilteringLevel: number;
  29829. /**
  29830. * Define if the texture is a cube texture or if false a 2d texture.
  29831. */
  29832. get isCube(): boolean;
  29833. set isCube(value: boolean);
  29834. /**
  29835. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29836. */
  29837. get is3D(): boolean;
  29838. set is3D(value: boolean);
  29839. /**
  29840. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29841. */
  29842. get is2DArray(): boolean;
  29843. set is2DArray(value: boolean);
  29844. /**
  29845. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29846. * HDR texture are usually stored in linear space.
  29847. * This only impacts the PBR and Background materials
  29848. */
  29849. gammaSpace: boolean;
  29850. /**
  29851. * Gets or sets whether or not the texture contains RGBD data.
  29852. */
  29853. get isRGBD(): boolean;
  29854. set isRGBD(value: boolean);
  29855. /**
  29856. * Is Z inverted in the texture (useful in a cube texture).
  29857. */
  29858. invertZ: boolean;
  29859. /**
  29860. * Are mip maps generated for this texture or not.
  29861. */
  29862. get noMipmap(): boolean;
  29863. /**
  29864. * @hidden
  29865. */
  29866. lodLevelInAlpha: boolean;
  29867. /**
  29868. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29869. */
  29870. get lodGenerationOffset(): number;
  29871. set lodGenerationOffset(value: number);
  29872. /**
  29873. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29874. */
  29875. get lodGenerationScale(): number;
  29876. set lodGenerationScale(value: number);
  29877. /**
  29878. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29879. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29880. * average roughness values.
  29881. */
  29882. get linearSpecularLOD(): boolean;
  29883. set linearSpecularLOD(value: boolean);
  29884. /**
  29885. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29886. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29887. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29888. */
  29889. get irradianceTexture(): Nullable<BaseTexture>;
  29890. set irradianceTexture(value: Nullable<BaseTexture>);
  29891. /**
  29892. * Define if the texture is a render target.
  29893. */
  29894. isRenderTarget: boolean;
  29895. /**
  29896. * Define the unique id of the texture in the scene.
  29897. */
  29898. get uid(): string;
  29899. /**
  29900. * Return a string representation of the texture.
  29901. * @returns the texture as a string
  29902. */
  29903. toString(): string;
  29904. /**
  29905. * Get the class name of the texture.
  29906. * @returns "BaseTexture"
  29907. */
  29908. getClassName(): string;
  29909. /**
  29910. * Define the list of animation attached to the texture.
  29911. */
  29912. animations: Animation[];
  29913. /**
  29914. * An event triggered when the texture is disposed.
  29915. */
  29916. onDisposeObservable: Observable<BaseTexture>;
  29917. private _onDisposeObserver;
  29918. /**
  29919. * Callback triggered when the texture has been disposed.
  29920. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29921. */
  29922. set onDispose(callback: () => void);
  29923. /**
  29924. * Define the current state of the loading sequence when in delayed load mode.
  29925. */
  29926. delayLoadState: number;
  29927. private _scene;
  29928. /** @hidden */
  29929. _texture: Nullable<InternalTexture>;
  29930. private _uid;
  29931. /**
  29932. * Define if the texture is preventinga material to render or not.
  29933. * If not and the texture is not ready, the engine will use a default black texture instead.
  29934. */
  29935. get isBlocking(): boolean;
  29936. /**
  29937. * Instantiates a new BaseTexture.
  29938. * Base class of all the textures in babylon.
  29939. * It groups all the common properties the materials, post process, lights... might need
  29940. * in order to make a correct use of the texture.
  29941. * @param scene Define the scene the texture blongs to
  29942. */
  29943. constructor(scene: Nullable<Scene>);
  29944. /**
  29945. * Get the scene the texture belongs to.
  29946. * @returns the scene or null if undefined
  29947. */
  29948. getScene(): Nullable<Scene>;
  29949. /**
  29950. * Get the texture transform matrix used to offset tile the texture for istance.
  29951. * @returns the transformation matrix
  29952. */
  29953. getTextureMatrix(): Matrix;
  29954. /**
  29955. * Get the texture reflection matrix used to rotate/transform the reflection.
  29956. * @returns the reflection matrix
  29957. */
  29958. getReflectionTextureMatrix(): Matrix;
  29959. /**
  29960. * Get the underlying lower level texture from Babylon.
  29961. * @returns the insternal texture
  29962. */
  29963. getInternalTexture(): Nullable<InternalTexture>;
  29964. /**
  29965. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29966. * @returns true if ready or not blocking
  29967. */
  29968. isReadyOrNotBlocking(): boolean;
  29969. /**
  29970. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29971. * @returns true if fully ready
  29972. */
  29973. isReady(): boolean;
  29974. private _cachedSize;
  29975. /**
  29976. * Get the size of the texture.
  29977. * @returns the texture size.
  29978. */
  29979. getSize(): ISize;
  29980. /**
  29981. * Get the base size of the texture.
  29982. * It can be different from the size if the texture has been resized for POT for instance
  29983. * @returns the base size
  29984. */
  29985. getBaseSize(): ISize;
  29986. /**
  29987. * Update the sampling mode of the texture.
  29988. * Default is Trilinear mode.
  29989. *
  29990. * | Value | Type | Description |
  29991. * | ----- | ------------------ | ----------- |
  29992. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29993. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29994. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29995. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29996. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29997. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29998. * | 7 | NEAREST_LINEAR | |
  29999. * | 8 | NEAREST_NEAREST | |
  30000. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30001. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30002. * | 11 | LINEAR_LINEAR | |
  30003. * | 12 | LINEAR_NEAREST | |
  30004. *
  30005. * > _mag_: magnification filter (close to the viewer)
  30006. * > _min_: minification filter (far from the viewer)
  30007. * > _mip_: filter used between mip map levels
  30008. *@param samplingMode Define the new sampling mode of the texture
  30009. */
  30010. updateSamplingMode(samplingMode: number): void;
  30011. /**
  30012. * Scales the texture if is `canRescale()`
  30013. * @param ratio the resize factor we want to use to rescale
  30014. */
  30015. scale(ratio: number): void;
  30016. /**
  30017. * Get if the texture can rescale.
  30018. */
  30019. get canRescale(): boolean;
  30020. /** @hidden */
  30021. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30022. /** @hidden */
  30023. _rebuild(): void;
  30024. /**
  30025. * Triggers the load sequence in delayed load mode.
  30026. */
  30027. delayLoad(): void;
  30028. /**
  30029. * Clones the texture.
  30030. * @returns the cloned texture
  30031. */
  30032. clone(): Nullable<BaseTexture>;
  30033. /**
  30034. * Get the texture underlying type (INT, FLOAT...)
  30035. */
  30036. get textureType(): number;
  30037. /**
  30038. * Get the texture underlying format (RGB, RGBA...)
  30039. */
  30040. get textureFormat(): number;
  30041. /**
  30042. * Indicates that textures need to be re-calculated for all materials
  30043. */
  30044. protected _markAllSubMeshesAsTexturesDirty(): void;
  30045. /**
  30046. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30047. * This will returns an RGBA array buffer containing either in values (0-255) or
  30048. * float values (0-1) depending of the underlying buffer type.
  30049. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30050. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30051. * @param buffer defines a user defined buffer to fill with data (can be null)
  30052. * @returns The Array buffer containing the pixels data.
  30053. */
  30054. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30055. /**
  30056. * Release and destroy the underlying lower level texture aka internalTexture.
  30057. */
  30058. releaseInternalTexture(): void;
  30059. /** @hidden */
  30060. get _lodTextureHigh(): Nullable<BaseTexture>;
  30061. /** @hidden */
  30062. get _lodTextureMid(): Nullable<BaseTexture>;
  30063. /** @hidden */
  30064. get _lodTextureLow(): Nullable<BaseTexture>;
  30065. /**
  30066. * Dispose the texture and release its associated resources.
  30067. */
  30068. dispose(): void;
  30069. /**
  30070. * Serialize the texture into a JSON representation that can be parsed later on.
  30071. * @returns the JSON representation of the texture
  30072. */
  30073. serialize(): any;
  30074. /**
  30075. * Helper function to be called back once a list of texture contains only ready textures.
  30076. * @param textures Define the list of textures to wait for
  30077. * @param callback Define the callback triggered once the entire list will be ready
  30078. */
  30079. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30080. }
  30081. }
  30082. declare module BABYLON {
  30083. /**
  30084. * Options to be used when creating an effect.
  30085. */
  30086. export interface IEffectCreationOptions {
  30087. /**
  30088. * Atrributes that will be used in the shader.
  30089. */
  30090. attributes: string[];
  30091. /**
  30092. * Uniform varible names that will be set in the shader.
  30093. */
  30094. uniformsNames: string[];
  30095. /**
  30096. * Uniform buffer variable names that will be set in the shader.
  30097. */
  30098. uniformBuffersNames: string[];
  30099. /**
  30100. * Sampler texture variable names that will be set in the shader.
  30101. */
  30102. samplers: string[];
  30103. /**
  30104. * Define statements that will be set in the shader.
  30105. */
  30106. defines: any;
  30107. /**
  30108. * Possible fallbacks for this effect to improve performance when needed.
  30109. */
  30110. fallbacks: Nullable<IEffectFallbacks>;
  30111. /**
  30112. * Callback that will be called when the shader is compiled.
  30113. */
  30114. onCompiled: Nullable<(effect: Effect) => void>;
  30115. /**
  30116. * Callback that will be called if an error occurs during shader compilation.
  30117. */
  30118. onError: Nullable<(effect: Effect, errors: string) => void>;
  30119. /**
  30120. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30121. */
  30122. indexParameters?: any;
  30123. /**
  30124. * Max number of lights that can be used in the shader.
  30125. */
  30126. maxSimultaneousLights?: number;
  30127. /**
  30128. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30129. */
  30130. transformFeedbackVaryings?: Nullable<string[]>;
  30131. }
  30132. /**
  30133. * Effect containing vertex and fragment shader that can be executed on an object.
  30134. */
  30135. export class Effect implements IDisposable {
  30136. /**
  30137. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30138. */
  30139. static ShadersRepository: string;
  30140. /**
  30141. * Enable logging of the shader code when a compilation error occurs
  30142. */
  30143. static LogShaderCodeOnCompilationError: boolean;
  30144. /**
  30145. * Name of the effect.
  30146. */
  30147. name: any;
  30148. /**
  30149. * String container all the define statements that should be set on the shader.
  30150. */
  30151. defines: string;
  30152. /**
  30153. * Callback that will be called when the shader is compiled.
  30154. */
  30155. onCompiled: Nullable<(effect: Effect) => void>;
  30156. /**
  30157. * Callback that will be called if an error occurs during shader compilation.
  30158. */
  30159. onError: Nullable<(effect: Effect, errors: string) => void>;
  30160. /**
  30161. * Callback that will be called when effect is bound.
  30162. */
  30163. onBind: Nullable<(effect: Effect) => void>;
  30164. /**
  30165. * Unique ID of the effect.
  30166. */
  30167. uniqueId: number;
  30168. /**
  30169. * Observable that will be called when the shader is compiled.
  30170. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30171. */
  30172. onCompileObservable: Observable<Effect>;
  30173. /**
  30174. * Observable that will be called if an error occurs during shader compilation.
  30175. */
  30176. onErrorObservable: Observable<Effect>;
  30177. /** @hidden */
  30178. _onBindObservable: Nullable<Observable<Effect>>;
  30179. /**
  30180. * @hidden
  30181. * Specifies if the effect was previously ready
  30182. */
  30183. _wasPreviouslyReady: boolean;
  30184. /**
  30185. * Observable that will be called when effect is bound.
  30186. */
  30187. get onBindObservable(): Observable<Effect>;
  30188. /** @hidden */
  30189. _bonesComputationForcedToCPU: boolean;
  30190. private static _uniqueIdSeed;
  30191. private _engine;
  30192. private _uniformBuffersNames;
  30193. private _uniformsNames;
  30194. private _samplerList;
  30195. private _samplers;
  30196. private _isReady;
  30197. private _compilationError;
  30198. private _allFallbacksProcessed;
  30199. private _attributesNames;
  30200. private _attributes;
  30201. private _attributeLocationByName;
  30202. private _uniforms;
  30203. /**
  30204. * Key for the effect.
  30205. * @hidden
  30206. */
  30207. _key: string;
  30208. private _indexParameters;
  30209. private _fallbacks;
  30210. private _vertexSourceCode;
  30211. private _fragmentSourceCode;
  30212. private _vertexSourceCodeOverride;
  30213. private _fragmentSourceCodeOverride;
  30214. private _transformFeedbackVaryings;
  30215. /**
  30216. * Compiled shader to webGL program.
  30217. * @hidden
  30218. */
  30219. _pipelineContext: Nullable<IPipelineContext>;
  30220. private _valueCache;
  30221. private static _baseCache;
  30222. /**
  30223. * Instantiates an effect.
  30224. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30225. * @param baseName Name of the effect.
  30226. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30227. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30228. * @param samplers List of sampler variables that will be passed to the shader.
  30229. * @param engine Engine to be used to render the effect
  30230. * @param defines Define statements to be added to the shader.
  30231. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30232. * @param onCompiled Callback that will be called when the shader is compiled.
  30233. * @param onError Callback that will be called if an error occurs during shader compilation.
  30234. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30235. */
  30236. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30237. private _useFinalCode;
  30238. /**
  30239. * Unique key for this effect
  30240. */
  30241. get key(): string;
  30242. /**
  30243. * If the effect has been compiled and prepared.
  30244. * @returns if the effect is compiled and prepared.
  30245. */
  30246. isReady(): boolean;
  30247. private _isReadyInternal;
  30248. /**
  30249. * The engine the effect was initialized with.
  30250. * @returns the engine.
  30251. */
  30252. getEngine(): Engine;
  30253. /**
  30254. * The pipeline context for this effect
  30255. * @returns the associated pipeline context
  30256. */
  30257. getPipelineContext(): Nullable<IPipelineContext>;
  30258. /**
  30259. * The set of names of attribute variables for the shader.
  30260. * @returns An array of attribute names.
  30261. */
  30262. getAttributesNames(): string[];
  30263. /**
  30264. * Returns the attribute at the given index.
  30265. * @param index The index of the attribute.
  30266. * @returns The location of the attribute.
  30267. */
  30268. getAttributeLocation(index: number): number;
  30269. /**
  30270. * Returns the attribute based on the name of the variable.
  30271. * @param name of the attribute to look up.
  30272. * @returns the attribute location.
  30273. */
  30274. getAttributeLocationByName(name: string): number;
  30275. /**
  30276. * The number of attributes.
  30277. * @returns the numnber of attributes.
  30278. */
  30279. getAttributesCount(): number;
  30280. /**
  30281. * Gets the index of a uniform variable.
  30282. * @param uniformName of the uniform to look up.
  30283. * @returns the index.
  30284. */
  30285. getUniformIndex(uniformName: string): number;
  30286. /**
  30287. * Returns the attribute based on the name of the variable.
  30288. * @param uniformName of the uniform to look up.
  30289. * @returns the location of the uniform.
  30290. */
  30291. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30292. /**
  30293. * Returns an array of sampler variable names
  30294. * @returns The array of sampler variable neames.
  30295. */
  30296. getSamplers(): string[];
  30297. /**
  30298. * The error from the last compilation.
  30299. * @returns the error string.
  30300. */
  30301. getCompilationError(): string;
  30302. /**
  30303. * Gets a boolean indicating that all fallbacks were used during compilation
  30304. * @returns true if all fallbacks were used
  30305. */
  30306. allFallbacksProcessed(): boolean;
  30307. /**
  30308. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30309. * @param func The callback to be used.
  30310. */
  30311. executeWhenCompiled(func: (effect: Effect) => void): void;
  30312. private _checkIsReady;
  30313. private _loadShader;
  30314. /**
  30315. * Recompiles the webGL program
  30316. * @param vertexSourceCode The source code for the vertex shader.
  30317. * @param fragmentSourceCode The source code for the fragment shader.
  30318. * @param onCompiled Callback called when completed.
  30319. * @param onError Callback called on error.
  30320. * @hidden
  30321. */
  30322. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30323. /**
  30324. * Prepares the effect
  30325. * @hidden
  30326. */
  30327. _prepareEffect(): void;
  30328. private _getShaderCodeAndErrorLine;
  30329. private _processCompilationErrors;
  30330. /**
  30331. * Checks if the effect is supported. (Must be called after compilation)
  30332. */
  30333. get isSupported(): boolean;
  30334. /**
  30335. * Binds a texture to the engine to be used as output of the shader.
  30336. * @param channel Name of the output variable.
  30337. * @param texture Texture to bind.
  30338. * @hidden
  30339. */
  30340. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30341. /**
  30342. * Sets a texture on the engine to be used in the shader.
  30343. * @param channel Name of the sampler variable.
  30344. * @param texture Texture to set.
  30345. */
  30346. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30347. /**
  30348. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30349. * @param channel Name of the sampler variable.
  30350. * @param texture Texture to set.
  30351. */
  30352. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30353. /**
  30354. * Sets an array of textures on the engine to be used in the shader.
  30355. * @param channel Name of the variable.
  30356. * @param textures Textures to set.
  30357. */
  30358. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30359. /**
  30360. * 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)
  30361. * @param channel Name of the sampler variable.
  30362. * @param postProcess Post process to get the input texture from.
  30363. */
  30364. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30365. /**
  30366. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30367. * 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)
  30368. * @param channel Name of the sampler variable.
  30369. * @param postProcess Post process to get the output texture from.
  30370. */
  30371. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30372. /** @hidden */
  30373. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30374. /** @hidden */
  30375. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30376. /** @hidden */
  30377. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30378. /** @hidden */
  30379. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30380. /**
  30381. * Binds a buffer to a uniform.
  30382. * @param buffer Buffer to bind.
  30383. * @param name Name of the uniform variable to bind to.
  30384. */
  30385. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30386. /**
  30387. * Binds block to a uniform.
  30388. * @param blockName Name of the block to bind.
  30389. * @param index Index to bind.
  30390. */
  30391. bindUniformBlock(blockName: string, index: number): void;
  30392. /**
  30393. * Sets an interger value on a uniform variable.
  30394. * @param uniformName Name of the variable.
  30395. * @param value Value to be set.
  30396. * @returns this effect.
  30397. */
  30398. setInt(uniformName: string, value: number): Effect;
  30399. /**
  30400. * Sets an int array on a uniform variable.
  30401. * @param uniformName Name of the variable.
  30402. * @param array array to be set.
  30403. * @returns this effect.
  30404. */
  30405. setIntArray(uniformName: string, array: Int32Array): Effect;
  30406. /**
  30407. * 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)
  30408. * @param uniformName Name of the variable.
  30409. * @param array array to be set.
  30410. * @returns this effect.
  30411. */
  30412. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30413. /**
  30414. * 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)
  30415. * @param uniformName Name of the variable.
  30416. * @param array array to be set.
  30417. * @returns this effect.
  30418. */
  30419. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30420. /**
  30421. * 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)
  30422. * @param uniformName Name of the variable.
  30423. * @param array array to be set.
  30424. * @returns this effect.
  30425. */
  30426. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30427. /**
  30428. * Sets an float array on a uniform variable.
  30429. * @param uniformName Name of the variable.
  30430. * @param array array to be set.
  30431. * @returns this effect.
  30432. */
  30433. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30434. /**
  30435. * 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)
  30436. * @param uniformName Name of the variable.
  30437. * @param array array to be set.
  30438. * @returns this effect.
  30439. */
  30440. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30441. /**
  30442. * 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)
  30443. * @param uniformName Name of the variable.
  30444. * @param array array to be set.
  30445. * @returns this effect.
  30446. */
  30447. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30448. /**
  30449. * 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)
  30450. * @param uniformName Name of the variable.
  30451. * @param array array to be set.
  30452. * @returns this effect.
  30453. */
  30454. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30455. /**
  30456. * Sets an array on a uniform variable.
  30457. * @param uniformName Name of the variable.
  30458. * @param array array to be set.
  30459. * @returns this effect.
  30460. */
  30461. setArray(uniformName: string, array: number[]): Effect;
  30462. /**
  30463. * 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)
  30464. * @param uniformName Name of the variable.
  30465. * @param array array to be set.
  30466. * @returns this effect.
  30467. */
  30468. setArray2(uniformName: string, array: number[]): Effect;
  30469. /**
  30470. * 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)
  30471. * @param uniformName Name of the variable.
  30472. * @param array array to be set.
  30473. * @returns this effect.
  30474. */
  30475. setArray3(uniformName: string, array: number[]): Effect;
  30476. /**
  30477. * 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)
  30478. * @param uniformName Name of the variable.
  30479. * @param array array to be set.
  30480. * @returns this effect.
  30481. */
  30482. setArray4(uniformName: string, array: number[]): Effect;
  30483. /**
  30484. * Sets matrices on a uniform variable.
  30485. * @param uniformName Name of the variable.
  30486. * @param matrices matrices to be set.
  30487. * @returns this effect.
  30488. */
  30489. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30490. /**
  30491. * Sets matrix on a uniform variable.
  30492. * @param uniformName Name of the variable.
  30493. * @param matrix matrix to be set.
  30494. * @returns this effect.
  30495. */
  30496. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30497. /**
  30498. * 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)
  30499. * @param uniformName Name of the variable.
  30500. * @param matrix matrix to be set.
  30501. * @returns this effect.
  30502. */
  30503. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30504. /**
  30505. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30506. * @param uniformName Name of the variable.
  30507. * @param matrix matrix to be set.
  30508. * @returns this effect.
  30509. */
  30510. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30511. /**
  30512. * Sets a float on a uniform variable.
  30513. * @param uniformName Name of the variable.
  30514. * @param value value to be set.
  30515. * @returns this effect.
  30516. */
  30517. setFloat(uniformName: string, value: number): Effect;
  30518. /**
  30519. * Sets a boolean on a uniform variable.
  30520. * @param uniformName Name of the variable.
  30521. * @param bool value to be set.
  30522. * @returns this effect.
  30523. */
  30524. setBool(uniformName: string, bool: boolean): Effect;
  30525. /**
  30526. * Sets a Vector2 on a uniform variable.
  30527. * @param uniformName Name of the variable.
  30528. * @param vector2 vector2 to be set.
  30529. * @returns this effect.
  30530. */
  30531. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30532. /**
  30533. * Sets a float2 on a uniform variable.
  30534. * @param uniformName Name of the variable.
  30535. * @param x First float in float2.
  30536. * @param y Second float in float2.
  30537. * @returns this effect.
  30538. */
  30539. setFloat2(uniformName: string, x: number, y: number): Effect;
  30540. /**
  30541. * Sets a Vector3 on a uniform variable.
  30542. * @param uniformName Name of the variable.
  30543. * @param vector3 Value to be set.
  30544. * @returns this effect.
  30545. */
  30546. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30547. /**
  30548. * Sets a float3 on a uniform variable.
  30549. * @param uniformName Name of the variable.
  30550. * @param x First float in float3.
  30551. * @param y Second float in float3.
  30552. * @param z Third float in float3.
  30553. * @returns this effect.
  30554. */
  30555. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30556. /**
  30557. * Sets a Vector4 on a uniform variable.
  30558. * @param uniformName Name of the variable.
  30559. * @param vector4 Value to be set.
  30560. * @returns this effect.
  30561. */
  30562. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30563. /**
  30564. * Sets a float4 on a uniform variable.
  30565. * @param uniformName Name of the variable.
  30566. * @param x First float in float4.
  30567. * @param y Second float in float4.
  30568. * @param z Third float in float4.
  30569. * @param w Fourth float in float4.
  30570. * @returns this effect.
  30571. */
  30572. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30573. /**
  30574. * Sets a Color3 on a uniform variable.
  30575. * @param uniformName Name of the variable.
  30576. * @param color3 Value to be set.
  30577. * @returns this effect.
  30578. */
  30579. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30580. /**
  30581. * Sets a Color4 on a uniform variable.
  30582. * @param uniformName Name of the variable.
  30583. * @param color3 Value to be set.
  30584. * @param alpha Alpha value to be set.
  30585. * @returns this effect.
  30586. */
  30587. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30588. /**
  30589. * Sets a Color4 on a uniform variable
  30590. * @param uniformName defines the name of the variable
  30591. * @param color4 defines the value to be set
  30592. * @returns this effect.
  30593. */
  30594. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30595. /** Release all associated resources */
  30596. dispose(): void;
  30597. /**
  30598. * This function will add a new shader to the shader store
  30599. * @param name the name of the shader
  30600. * @param pixelShader optional pixel shader content
  30601. * @param vertexShader optional vertex shader content
  30602. */
  30603. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30604. /**
  30605. * Store of each shader (The can be looked up using effect.key)
  30606. */
  30607. static ShadersStore: {
  30608. [key: string]: string;
  30609. };
  30610. /**
  30611. * Store of each included file for a shader (The can be looked up using effect.key)
  30612. */
  30613. static IncludesShadersStore: {
  30614. [key: string]: string;
  30615. };
  30616. /**
  30617. * Resets the cache of effects.
  30618. */
  30619. static ResetCache(): void;
  30620. }
  30621. }
  30622. declare module BABYLON {
  30623. /**
  30624. * Interface used to describe the capabilities of the engine relatively to the current browser
  30625. */
  30626. export interface EngineCapabilities {
  30627. /** Maximum textures units per fragment shader */
  30628. maxTexturesImageUnits: number;
  30629. /** Maximum texture units per vertex shader */
  30630. maxVertexTextureImageUnits: number;
  30631. /** Maximum textures units in the entire pipeline */
  30632. maxCombinedTexturesImageUnits: number;
  30633. /** Maximum texture size */
  30634. maxTextureSize: number;
  30635. /** Maximum texture samples */
  30636. maxSamples?: number;
  30637. /** Maximum cube texture size */
  30638. maxCubemapTextureSize: number;
  30639. /** Maximum render texture size */
  30640. maxRenderTextureSize: number;
  30641. /** Maximum number of vertex attributes */
  30642. maxVertexAttribs: number;
  30643. /** Maximum number of varyings */
  30644. maxVaryingVectors: number;
  30645. /** Maximum number of uniforms per vertex shader */
  30646. maxVertexUniformVectors: number;
  30647. /** Maximum number of uniforms per fragment shader */
  30648. maxFragmentUniformVectors: number;
  30649. /** Defines if standard derivates (dx/dy) are supported */
  30650. standardDerivatives: boolean;
  30651. /** Defines if s3tc texture compression is supported */
  30652. s3tc?: WEBGL_compressed_texture_s3tc;
  30653. /** Defines if pvrtc texture compression is supported */
  30654. pvrtc: any;
  30655. /** Defines if etc1 texture compression is supported */
  30656. etc1: any;
  30657. /** Defines if etc2 texture compression is supported */
  30658. etc2: any;
  30659. /** Defines if astc texture compression is supported */
  30660. astc: any;
  30661. /** Defines if float textures are supported */
  30662. textureFloat: boolean;
  30663. /** Defines if vertex array objects are supported */
  30664. vertexArrayObject: boolean;
  30665. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30666. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30667. /** Gets the maximum level of anisotropy supported */
  30668. maxAnisotropy: number;
  30669. /** Defines if instancing is supported */
  30670. instancedArrays: boolean;
  30671. /** Defines if 32 bits indices are supported */
  30672. uintIndices: boolean;
  30673. /** Defines if high precision shaders are supported */
  30674. highPrecisionShaderSupported: boolean;
  30675. /** Defines if depth reading in the fragment shader is supported */
  30676. fragmentDepthSupported: boolean;
  30677. /** Defines if float texture linear filtering is supported*/
  30678. textureFloatLinearFiltering: boolean;
  30679. /** Defines if rendering to float textures is supported */
  30680. textureFloatRender: boolean;
  30681. /** Defines if half float textures are supported*/
  30682. textureHalfFloat: boolean;
  30683. /** Defines if half float texture linear filtering is supported*/
  30684. textureHalfFloatLinearFiltering: boolean;
  30685. /** Defines if rendering to half float textures is supported */
  30686. textureHalfFloatRender: boolean;
  30687. /** Defines if textureLOD shader command is supported */
  30688. textureLOD: boolean;
  30689. /** Defines if draw buffers extension is supported */
  30690. drawBuffersExtension: boolean;
  30691. /** Defines if depth textures are supported */
  30692. depthTextureExtension: boolean;
  30693. /** Defines if float color buffer are supported */
  30694. colorBufferFloat: boolean;
  30695. /** Gets disjoint timer query extension (null if not supported) */
  30696. timerQuery?: EXT_disjoint_timer_query;
  30697. /** Defines if timestamp can be used with timer query */
  30698. canUseTimestampForTimerQuery: boolean;
  30699. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30700. multiview?: any;
  30701. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30702. oculusMultiview?: any;
  30703. /** Function used to let the system compiles shaders in background */
  30704. parallelShaderCompile?: {
  30705. COMPLETION_STATUS_KHR: number;
  30706. };
  30707. /** Max number of texture samples for MSAA */
  30708. maxMSAASamples: number;
  30709. /** Defines if the blend min max extension is supported */
  30710. blendMinMax: boolean;
  30711. }
  30712. }
  30713. declare module BABYLON {
  30714. /**
  30715. * @hidden
  30716. **/
  30717. export class DepthCullingState {
  30718. private _isDepthTestDirty;
  30719. private _isDepthMaskDirty;
  30720. private _isDepthFuncDirty;
  30721. private _isCullFaceDirty;
  30722. private _isCullDirty;
  30723. private _isZOffsetDirty;
  30724. private _isFrontFaceDirty;
  30725. private _depthTest;
  30726. private _depthMask;
  30727. private _depthFunc;
  30728. private _cull;
  30729. private _cullFace;
  30730. private _zOffset;
  30731. private _frontFace;
  30732. /**
  30733. * Initializes the state.
  30734. */
  30735. constructor();
  30736. get isDirty(): boolean;
  30737. get zOffset(): number;
  30738. set zOffset(value: number);
  30739. get cullFace(): Nullable<number>;
  30740. set cullFace(value: Nullable<number>);
  30741. get cull(): Nullable<boolean>;
  30742. set cull(value: Nullable<boolean>);
  30743. get depthFunc(): Nullable<number>;
  30744. set depthFunc(value: Nullable<number>);
  30745. get depthMask(): boolean;
  30746. set depthMask(value: boolean);
  30747. get depthTest(): boolean;
  30748. set depthTest(value: boolean);
  30749. get frontFace(): Nullable<number>;
  30750. set frontFace(value: Nullable<number>);
  30751. reset(): void;
  30752. apply(gl: WebGLRenderingContext): void;
  30753. }
  30754. }
  30755. declare module BABYLON {
  30756. /**
  30757. * @hidden
  30758. **/
  30759. export class StencilState {
  30760. /** 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 */
  30761. static readonly ALWAYS: number;
  30762. /** Passed to stencilOperation to specify that stencil value must be kept */
  30763. static readonly KEEP: number;
  30764. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30765. static readonly REPLACE: number;
  30766. private _isStencilTestDirty;
  30767. private _isStencilMaskDirty;
  30768. private _isStencilFuncDirty;
  30769. private _isStencilOpDirty;
  30770. private _stencilTest;
  30771. private _stencilMask;
  30772. private _stencilFunc;
  30773. private _stencilFuncRef;
  30774. private _stencilFuncMask;
  30775. private _stencilOpStencilFail;
  30776. private _stencilOpDepthFail;
  30777. private _stencilOpStencilDepthPass;
  30778. get isDirty(): boolean;
  30779. get stencilFunc(): number;
  30780. set stencilFunc(value: number);
  30781. get stencilFuncRef(): number;
  30782. set stencilFuncRef(value: number);
  30783. get stencilFuncMask(): number;
  30784. set stencilFuncMask(value: number);
  30785. get stencilOpStencilFail(): number;
  30786. set stencilOpStencilFail(value: number);
  30787. get stencilOpDepthFail(): number;
  30788. set stencilOpDepthFail(value: number);
  30789. get stencilOpStencilDepthPass(): number;
  30790. set stencilOpStencilDepthPass(value: number);
  30791. get stencilMask(): number;
  30792. set stencilMask(value: number);
  30793. get stencilTest(): boolean;
  30794. set stencilTest(value: boolean);
  30795. constructor();
  30796. reset(): void;
  30797. apply(gl: WebGLRenderingContext): void;
  30798. }
  30799. }
  30800. declare module BABYLON {
  30801. /**
  30802. * @hidden
  30803. **/
  30804. export class AlphaState {
  30805. private _isAlphaBlendDirty;
  30806. private _isBlendFunctionParametersDirty;
  30807. private _isBlendEquationParametersDirty;
  30808. private _isBlendConstantsDirty;
  30809. private _alphaBlend;
  30810. private _blendFunctionParameters;
  30811. private _blendEquationParameters;
  30812. private _blendConstants;
  30813. /**
  30814. * Initializes the state.
  30815. */
  30816. constructor();
  30817. get isDirty(): boolean;
  30818. get alphaBlend(): boolean;
  30819. set alphaBlend(value: boolean);
  30820. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30821. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30822. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30823. reset(): void;
  30824. apply(gl: WebGLRenderingContext): void;
  30825. }
  30826. }
  30827. declare module BABYLON {
  30828. /** @hidden */
  30829. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30830. attributeProcessor(attribute: string): string;
  30831. varyingProcessor(varying: string, isFragment: boolean): string;
  30832. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30833. }
  30834. }
  30835. declare module BABYLON {
  30836. /**
  30837. * Interface for attribute information associated with buffer instanciation
  30838. */
  30839. export interface InstancingAttributeInfo {
  30840. /**
  30841. * Name of the GLSL attribute
  30842. * if attribute index is not specified, this is used to retrieve the index from the effect
  30843. */
  30844. attributeName: string;
  30845. /**
  30846. * Index/offset of the attribute in the vertex shader
  30847. * if not specified, this will be computes from the name.
  30848. */
  30849. index?: number;
  30850. /**
  30851. * size of the attribute, 1, 2, 3 or 4
  30852. */
  30853. attributeSize: number;
  30854. /**
  30855. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30856. */
  30857. offset: number;
  30858. /**
  30859. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30860. * default to 1
  30861. */
  30862. divisor?: number;
  30863. /**
  30864. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30865. * default is FLOAT
  30866. */
  30867. attributeType?: number;
  30868. /**
  30869. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30870. */
  30871. normalized?: boolean;
  30872. }
  30873. }
  30874. declare module BABYLON {
  30875. interface ThinEngine {
  30876. /**
  30877. * Update a video texture
  30878. * @param texture defines the texture to update
  30879. * @param video defines the video element to use
  30880. * @param invertY defines if data must be stored with Y axis inverted
  30881. */
  30882. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30883. }
  30884. }
  30885. declare module BABYLON {
  30886. /**
  30887. * Settings for finer control over video usage
  30888. */
  30889. export interface VideoTextureSettings {
  30890. /**
  30891. * Applies `autoplay` to video, if specified
  30892. */
  30893. autoPlay?: boolean;
  30894. /**
  30895. * Applies `loop` to video, if specified
  30896. */
  30897. loop?: boolean;
  30898. /**
  30899. * Automatically updates internal texture from video at every frame in the render loop
  30900. */
  30901. autoUpdateTexture: boolean;
  30902. /**
  30903. * Image src displayed during the video loading or until the user interacts with the video.
  30904. */
  30905. poster?: string;
  30906. }
  30907. /**
  30908. * If you want to display a video in your scene, this is the special texture for that.
  30909. * This special texture works similar to other textures, with the exception of a few parameters.
  30910. * @see https://doc.babylonjs.com/how_to/video_texture
  30911. */
  30912. export class VideoTexture extends Texture {
  30913. /**
  30914. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30915. */
  30916. readonly autoUpdateTexture: boolean;
  30917. /**
  30918. * The video instance used by the texture internally
  30919. */
  30920. readonly video: HTMLVideoElement;
  30921. private _onUserActionRequestedObservable;
  30922. /**
  30923. * Event triggerd when a dom action is required by the user to play the video.
  30924. * This happens due to recent changes in browser policies preventing video to auto start.
  30925. */
  30926. get onUserActionRequestedObservable(): Observable<Texture>;
  30927. private _generateMipMaps;
  30928. private _engine;
  30929. private _stillImageCaptured;
  30930. private _displayingPosterTexture;
  30931. private _settings;
  30932. private _createInternalTextureOnEvent;
  30933. private _frameId;
  30934. private _currentSrc;
  30935. /**
  30936. * Creates a video texture.
  30937. * If you want to display a video in your scene, this is the special texture for that.
  30938. * This special texture works similar to other textures, with the exception of a few parameters.
  30939. * @see https://doc.babylonjs.com/how_to/video_texture
  30940. * @param name optional name, will detect from video source, if not defined
  30941. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30942. * @param scene is obviously the current scene.
  30943. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30944. * @param invertY is false by default but can be used to invert video on Y axis
  30945. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30946. * @param settings allows finer control over video usage
  30947. */
  30948. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30949. private _getName;
  30950. private _getVideo;
  30951. private _createInternalTexture;
  30952. private reset;
  30953. /**
  30954. * @hidden Internal method to initiate `update`.
  30955. */
  30956. _rebuild(): void;
  30957. /**
  30958. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30959. */
  30960. update(): void;
  30961. /**
  30962. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30963. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30964. */
  30965. updateTexture(isVisible: boolean): void;
  30966. protected _updateInternalTexture: () => void;
  30967. /**
  30968. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30969. * @param url New url.
  30970. */
  30971. updateURL(url: string): void;
  30972. /**
  30973. * Clones the texture.
  30974. * @returns the cloned texture
  30975. */
  30976. clone(): VideoTexture;
  30977. /**
  30978. * Dispose the texture and release its associated resources.
  30979. */
  30980. dispose(): void;
  30981. /**
  30982. * Creates a video texture straight from a stream.
  30983. * @param scene Define the scene the texture should be created in
  30984. * @param stream Define the stream the texture should be created from
  30985. * @returns The created video texture as a promise
  30986. */
  30987. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30988. /**
  30989. * Creates a video texture straight from your WebCam video feed.
  30990. * @param scene Define the scene the texture should be created in
  30991. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30992. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30993. * @returns The created video texture as a promise
  30994. */
  30995. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30996. minWidth: number;
  30997. maxWidth: number;
  30998. minHeight: number;
  30999. maxHeight: number;
  31000. deviceId: string;
  31001. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31002. /**
  31003. * Creates a video texture straight from your WebCam video feed.
  31004. * @param scene Define the scene the texture should be created in
  31005. * @param onReady Define a callback to triggered once the texture will be ready
  31006. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31007. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31008. */
  31009. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31010. minWidth: number;
  31011. maxWidth: number;
  31012. minHeight: number;
  31013. maxHeight: number;
  31014. deviceId: string;
  31015. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31016. }
  31017. }
  31018. declare module BABYLON {
  31019. /**
  31020. * Defines the interface used by objects working like Scene
  31021. * @hidden
  31022. */
  31023. export interface ISceneLike {
  31024. _addPendingData(data: any): void;
  31025. _removePendingData(data: any): void;
  31026. offlineProvider: IOfflineProvider;
  31027. }
  31028. /** Interface defining initialization parameters for Engine class */
  31029. export interface EngineOptions extends WebGLContextAttributes {
  31030. /**
  31031. * Defines if the engine should no exceed a specified device ratio
  31032. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31033. */
  31034. limitDeviceRatio?: number;
  31035. /**
  31036. * Defines if webvr should be enabled automatically
  31037. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31038. */
  31039. autoEnableWebVR?: boolean;
  31040. /**
  31041. * Defines if webgl2 should be turned off even if supported
  31042. * @see http://doc.babylonjs.com/features/webgl2
  31043. */
  31044. disableWebGL2Support?: boolean;
  31045. /**
  31046. * Defines if webaudio should be initialized as well
  31047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31048. */
  31049. audioEngine?: boolean;
  31050. /**
  31051. * Defines if animations should run using a deterministic lock step
  31052. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31053. */
  31054. deterministicLockstep?: boolean;
  31055. /** Defines the maximum steps to use with deterministic lock step mode */
  31056. lockstepMaxSteps?: number;
  31057. /** Defines the seconds between each deterministic lock step */
  31058. timeStep?: number;
  31059. /**
  31060. * Defines that engine should ignore context lost events
  31061. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31062. */
  31063. doNotHandleContextLost?: boolean;
  31064. /**
  31065. * Defines that engine should ignore modifying touch action attribute and style
  31066. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31067. */
  31068. doNotHandleTouchAction?: boolean;
  31069. /**
  31070. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31071. */
  31072. useHighPrecisionFloats?: boolean;
  31073. }
  31074. /**
  31075. * The base engine class (root of all engines)
  31076. */
  31077. export class ThinEngine {
  31078. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31079. static ExceptionList: ({
  31080. key: string;
  31081. capture: string;
  31082. captureConstraint: number;
  31083. targets: string[];
  31084. } | {
  31085. key: string;
  31086. capture: null;
  31087. captureConstraint: null;
  31088. targets: string[];
  31089. })[];
  31090. /** @hidden */
  31091. static _TextureLoaders: IInternalTextureLoader[];
  31092. /**
  31093. * Returns the current npm package of the sdk
  31094. */
  31095. static get NpmPackage(): string;
  31096. /**
  31097. * Returns the current version of the framework
  31098. */
  31099. static get Version(): string;
  31100. /**
  31101. * Returns a string describing the current engine
  31102. */
  31103. get description(): string;
  31104. /**
  31105. * Gets or sets the epsilon value used by collision engine
  31106. */
  31107. static CollisionsEpsilon: number;
  31108. /**
  31109. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31110. */
  31111. static get ShadersRepository(): string;
  31112. static set ShadersRepository(value: string);
  31113. /** @hidden */
  31114. _shaderProcessor: IShaderProcessor;
  31115. /**
  31116. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31117. */
  31118. forcePOTTextures: boolean;
  31119. /**
  31120. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31121. */
  31122. isFullscreen: boolean;
  31123. /**
  31124. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31125. */
  31126. cullBackFaces: boolean;
  31127. /**
  31128. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31129. */
  31130. renderEvenInBackground: boolean;
  31131. /**
  31132. * Gets or sets a boolean indicating that cache can be kept between frames
  31133. */
  31134. preventCacheWipeBetweenFrames: boolean;
  31135. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31136. validateShaderPrograms: boolean;
  31137. /**
  31138. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31139. * This can provide greater z depth for distant objects.
  31140. */
  31141. useReverseDepthBuffer: boolean;
  31142. /**
  31143. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31144. */
  31145. disableUniformBuffers: boolean;
  31146. /** @hidden */
  31147. _uniformBuffers: UniformBuffer[];
  31148. /**
  31149. * Gets a boolean indicating that the engine supports uniform buffers
  31150. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31151. */
  31152. get supportsUniformBuffers(): boolean;
  31153. /** @hidden */
  31154. _gl: WebGLRenderingContext;
  31155. /** @hidden */
  31156. _webGLVersion: number;
  31157. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31158. protected _windowIsBackground: boolean;
  31159. protected _creationOptions: EngineOptions;
  31160. protected _highPrecisionShadersAllowed: boolean;
  31161. /** @hidden */
  31162. get _shouldUseHighPrecisionShader(): boolean;
  31163. /**
  31164. * Gets a boolean indicating that only power of 2 textures are supported
  31165. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31166. */
  31167. get needPOTTextures(): boolean;
  31168. /** @hidden */
  31169. _badOS: boolean;
  31170. /** @hidden */
  31171. _badDesktopOS: boolean;
  31172. private _hardwareScalingLevel;
  31173. /** @hidden */
  31174. _caps: EngineCapabilities;
  31175. private _isStencilEnable;
  31176. private _glVersion;
  31177. private _glRenderer;
  31178. private _glVendor;
  31179. /** @hidden */
  31180. _videoTextureSupported: boolean;
  31181. protected _renderingQueueLaunched: boolean;
  31182. protected _activeRenderLoops: (() => void)[];
  31183. /**
  31184. * Observable signaled when a context lost event is raised
  31185. */
  31186. onContextLostObservable: Observable<ThinEngine>;
  31187. /**
  31188. * Observable signaled when a context restored event is raised
  31189. */
  31190. onContextRestoredObservable: Observable<ThinEngine>;
  31191. private _onContextLost;
  31192. private _onContextRestored;
  31193. protected _contextWasLost: boolean;
  31194. /** @hidden */
  31195. _doNotHandleContextLost: boolean;
  31196. /**
  31197. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31199. */
  31200. get doNotHandleContextLost(): boolean;
  31201. set doNotHandleContextLost(value: boolean);
  31202. /**
  31203. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31204. */
  31205. disableVertexArrayObjects: boolean;
  31206. /** @hidden */
  31207. protected _colorWrite: boolean;
  31208. /** @hidden */
  31209. protected _colorWriteChanged: boolean;
  31210. /** @hidden */
  31211. protected _depthCullingState: DepthCullingState;
  31212. /** @hidden */
  31213. protected _stencilState: StencilState;
  31214. /** @hidden */
  31215. _alphaState: AlphaState;
  31216. /** @hidden */
  31217. _alphaMode: number;
  31218. /** @hidden */
  31219. _alphaEquation: number;
  31220. /** @hidden */
  31221. _internalTexturesCache: InternalTexture[];
  31222. /** @hidden */
  31223. protected _activeChannel: number;
  31224. private _currentTextureChannel;
  31225. /** @hidden */
  31226. protected _boundTexturesCache: {
  31227. [key: string]: Nullable<InternalTexture>;
  31228. };
  31229. /** @hidden */
  31230. protected _currentEffect: Nullable<Effect>;
  31231. /** @hidden */
  31232. protected _currentProgram: Nullable<WebGLProgram>;
  31233. private _compiledEffects;
  31234. private _vertexAttribArraysEnabled;
  31235. /** @hidden */
  31236. protected _cachedViewport: Nullable<IViewportLike>;
  31237. private _cachedVertexArrayObject;
  31238. /** @hidden */
  31239. protected _cachedVertexBuffers: any;
  31240. /** @hidden */
  31241. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31242. /** @hidden */
  31243. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31244. /** @hidden */
  31245. _currentRenderTarget: Nullable<InternalTexture>;
  31246. private _uintIndicesCurrentlySet;
  31247. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31248. /** @hidden */
  31249. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31250. private _currentBufferPointers;
  31251. private _currentInstanceLocations;
  31252. private _currentInstanceBuffers;
  31253. private _textureUnits;
  31254. /** @hidden */
  31255. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31256. /** @hidden */
  31257. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31258. /** @hidden */
  31259. _boundRenderFunction: any;
  31260. private _vaoRecordInProgress;
  31261. private _mustWipeVertexAttributes;
  31262. private _emptyTexture;
  31263. private _emptyCubeTexture;
  31264. private _emptyTexture3D;
  31265. private _emptyTexture2DArray;
  31266. /** @hidden */
  31267. _frameHandler: number;
  31268. private _nextFreeTextureSlots;
  31269. private _maxSimultaneousTextures;
  31270. private _activeRequests;
  31271. protected _texturesSupported: string[];
  31272. /** @hidden */
  31273. _textureFormatInUse: Nullable<string>;
  31274. protected get _supportsHardwareTextureRescaling(): boolean;
  31275. private _framebufferDimensionsObject;
  31276. /**
  31277. * sets the object from which width and height will be taken from when getting render width and height
  31278. * Will fallback to the gl object
  31279. * @param dimensions the framebuffer width and height that will be used.
  31280. */
  31281. set framebufferDimensionsObject(dimensions: Nullable<{
  31282. framebufferWidth: number;
  31283. framebufferHeight: number;
  31284. }>);
  31285. /**
  31286. * Gets the list of texture formats supported
  31287. */
  31288. get texturesSupported(): Array<string>;
  31289. /**
  31290. * Gets the list of texture formats in use
  31291. */
  31292. get textureFormatInUse(): Nullable<string>;
  31293. /**
  31294. * Gets the current viewport
  31295. */
  31296. get currentViewport(): Nullable<IViewportLike>;
  31297. /**
  31298. * Gets the default empty texture
  31299. */
  31300. get emptyTexture(): InternalTexture;
  31301. /**
  31302. * Gets the default empty 3D texture
  31303. */
  31304. get emptyTexture3D(): InternalTexture;
  31305. /**
  31306. * Gets the default empty 2D array texture
  31307. */
  31308. get emptyTexture2DArray(): InternalTexture;
  31309. /**
  31310. * Gets the default empty cube texture
  31311. */
  31312. get emptyCubeTexture(): InternalTexture;
  31313. /**
  31314. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31315. */
  31316. readonly premultipliedAlpha: boolean;
  31317. /**
  31318. * Observable event triggered before each texture is initialized
  31319. */
  31320. onBeforeTextureInitObservable: Observable<Texture>;
  31321. /**
  31322. * Creates a new engine
  31323. * @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
  31324. * @param antialias defines enable antialiasing (default: false)
  31325. * @param options defines further options to be sent to the getContext() function
  31326. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31327. */
  31328. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31329. private _rebuildInternalTextures;
  31330. private _rebuildEffects;
  31331. /**
  31332. * Gets a boolean indicating if all created effects are ready
  31333. * @returns true if all effects are ready
  31334. */
  31335. areAllEffectsReady(): boolean;
  31336. protected _rebuildBuffers(): void;
  31337. private _initGLContext;
  31338. /**
  31339. * Gets version of the current webGL context
  31340. */
  31341. get webGLVersion(): number;
  31342. /**
  31343. * Gets a string idenfifying the name of the class
  31344. * @returns "Engine" string
  31345. */
  31346. getClassName(): string;
  31347. /**
  31348. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31349. */
  31350. get isStencilEnable(): boolean;
  31351. /** @hidden */
  31352. _prepareWorkingCanvas(): void;
  31353. /**
  31354. * Reset the texture cache to empty state
  31355. */
  31356. resetTextureCache(): void;
  31357. /**
  31358. * Gets an object containing information about the current webGL context
  31359. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31360. */
  31361. getGlInfo(): {
  31362. vendor: string;
  31363. renderer: string;
  31364. version: string;
  31365. };
  31366. /**
  31367. * Defines the hardware scaling level.
  31368. * By default the hardware scaling level is computed from the window device ratio.
  31369. * 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.
  31370. * @param level defines the level to use
  31371. */
  31372. setHardwareScalingLevel(level: number): void;
  31373. /**
  31374. * Gets the current hardware scaling level.
  31375. * By default the hardware scaling level is computed from the window device ratio.
  31376. * 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.
  31377. * @returns a number indicating the current hardware scaling level
  31378. */
  31379. getHardwareScalingLevel(): number;
  31380. /**
  31381. * Gets the list of loaded textures
  31382. * @returns an array containing all loaded textures
  31383. */
  31384. getLoadedTexturesCache(): InternalTexture[];
  31385. /**
  31386. * Gets the object containing all engine capabilities
  31387. * @returns the EngineCapabilities object
  31388. */
  31389. getCaps(): EngineCapabilities;
  31390. /**
  31391. * stop executing a render loop function and remove it from the execution array
  31392. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31393. */
  31394. stopRenderLoop(renderFunction?: () => void): void;
  31395. /** @hidden */
  31396. _renderLoop(): void;
  31397. /**
  31398. * Gets the HTML canvas attached with the current webGL context
  31399. * @returns a HTML canvas
  31400. */
  31401. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31402. /**
  31403. * Gets host window
  31404. * @returns the host window object
  31405. */
  31406. getHostWindow(): Nullable<Window>;
  31407. /**
  31408. * Gets the current render width
  31409. * @param useScreen defines if screen size must be used (or the current render target if any)
  31410. * @returns a number defining the current render width
  31411. */
  31412. getRenderWidth(useScreen?: boolean): number;
  31413. /**
  31414. * Gets the current render height
  31415. * @param useScreen defines if screen size must be used (or the current render target if any)
  31416. * @returns a number defining the current render height
  31417. */
  31418. getRenderHeight(useScreen?: boolean): number;
  31419. /**
  31420. * Can be used to override the current requestAnimationFrame requester.
  31421. * @hidden
  31422. */
  31423. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31424. /**
  31425. * Register and execute a render loop. The engine can have more than one render function
  31426. * @param renderFunction defines the function to continuously execute
  31427. */
  31428. runRenderLoop(renderFunction: () => void): void;
  31429. /**
  31430. * Clear the current render buffer or the current render target (if any is set up)
  31431. * @param color defines the color to use
  31432. * @param backBuffer defines if the back buffer must be cleared
  31433. * @param depth defines if the depth buffer must be cleared
  31434. * @param stencil defines if the stencil buffer must be cleared
  31435. */
  31436. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31437. private _viewportCached;
  31438. /** @hidden */
  31439. _viewport(x: number, y: number, width: number, height: number): void;
  31440. /**
  31441. * Set the WebGL's viewport
  31442. * @param viewport defines the viewport element to be used
  31443. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31444. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31445. */
  31446. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31447. /**
  31448. * Begin a new frame
  31449. */
  31450. beginFrame(): void;
  31451. /**
  31452. * Enf the current frame
  31453. */
  31454. endFrame(): void;
  31455. /**
  31456. * Resize the view according to the canvas' size
  31457. */
  31458. resize(): void;
  31459. /**
  31460. * Force a specific size of the canvas
  31461. * @param width defines the new canvas' width
  31462. * @param height defines the new canvas' height
  31463. */
  31464. setSize(width: number, height: number): void;
  31465. /**
  31466. * Binds the frame buffer to the specified texture.
  31467. * @param texture The texture to render to or null for the default canvas
  31468. * @param faceIndex The face of the texture to render to in case of cube texture
  31469. * @param requiredWidth The width of the target to render to
  31470. * @param requiredHeight The height of the target to render to
  31471. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31472. * @param lodLevel defines the lod level to bind to the frame buffer
  31473. * @param layer defines the 2d array index to bind to frame buffer to
  31474. */
  31475. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31476. /** @hidden */
  31477. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31478. /**
  31479. * Unbind the current render target texture from the webGL context
  31480. * @param texture defines the render target texture to unbind
  31481. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31482. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31483. */
  31484. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31485. /**
  31486. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31487. */
  31488. flushFramebuffer(): void;
  31489. /**
  31490. * Unbind the current render target and bind the default framebuffer
  31491. */
  31492. restoreDefaultFramebuffer(): void;
  31493. /** @hidden */
  31494. protected _resetVertexBufferBinding(): void;
  31495. /**
  31496. * Creates a vertex buffer
  31497. * @param data the data for the vertex buffer
  31498. * @returns the new WebGL static buffer
  31499. */
  31500. createVertexBuffer(data: DataArray): DataBuffer;
  31501. private _createVertexBuffer;
  31502. /**
  31503. * Creates a dynamic vertex buffer
  31504. * @param data the data for the dynamic vertex buffer
  31505. * @returns the new WebGL dynamic buffer
  31506. */
  31507. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31508. protected _resetIndexBufferBinding(): void;
  31509. /**
  31510. * Creates a new index buffer
  31511. * @param indices defines the content of the index buffer
  31512. * @param updatable defines if the index buffer must be updatable
  31513. * @returns a new webGL buffer
  31514. */
  31515. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31516. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31517. /**
  31518. * Bind a webGL buffer to the webGL context
  31519. * @param buffer defines the buffer to bind
  31520. */
  31521. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31522. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31523. private bindBuffer;
  31524. /**
  31525. * update the bound buffer with the given data
  31526. * @param data defines the data to update
  31527. */
  31528. updateArrayBuffer(data: Float32Array): void;
  31529. private _vertexAttribPointer;
  31530. /** @hidden */
  31531. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31532. private _bindVertexBuffersAttributes;
  31533. /**
  31534. * Records a vertex array object
  31535. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31536. * @param vertexBuffers defines the list of vertex buffers to store
  31537. * @param indexBuffer defines the index buffer to store
  31538. * @param effect defines the effect to store
  31539. * @returns the new vertex array object
  31540. */
  31541. recordVertexArrayObject(vertexBuffers: {
  31542. [key: string]: VertexBuffer;
  31543. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31544. /**
  31545. * Bind a specific vertex array object
  31546. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31547. * @param vertexArrayObject defines the vertex array object to bind
  31548. * @param indexBuffer defines the index buffer to bind
  31549. */
  31550. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31551. /**
  31552. * Bind webGl buffers directly to the webGL context
  31553. * @param vertexBuffer defines the vertex buffer to bind
  31554. * @param indexBuffer defines the index buffer to bind
  31555. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31556. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31557. * @param effect defines the effect associated with the vertex buffer
  31558. */
  31559. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31560. private _unbindVertexArrayObject;
  31561. /**
  31562. * Bind a list of vertex buffers to the webGL context
  31563. * @param vertexBuffers defines the list of vertex buffers to bind
  31564. * @param indexBuffer defines the index buffer to bind
  31565. * @param effect defines the effect associated with the vertex buffers
  31566. */
  31567. bindBuffers(vertexBuffers: {
  31568. [key: string]: Nullable<VertexBuffer>;
  31569. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31570. /**
  31571. * Unbind all instance attributes
  31572. */
  31573. unbindInstanceAttributes(): void;
  31574. /**
  31575. * Release and free the memory of a vertex array object
  31576. * @param vao defines the vertex array object to delete
  31577. */
  31578. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31579. /** @hidden */
  31580. _releaseBuffer(buffer: DataBuffer): boolean;
  31581. protected _deleteBuffer(buffer: DataBuffer): void;
  31582. /**
  31583. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31584. * @param instancesBuffer defines the webGL buffer to update and bind
  31585. * @param data defines the data to store in the buffer
  31586. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31587. */
  31588. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31589. /**
  31590. * Bind the content of a webGL buffer used with instantiation
  31591. * @param instancesBuffer defines the webGL buffer to bind
  31592. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31593. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31594. */
  31595. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31596. /**
  31597. * Disable the instance attribute corresponding to the name in parameter
  31598. * @param name defines the name of the attribute to disable
  31599. */
  31600. disableInstanceAttributeByName(name: string): void;
  31601. /**
  31602. * Disable the instance attribute corresponding to the location in parameter
  31603. * @param attributeLocation defines the attribute location of the attribute to disable
  31604. */
  31605. disableInstanceAttribute(attributeLocation: number): void;
  31606. /**
  31607. * Disable the attribute corresponding to the location in parameter
  31608. * @param attributeLocation defines the attribute location of the attribute to disable
  31609. */
  31610. disableAttributeByIndex(attributeLocation: number): void;
  31611. /**
  31612. * Send a draw order
  31613. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31614. * @param indexStart defines the starting index
  31615. * @param indexCount defines the number of index to draw
  31616. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31617. */
  31618. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31619. /**
  31620. * Draw a list of points
  31621. * @param verticesStart defines the index of first vertex to draw
  31622. * @param verticesCount defines the count of vertices to draw
  31623. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31624. */
  31625. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31626. /**
  31627. * Draw a list of unindexed primitives
  31628. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31629. * @param verticesStart defines the index of first vertex to draw
  31630. * @param verticesCount defines the count of vertices to draw
  31631. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31632. */
  31633. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31634. /**
  31635. * Draw a list of indexed primitives
  31636. * @param fillMode defines the primitive to use
  31637. * @param indexStart defines the starting index
  31638. * @param indexCount defines the number of index to draw
  31639. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31640. */
  31641. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31642. /**
  31643. * Draw a list of unindexed primitives
  31644. * @param fillMode defines the primitive to use
  31645. * @param verticesStart defines the index of first vertex to draw
  31646. * @param verticesCount defines the count of vertices to draw
  31647. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31648. */
  31649. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31650. private _drawMode;
  31651. /** @hidden */
  31652. protected _reportDrawCall(): void;
  31653. /** @hidden */
  31654. _releaseEffect(effect: Effect): void;
  31655. /** @hidden */
  31656. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31657. /**
  31658. * Create a new effect (used to store vertex/fragment shaders)
  31659. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31660. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31661. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31662. * @param samplers defines an array of string used to represent textures
  31663. * @param defines defines the string containing the defines to use to compile the shaders
  31664. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31665. * @param onCompiled defines a function to call when the effect creation is successful
  31666. * @param onError defines a function to call when the effect creation has failed
  31667. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31668. * @returns the new Effect
  31669. */
  31670. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31671. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31672. private _compileShader;
  31673. private _compileRawShader;
  31674. /** @hidden */
  31675. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31676. /**
  31677. * Directly creates a webGL program
  31678. * @param pipelineContext defines the pipeline context to attach to
  31679. * @param vertexCode defines the vertex shader code to use
  31680. * @param fragmentCode defines the fragment shader code to use
  31681. * @param context defines the webGL context to use (if not set, the current one will be used)
  31682. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31683. * @returns the new webGL program
  31684. */
  31685. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31686. /**
  31687. * Creates a webGL program
  31688. * @param pipelineContext defines the pipeline context to attach to
  31689. * @param vertexCode defines the vertex shader code to use
  31690. * @param fragmentCode defines the fragment shader code to use
  31691. * @param defines defines the string containing the defines to use to compile the shaders
  31692. * @param context defines the webGL context to use (if not set, the current one will be used)
  31693. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31694. * @returns the new webGL program
  31695. */
  31696. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31697. /**
  31698. * Creates a new pipeline context
  31699. * @returns the new pipeline
  31700. */
  31701. createPipelineContext(): IPipelineContext;
  31702. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31703. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31704. /** @hidden */
  31705. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31706. /** @hidden */
  31707. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31708. /** @hidden */
  31709. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31710. /**
  31711. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31712. * @param pipelineContext defines the pipeline context to use
  31713. * @param uniformsNames defines the list of uniform names
  31714. * @returns an array of webGL uniform locations
  31715. */
  31716. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31717. /**
  31718. * Gets the lsit of active attributes for a given webGL program
  31719. * @param pipelineContext defines the pipeline context to use
  31720. * @param attributesNames defines the list of attribute names to get
  31721. * @returns an array of indices indicating the offset of each attribute
  31722. */
  31723. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31724. /**
  31725. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31726. * @param effect defines the effect to activate
  31727. */
  31728. enableEffect(effect: Nullable<Effect>): void;
  31729. /**
  31730. * Set the value of an uniform to a number (int)
  31731. * @param uniform defines the webGL uniform location where to store the value
  31732. * @param value defines the int number to store
  31733. */
  31734. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31735. /**
  31736. * Set the value of an uniform to an array of int32
  31737. * @param uniform defines the webGL uniform location where to store the value
  31738. * @param array defines the array of int32 to store
  31739. */
  31740. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31741. /**
  31742. * Set the value of an uniform to an array of int32 (stored as vec2)
  31743. * @param uniform defines the webGL uniform location where to store the value
  31744. * @param array defines the array of int32 to store
  31745. */
  31746. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31747. /**
  31748. * Set the value of an uniform to an array of int32 (stored as vec3)
  31749. * @param uniform defines the webGL uniform location where to store the value
  31750. * @param array defines the array of int32 to store
  31751. */
  31752. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31753. /**
  31754. * Set the value of an uniform to an array of int32 (stored as vec4)
  31755. * @param uniform defines the webGL uniform location where to store the value
  31756. * @param array defines the array of int32 to store
  31757. */
  31758. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31759. /**
  31760. * Set the value of an uniform to an array of number
  31761. * @param uniform defines the webGL uniform location where to store the value
  31762. * @param array defines the array of number to store
  31763. */
  31764. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31765. /**
  31766. * Set the value of an uniform to an array of number (stored as vec2)
  31767. * @param uniform defines the webGL uniform location where to store the value
  31768. * @param array defines the array of number to store
  31769. */
  31770. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31771. /**
  31772. * Set the value of an uniform to an array of number (stored as vec3)
  31773. * @param uniform defines the webGL uniform location where to store the value
  31774. * @param array defines the array of number to store
  31775. */
  31776. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31777. /**
  31778. * Set the value of an uniform to an array of number (stored as vec4)
  31779. * @param uniform defines the webGL uniform location where to store the value
  31780. * @param array defines the array of number to store
  31781. */
  31782. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31783. /**
  31784. * Set the value of an uniform to an array of float32 (stored as matrices)
  31785. * @param uniform defines the webGL uniform location where to store the value
  31786. * @param matrices defines the array of float32 to store
  31787. */
  31788. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31789. /**
  31790. * Set the value of an uniform to a matrix (3x3)
  31791. * @param uniform defines the webGL uniform location where to store the value
  31792. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31793. */
  31794. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31795. /**
  31796. * Set the value of an uniform to a matrix (2x2)
  31797. * @param uniform defines the webGL uniform location where to store the value
  31798. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31799. */
  31800. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31801. /**
  31802. * Set the value of an uniform to a number (float)
  31803. * @param uniform defines the webGL uniform location where to store the value
  31804. * @param value defines the float number to store
  31805. */
  31806. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31807. /**
  31808. * Set the value of an uniform to a vec2
  31809. * @param uniform defines the webGL uniform location where to store the value
  31810. * @param x defines the 1st component of the value
  31811. * @param y defines the 2nd component of the value
  31812. */
  31813. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31814. /**
  31815. * Set the value of an uniform to a vec3
  31816. * @param uniform defines the webGL uniform location where to store the value
  31817. * @param x defines the 1st component of the value
  31818. * @param y defines the 2nd component of the value
  31819. * @param z defines the 3rd component of the value
  31820. */
  31821. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31822. /**
  31823. * Set the value of an uniform to a vec4
  31824. * @param uniform defines the webGL uniform location where to store the value
  31825. * @param x defines the 1st component of the value
  31826. * @param y defines the 2nd component of the value
  31827. * @param z defines the 3rd component of the value
  31828. * @param w defines the 4th component of the value
  31829. */
  31830. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31831. /**
  31832. * Apply all cached states (depth, culling, stencil and alpha)
  31833. */
  31834. applyStates(): void;
  31835. /**
  31836. * Enable or disable color writing
  31837. * @param enable defines the state to set
  31838. */
  31839. setColorWrite(enable: boolean): void;
  31840. /**
  31841. * Gets a boolean indicating if color writing is enabled
  31842. * @returns the current color writing state
  31843. */
  31844. getColorWrite(): boolean;
  31845. /**
  31846. * Gets the depth culling state manager
  31847. */
  31848. get depthCullingState(): DepthCullingState;
  31849. /**
  31850. * Gets the alpha state manager
  31851. */
  31852. get alphaState(): AlphaState;
  31853. /**
  31854. * Gets the stencil state manager
  31855. */
  31856. get stencilState(): StencilState;
  31857. /**
  31858. * Clears the list of texture accessible through engine.
  31859. * This can help preventing texture load conflict due to name collision.
  31860. */
  31861. clearInternalTexturesCache(): void;
  31862. /**
  31863. * Force the entire cache to be cleared
  31864. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31865. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31866. */
  31867. wipeCaches(bruteForce?: boolean): void;
  31868. /** @hidden */
  31869. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31870. min: number;
  31871. mag: number;
  31872. };
  31873. /** @hidden */
  31874. _createTexture(): WebGLTexture;
  31875. /**
  31876. * Usually called from Texture.ts.
  31877. * Passed information to create a WebGLTexture
  31878. * @param urlArg defines a value which contains one of the following:
  31879. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31880. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31881. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31882. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31883. * @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)
  31884. * @param scene needed for loading to the correct scene
  31885. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31886. * @param onLoad optional callback to be called upon successful completion
  31887. * @param onError optional callback to be called upon failure
  31888. * @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
  31889. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31890. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31891. * @param forcedExtension defines the extension to use to pick the right loader
  31892. * @param mimeType defines an optional mime type
  31893. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31894. */
  31895. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  31896. /**
  31897. * Loads an image as an HTMLImageElement.
  31898. * @param input url string, ArrayBuffer, or Blob to load
  31899. * @param onLoad callback called when the image successfully loads
  31900. * @param onError callback called when the image fails to load
  31901. * @param offlineProvider offline provider for caching
  31902. * @param mimeType optional mime type
  31903. * @returns the HTMLImageElement of the loaded image
  31904. * @hidden
  31905. */
  31906. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31907. /**
  31908. * @hidden
  31909. */
  31910. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31911. /**
  31912. * Creates a raw texture
  31913. * @param data defines the data to store in the texture
  31914. * @param width defines the width of the texture
  31915. * @param height defines the height of the texture
  31916. * @param format defines the format of the data
  31917. * @param generateMipMaps defines if the engine should generate the mip levels
  31918. * @param invertY defines if data must be stored with Y axis inverted
  31919. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31920. * @param compression defines the compression used (null by default)
  31921. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31922. * @returns the raw texture inside an InternalTexture
  31923. */
  31924. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31925. /**
  31926. * Creates a new raw cube texture
  31927. * @param data defines the array of data to use to create each face
  31928. * @param size defines the size of the textures
  31929. * @param format defines the format of the data
  31930. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31931. * @param generateMipMaps defines if the engine should generate the mip levels
  31932. * @param invertY defines if data must be stored with Y axis inverted
  31933. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31934. * @param compression defines the compression used (null by default)
  31935. * @returns the cube texture as an InternalTexture
  31936. */
  31937. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31938. /**
  31939. * Creates a new raw 3D texture
  31940. * @param data defines the data used to create the texture
  31941. * @param width defines the width of the texture
  31942. * @param height defines the height of the texture
  31943. * @param depth defines the depth of the texture
  31944. * @param format defines the format of the texture
  31945. * @param generateMipMaps defines if the engine must generate mip levels
  31946. * @param invertY defines if data must be stored with Y axis inverted
  31947. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31948. * @param compression defines the compressed used (can be null)
  31949. * @param textureType defines the compressed used (can be null)
  31950. * @returns a new raw 3D texture (stored in an InternalTexture)
  31951. */
  31952. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31953. /**
  31954. * Creates a new raw 2D array texture
  31955. * @param data defines the data used to create the texture
  31956. * @param width defines the width of the texture
  31957. * @param height defines the height of the texture
  31958. * @param depth defines the number of layers of the texture
  31959. * @param format defines the format of the texture
  31960. * @param generateMipMaps defines if the engine must generate mip levels
  31961. * @param invertY defines if data must be stored with Y axis inverted
  31962. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31963. * @param compression defines the compressed used (can be null)
  31964. * @param textureType defines the compressed used (can be null)
  31965. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31966. */
  31967. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31968. private _unpackFlipYCached;
  31969. /**
  31970. * In case you are sharing the context with other applications, it might
  31971. * be interested to not cache the unpack flip y state to ensure a consistent
  31972. * value would be set.
  31973. */
  31974. enableUnpackFlipYCached: boolean;
  31975. /** @hidden */
  31976. _unpackFlipY(value: boolean): void;
  31977. /** @hidden */
  31978. _getUnpackAlignement(): number;
  31979. private _getTextureTarget;
  31980. /**
  31981. * Update the sampling mode of a given texture
  31982. * @param samplingMode defines the required sampling mode
  31983. * @param texture defines the texture to update
  31984. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31985. */
  31986. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31987. /**
  31988. * Update the sampling mode of a given texture
  31989. * @param texture defines the texture to update
  31990. * @param wrapU defines the texture wrap mode of the u coordinates
  31991. * @param wrapV defines the texture wrap mode of the v coordinates
  31992. * @param wrapR defines the texture wrap mode of the r coordinates
  31993. */
  31994. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31995. /** @hidden */
  31996. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31997. width: number;
  31998. height: number;
  31999. layers?: number;
  32000. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32001. /** @hidden */
  32002. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32003. /** @hidden */
  32004. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32005. /**
  32006. * Update a portion of an internal texture
  32007. * @param texture defines the texture to update
  32008. * @param imageData defines the data to store into the texture
  32009. * @param xOffset defines the x coordinates of the update rectangle
  32010. * @param yOffset defines the y coordinates of the update rectangle
  32011. * @param width defines the width of the update rectangle
  32012. * @param height defines the height of the update rectangle
  32013. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32014. * @param lod defines the lod level to update (0 by default)
  32015. */
  32016. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32017. /** @hidden */
  32018. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32019. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32020. private _prepareWebGLTexture;
  32021. /** @hidden */
  32022. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32023. private _getDepthStencilBuffer;
  32024. /** @hidden */
  32025. _releaseFramebufferObjects(texture: InternalTexture): void;
  32026. /** @hidden */
  32027. _releaseTexture(texture: InternalTexture): void;
  32028. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32029. protected _setProgram(program: WebGLProgram): void;
  32030. protected _boundUniforms: {
  32031. [key: number]: WebGLUniformLocation;
  32032. };
  32033. /**
  32034. * Binds an effect to the webGL context
  32035. * @param effect defines the effect to bind
  32036. */
  32037. bindSamplers(effect: Effect): void;
  32038. private _activateCurrentTexture;
  32039. /** @hidden */
  32040. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32041. /** @hidden */
  32042. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32043. /**
  32044. * Unbind all textures from the webGL context
  32045. */
  32046. unbindAllTextures(): void;
  32047. /**
  32048. * Sets a texture to the according uniform.
  32049. * @param channel The texture channel
  32050. * @param uniform The uniform to set
  32051. * @param texture The texture to apply
  32052. */
  32053. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32054. private _bindSamplerUniformToChannel;
  32055. private _getTextureWrapMode;
  32056. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32057. /**
  32058. * Sets an array of texture to the webGL context
  32059. * @param channel defines the channel where the texture array must be set
  32060. * @param uniform defines the associated uniform location
  32061. * @param textures defines the array of textures to bind
  32062. */
  32063. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32064. /** @hidden */
  32065. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32066. private _setTextureParameterFloat;
  32067. private _setTextureParameterInteger;
  32068. /**
  32069. * Unbind all vertex attributes from the webGL context
  32070. */
  32071. unbindAllAttributes(): void;
  32072. /**
  32073. * 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
  32074. */
  32075. releaseEffects(): void;
  32076. /**
  32077. * Dispose and release all associated resources
  32078. */
  32079. dispose(): void;
  32080. /**
  32081. * Attach a new callback raised when context lost event is fired
  32082. * @param callback defines the callback to call
  32083. */
  32084. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32085. /**
  32086. * Attach a new callback raised when context restored event is fired
  32087. * @param callback defines the callback to call
  32088. */
  32089. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32090. /**
  32091. * Get the current error code of the webGL context
  32092. * @returns the error code
  32093. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32094. */
  32095. getError(): number;
  32096. private _canRenderToFloatFramebuffer;
  32097. private _canRenderToHalfFloatFramebuffer;
  32098. private _canRenderToFramebuffer;
  32099. /** @hidden */
  32100. _getWebGLTextureType(type: number): number;
  32101. /** @hidden */
  32102. _getInternalFormat(format: number): number;
  32103. /** @hidden */
  32104. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32105. /** @hidden */
  32106. _getRGBAMultiSampleBufferFormat(type: number): number;
  32107. /** @hidden */
  32108. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32109. /**
  32110. * Loads a file from a url
  32111. * @param url url to load
  32112. * @param onSuccess callback called when the file successfully loads
  32113. * @param onProgress callback called while file is loading (if the server supports this mode)
  32114. * @param offlineProvider defines the offline provider for caching
  32115. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32116. * @param onError callback called when the file fails to load
  32117. * @returns a file request object
  32118. * @hidden
  32119. */
  32120. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  32121. /**
  32122. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32123. * @param x defines the x coordinate of the rectangle where pixels must be read
  32124. * @param y defines the y coordinate of the rectangle where pixels must be read
  32125. * @param width defines the width of the rectangle where pixels must be read
  32126. * @param height defines the height of the rectangle where pixels must be read
  32127. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32128. * @returns a Uint8Array containing RGBA colors
  32129. */
  32130. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32131. private static _isSupported;
  32132. /**
  32133. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32134. * @returns true if the engine can be created
  32135. * @ignorenaming
  32136. */
  32137. static isSupported(): boolean;
  32138. /**
  32139. * Find the next highest power of two.
  32140. * @param x Number to start search from.
  32141. * @return Next highest power of two.
  32142. */
  32143. static CeilingPOT(x: number): number;
  32144. /**
  32145. * Find the next lowest power of two.
  32146. * @param x Number to start search from.
  32147. * @return Next lowest power of two.
  32148. */
  32149. static FloorPOT(x: number): number;
  32150. /**
  32151. * Find the nearest power of two.
  32152. * @param x Number to start search from.
  32153. * @return Next nearest power of two.
  32154. */
  32155. static NearestPOT(x: number): number;
  32156. /**
  32157. * Get the closest exponent of two
  32158. * @param value defines the value to approximate
  32159. * @param max defines the maximum value to return
  32160. * @param mode defines how to define the closest value
  32161. * @returns closest exponent of two of the given value
  32162. */
  32163. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32164. /**
  32165. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32166. * @param func - the function to be called
  32167. * @param requester - the object that will request the next frame. Falls back to window.
  32168. * @returns frame number
  32169. */
  32170. static QueueNewFrame(func: () => void, requester?: any): number;
  32171. /**
  32172. * Gets host document
  32173. * @returns the host document object
  32174. */
  32175. getHostDocument(): Nullable<Document>;
  32176. }
  32177. }
  32178. declare module BABYLON {
  32179. /**
  32180. * Class representing spherical harmonics coefficients to the 3rd degree
  32181. */
  32182. export class SphericalHarmonics {
  32183. /**
  32184. * Defines whether or not the harmonics have been prescaled for rendering.
  32185. */
  32186. preScaled: boolean;
  32187. /**
  32188. * The l0,0 coefficients of the spherical harmonics
  32189. */
  32190. l00: Vector3;
  32191. /**
  32192. * The l1,-1 coefficients of the spherical harmonics
  32193. */
  32194. l1_1: Vector3;
  32195. /**
  32196. * The l1,0 coefficients of the spherical harmonics
  32197. */
  32198. l10: Vector3;
  32199. /**
  32200. * The l1,1 coefficients of the spherical harmonics
  32201. */
  32202. l11: Vector3;
  32203. /**
  32204. * The l2,-2 coefficients of the spherical harmonics
  32205. */
  32206. l2_2: Vector3;
  32207. /**
  32208. * The l2,-1 coefficients of the spherical harmonics
  32209. */
  32210. l2_1: Vector3;
  32211. /**
  32212. * The l2,0 coefficients of the spherical harmonics
  32213. */
  32214. l20: Vector3;
  32215. /**
  32216. * The l2,1 coefficients of the spherical harmonics
  32217. */
  32218. l21: Vector3;
  32219. /**
  32220. * The l2,2 coefficients of the spherical harmonics
  32221. */
  32222. l22: Vector3;
  32223. /**
  32224. * Adds a light to the spherical harmonics
  32225. * @param direction the direction of the light
  32226. * @param color the color of the light
  32227. * @param deltaSolidAngle the delta solid angle of the light
  32228. */
  32229. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32230. /**
  32231. * Scales the spherical harmonics by the given amount
  32232. * @param scale the amount to scale
  32233. */
  32234. scaleInPlace(scale: number): void;
  32235. /**
  32236. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32237. *
  32238. * ```
  32239. * E_lm = A_l * L_lm
  32240. * ```
  32241. *
  32242. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32243. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32244. * the scaling factors are given in equation 9.
  32245. */
  32246. convertIncidentRadianceToIrradiance(): void;
  32247. /**
  32248. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32249. *
  32250. * ```
  32251. * L = (1/pi) * E * rho
  32252. * ```
  32253. *
  32254. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32255. */
  32256. convertIrradianceToLambertianRadiance(): void;
  32257. /**
  32258. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32259. * required operations at run time.
  32260. *
  32261. * This is simply done by scaling back the SH with Ylm constants parameter.
  32262. * The trigonometric part being applied by the shader at run time.
  32263. */
  32264. preScaleForRendering(): void;
  32265. /**
  32266. * Constructs a spherical harmonics from an array.
  32267. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32268. * @returns the spherical harmonics
  32269. */
  32270. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32271. /**
  32272. * Gets the spherical harmonics from polynomial
  32273. * @param polynomial the spherical polynomial
  32274. * @returns the spherical harmonics
  32275. */
  32276. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32277. }
  32278. /**
  32279. * Class representing spherical polynomial coefficients to the 3rd degree
  32280. */
  32281. export class SphericalPolynomial {
  32282. private _harmonics;
  32283. /**
  32284. * The spherical harmonics used to create the polynomials.
  32285. */
  32286. get preScaledHarmonics(): SphericalHarmonics;
  32287. /**
  32288. * The x coefficients of the spherical polynomial
  32289. */
  32290. x: Vector3;
  32291. /**
  32292. * The y coefficients of the spherical polynomial
  32293. */
  32294. y: Vector3;
  32295. /**
  32296. * The z coefficients of the spherical polynomial
  32297. */
  32298. z: Vector3;
  32299. /**
  32300. * The xx coefficients of the spherical polynomial
  32301. */
  32302. xx: Vector3;
  32303. /**
  32304. * The yy coefficients of the spherical polynomial
  32305. */
  32306. yy: Vector3;
  32307. /**
  32308. * The zz coefficients of the spherical polynomial
  32309. */
  32310. zz: Vector3;
  32311. /**
  32312. * The xy coefficients of the spherical polynomial
  32313. */
  32314. xy: Vector3;
  32315. /**
  32316. * The yz coefficients of the spherical polynomial
  32317. */
  32318. yz: Vector3;
  32319. /**
  32320. * The zx coefficients of the spherical polynomial
  32321. */
  32322. zx: Vector3;
  32323. /**
  32324. * Adds an ambient color to the spherical polynomial
  32325. * @param color the color to add
  32326. */
  32327. addAmbient(color: Color3): void;
  32328. /**
  32329. * Scales the spherical polynomial by the given amount
  32330. * @param scale the amount to scale
  32331. */
  32332. scaleInPlace(scale: number): void;
  32333. /**
  32334. * Gets the spherical polynomial from harmonics
  32335. * @param harmonics the spherical harmonics
  32336. * @returns the spherical polynomial
  32337. */
  32338. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32339. /**
  32340. * Constructs a spherical polynomial from an array.
  32341. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32342. * @returns the spherical polynomial
  32343. */
  32344. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32345. }
  32346. }
  32347. declare module BABYLON {
  32348. /**
  32349. * Defines the source of the internal texture
  32350. */
  32351. export enum InternalTextureSource {
  32352. /**
  32353. * The source of the texture data is unknown
  32354. */
  32355. Unknown = 0,
  32356. /**
  32357. * Texture data comes from an URL
  32358. */
  32359. Url = 1,
  32360. /**
  32361. * Texture data is only used for temporary storage
  32362. */
  32363. Temp = 2,
  32364. /**
  32365. * Texture data comes from raw data (ArrayBuffer)
  32366. */
  32367. Raw = 3,
  32368. /**
  32369. * Texture content is dynamic (video or dynamic texture)
  32370. */
  32371. Dynamic = 4,
  32372. /**
  32373. * Texture content is generated by rendering to it
  32374. */
  32375. RenderTarget = 5,
  32376. /**
  32377. * Texture content is part of a multi render target process
  32378. */
  32379. MultiRenderTarget = 6,
  32380. /**
  32381. * Texture data comes from a cube data file
  32382. */
  32383. Cube = 7,
  32384. /**
  32385. * Texture data comes from a raw cube data
  32386. */
  32387. CubeRaw = 8,
  32388. /**
  32389. * Texture data come from a prefiltered cube data file
  32390. */
  32391. CubePrefiltered = 9,
  32392. /**
  32393. * Texture content is raw 3D data
  32394. */
  32395. Raw3D = 10,
  32396. /**
  32397. * Texture content is raw 2D array data
  32398. */
  32399. Raw2DArray = 11,
  32400. /**
  32401. * Texture content is a depth texture
  32402. */
  32403. Depth = 12,
  32404. /**
  32405. * Texture data comes from a raw cube data encoded with RGBD
  32406. */
  32407. CubeRawRGBD = 13
  32408. }
  32409. /**
  32410. * Class used to store data associated with WebGL texture data for the engine
  32411. * This class should not be used directly
  32412. */
  32413. export class InternalTexture {
  32414. /** @hidden */
  32415. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32416. /**
  32417. * Defines if the texture is ready
  32418. */
  32419. isReady: boolean;
  32420. /**
  32421. * Defines if the texture is a cube texture
  32422. */
  32423. isCube: boolean;
  32424. /**
  32425. * Defines if the texture contains 3D data
  32426. */
  32427. is3D: boolean;
  32428. /**
  32429. * Defines if the texture contains 2D array data
  32430. */
  32431. is2DArray: boolean;
  32432. /**
  32433. * Defines if the texture contains multiview data
  32434. */
  32435. isMultiview: boolean;
  32436. /**
  32437. * Gets the URL used to load this texture
  32438. */
  32439. url: string;
  32440. /**
  32441. * Gets the sampling mode of the texture
  32442. */
  32443. samplingMode: number;
  32444. /**
  32445. * Gets a boolean indicating if the texture needs mipmaps generation
  32446. */
  32447. generateMipMaps: boolean;
  32448. /**
  32449. * Gets the number of samples used by the texture (WebGL2+ only)
  32450. */
  32451. samples: number;
  32452. /**
  32453. * Gets the type of the texture (int, float...)
  32454. */
  32455. type: number;
  32456. /**
  32457. * Gets the format of the texture (RGB, RGBA...)
  32458. */
  32459. format: number;
  32460. /**
  32461. * Observable called when the texture is loaded
  32462. */
  32463. onLoadedObservable: Observable<InternalTexture>;
  32464. /**
  32465. * Gets the width of the texture
  32466. */
  32467. width: number;
  32468. /**
  32469. * Gets the height of the texture
  32470. */
  32471. height: number;
  32472. /**
  32473. * Gets the depth of the texture
  32474. */
  32475. depth: number;
  32476. /**
  32477. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32478. */
  32479. baseWidth: number;
  32480. /**
  32481. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32482. */
  32483. baseHeight: number;
  32484. /**
  32485. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32486. */
  32487. baseDepth: number;
  32488. /**
  32489. * Gets a boolean indicating if the texture is inverted on Y axis
  32490. */
  32491. invertY: boolean;
  32492. /** @hidden */
  32493. _invertVScale: boolean;
  32494. /** @hidden */
  32495. _associatedChannel: number;
  32496. /** @hidden */
  32497. _source: InternalTextureSource;
  32498. /** @hidden */
  32499. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32500. /** @hidden */
  32501. _bufferView: Nullable<ArrayBufferView>;
  32502. /** @hidden */
  32503. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32504. /** @hidden */
  32505. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32506. /** @hidden */
  32507. _size: number;
  32508. /** @hidden */
  32509. _extension: string;
  32510. /** @hidden */
  32511. _files: Nullable<string[]>;
  32512. /** @hidden */
  32513. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32514. /** @hidden */
  32515. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32516. /** @hidden */
  32517. _framebuffer: Nullable<WebGLFramebuffer>;
  32518. /** @hidden */
  32519. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32520. /** @hidden */
  32521. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32522. /** @hidden */
  32523. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32524. /** @hidden */
  32525. _attachments: Nullable<number[]>;
  32526. /** @hidden */
  32527. _cachedCoordinatesMode: Nullable<number>;
  32528. /** @hidden */
  32529. _cachedWrapU: Nullable<number>;
  32530. /** @hidden */
  32531. _cachedWrapV: Nullable<number>;
  32532. /** @hidden */
  32533. _cachedWrapR: Nullable<number>;
  32534. /** @hidden */
  32535. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32536. /** @hidden */
  32537. _isDisabled: boolean;
  32538. /** @hidden */
  32539. _compression: Nullable<string>;
  32540. /** @hidden */
  32541. _generateStencilBuffer: boolean;
  32542. /** @hidden */
  32543. _generateDepthBuffer: boolean;
  32544. /** @hidden */
  32545. _comparisonFunction: number;
  32546. /** @hidden */
  32547. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32548. /** @hidden */
  32549. _lodGenerationScale: number;
  32550. /** @hidden */
  32551. _lodGenerationOffset: number;
  32552. /** @hidden */
  32553. _depthStencilTexture: Nullable<InternalTexture>;
  32554. /** @hidden */
  32555. _colorTextureArray: Nullable<WebGLTexture>;
  32556. /** @hidden */
  32557. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32558. /** @hidden */
  32559. _lodTextureHigh: Nullable<BaseTexture>;
  32560. /** @hidden */
  32561. _lodTextureMid: Nullable<BaseTexture>;
  32562. /** @hidden */
  32563. _lodTextureLow: Nullable<BaseTexture>;
  32564. /** @hidden */
  32565. _isRGBD: boolean;
  32566. /** @hidden */
  32567. _linearSpecularLOD: boolean;
  32568. /** @hidden */
  32569. _irradianceTexture: Nullable<BaseTexture>;
  32570. /** @hidden */
  32571. _webGLTexture: Nullable<WebGLTexture>;
  32572. /** @hidden */
  32573. _references: number;
  32574. private _engine;
  32575. /**
  32576. * Gets the Engine the texture belongs to.
  32577. * @returns The babylon engine
  32578. */
  32579. getEngine(): ThinEngine;
  32580. /**
  32581. * Gets the data source type of the texture
  32582. */
  32583. get source(): InternalTextureSource;
  32584. /**
  32585. * Creates a new InternalTexture
  32586. * @param engine defines the engine to use
  32587. * @param source defines the type of data that will be used
  32588. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32589. */
  32590. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32591. /**
  32592. * Increments the number of references (ie. the number of Texture that point to it)
  32593. */
  32594. incrementReferences(): void;
  32595. /**
  32596. * Change the size of the texture (not the size of the content)
  32597. * @param width defines the new width
  32598. * @param height defines the new height
  32599. * @param depth defines the new depth (1 by default)
  32600. */
  32601. updateSize(width: int, height: int, depth?: int): void;
  32602. /** @hidden */
  32603. _rebuild(): void;
  32604. /** @hidden */
  32605. _swapAndDie(target: InternalTexture): void;
  32606. /**
  32607. * Dispose the current allocated resources
  32608. */
  32609. dispose(): void;
  32610. }
  32611. }
  32612. declare module BABYLON {
  32613. /**
  32614. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32616. */
  32617. export class Analyser {
  32618. /**
  32619. * Gets or sets the smoothing
  32620. * @ignorenaming
  32621. */
  32622. SMOOTHING: number;
  32623. /**
  32624. * Gets or sets the FFT table size
  32625. * @ignorenaming
  32626. */
  32627. FFT_SIZE: number;
  32628. /**
  32629. * Gets or sets the bar graph amplitude
  32630. * @ignorenaming
  32631. */
  32632. BARGRAPHAMPLITUDE: number;
  32633. /**
  32634. * Gets or sets the position of the debug canvas
  32635. * @ignorenaming
  32636. */
  32637. DEBUGCANVASPOS: {
  32638. x: number;
  32639. y: number;
  32640. };
  32641. /**
  32642. * Gets or sets the debug canvas size
  32643. * @ignorenaming
  32644. */
  32645. DEBUGCANVASSIZE: {
  32646. width: number;
  32647. height: number;
  32648. };
  32649. private _byteFreqs;
  32650. private _byteTime;
  32651. private _floatFreqs;
  32652. private _webAudioAnalyser;
  32653. private _debugCanvas;
  32654. private _debugCanvasContext;
  32655. private _scene;
  32656. private _registerFunc;
  32657. private _audioEngine;
  32658. /**
  32659. * Creates a new analyser
  32660. * @param scene defines hosting scene
  32661. */
  32662. constructor(scene: Scene);
  32663. /**
  32664. * Get the number of data values you will have to play with for the visualization
  32665. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32666. * @returns a number
  32667. */
  32668. getFrequencyBinCount(): number;
  32669. /**
  32670. * Gets the current frequency data as a byte array
  32671. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32672. * @returns a Uint8Array
  32673. */
  32674. getByteFrequencyData(): Uint8Array;
  32675. /**
  32676. * Gets the current waveform as a byte array
  32677. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32678. * @returns a Uint8Array
  32679. */
  32680. getByteTimeDomainData(): Uint8Array;
  32681. /**
  32682. * Gets the current frequency data as a float array
  32683. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32684. * @returns a Float32Array
  32685. */
  32686. getFloatFrequencyData(): Float32Array;
  32687. /**
  32688. * Renders the debug canvas
  32689. */
  32690. drawDebugCanvas(): void;
  32691. /**
  32692. * Stops rendering the debug canvas and removes it
  32693. */
  32694. stopDebugCanvas(): void;
  32695. /**
  32696. * Connects two audio nodes
  32697. * @param inputAudioNode defines first node to connect
  32698. * @param outputAudioNode defines second node to connect
  32699. */
  32700. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32701. /**
  32702. * Releases all associated resources
  32703. */
  32704. dispose(): void;
  32705. }
  32706. }
  32707. declare module BABYLON {
  32708. /**
  32709. * This represents an audio engine and it is responsible
  32710. * to play, synchronize and analyse sounds throughout the application.
  32711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32712. */
  32713. export interface IAudioEngine extends IDisposable {
  32714. /**
  32715. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32716. */
  32717. readonly canUseWebAudio: boolean;
  32718. /**
  32719. * Gets the current AudioContext if available.
  32720. */
  32721. readonly audioContext: Nullable<AudioContext>;
  32722. /**
  32723. * The master gain node defines the global audio volume of your audio engine.
  32724. */
  32725. readonly masterGain: GainNode;
  32726. /**
  32727. * Gets whether or not mp3 are supported by your browser.
  32728. */
  32729. readonly isMP3supported: boolean;
  32730. /**
  32731. * Gets whether or not ogg are supported by your browser.
  32732. */
  32733. readonly isOGGsupported: boolean;
  32734. /**
  32735. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32736. * @ignoreNaming
  32737. */
  32738. WarnedWebAudioUnsupported: boolean;
  32739. /**
  32740. * Defines if the audio engine relies on a custom unlocked button.
  32741. * In this case, the embedded button will not be displayed.
  32742. */
  32743. useCustomUnlockedButton: boolean;
  32744. /**
  32745. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32746. */
  32747. readonly unlocked: boolean;
  32748. /**
  32749. * Event raised when audio has been unlocked on the browser.
  32750. */
  32751. onAudioUnlockedObservable: Observable<AudioEngine>;
  32752. /**
  32753. * Event raised when audio has been locked on the browser.
  32754. */
  32755. onAudioLockedObservable: Observable<AudioEngine>;
  32756. /**
  32757. * Flags the audio engine in Locked state.
  32758. * This happens due to new browser policies preventing audio to autoplay.
  32759. */
  32760. lock(): void;
  32761. /**
  32762. * Unlocks the audio engine once a user action has been done on the dom.
  32763. * This is helpful to resume play once browser policies have been satisfied.
  32764. */
  32765. unlock(): void;
  32766. /**
  32767. * Gets the global volume sets on the master gain.
  32768. * @returns the global volume if set or -1 otherwise
  32769. */
  32770. getGlobalVolume(): number;
  32771. /**
  32772. * Sets the global volume of your experience (sets on the master gain).
  32773. * @param newVolume Defines the new global volume of the application
  32774. */
  32775. setGlobalVolume(newVolume: number): void;
  32776. /**
  32777. * Connect the audio engine to an audio analyser allowing some amazing
  32778. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32780. * @param analyser The analyser to connect to the engine
  32781. */
  32782. connectToAnalyser(analyser: Analyser): void;
  32783. }
  32784. /**
  32785. * This represents the default audio engine used in babylon.
  32786. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32788. */
  32789. export class AudioEngine implements IAudioEngine {
  32790. private _audioContext;
  32791. private _audioContextInitialized;
  32792. private _muteButton;
  32793. private _hostElement;
  32794. /**
  32795. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32796. */
  32797. canUseWebAudio: boolean;
  32798. /**
  32799. * The master gain node defines the global audio volume of your audio engine.
  32800. */
  32801. masterGain: GainNode;
  32802. /**
  32803. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32804. * @ignoreNaming
  32805. */
  32806. WarnedWebAudioUnsupported: boolean;
  32807. /**
  32808. * Gets whether or not mp3 are supported by your browser.
  32809. */
  32810. isMP3supported: boolean;
  32811. /**
  32812. * Gets whether or not ogg are supported by your browser.
  32813. */
  32814. isOGGsupported: boolean;
  32815. /**
  32816. * Gets whether audio has been unlocked on the device.
  32817. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32818. * a user interaction has happened.
  32819. */
  32820. unlocked: boolean;
  32821. /**
  32822. * Defines if the audio engine relies on a custom unlocked button.
  32823. * In this case, the embedded button will not be displayed.
  32824. */
  32825. useCustomUnlockedButton: boolean;
  32826. /**
  32827. * Event raised when audio has been unlocked on the browser.
  32828. */
  32829. onAudioUnlockedObservable: Observable<AudioEngine>;
  32830. /**
  32831. * Event raised when audio has been locked on the browser.
  32832. */
  32833. onAudioLockedObservable: Observable<AudioEngine>;
  32834. /**
  32835. * Gets the current AudioContext if available.
  32836. */
  32837. get audioContext(): Nullable<AudioContext>;
  32838. private _connectedAnalyser;
  32839. /**
  32840. * Instantiates a new audio engine.
  32841. *
  32842. * There should be only one per page as some browsers restrict the number
  32843. * of audio contexts you can create.
  32844. * @param hostElement defines the host element where to display the mute icon if necessary
  32845. */
  32846. constructor(hostElement?: Nullable<HTMLElement>);
  32847. /**
  32848. * Flags the audio engine in Locked state.
  32849. * This happens due to new browser policies preventing audio to autoplay.
  32850. */
  32851. lock(): void;
  32852. /**
  32853. * Unlocks the audio engine once a user action has been done on the dom.
  32854. * This is helpful to resume play once browser policies have been satisfied.
  32855. */
  32856. unlock(): void;
  32857. private _resumeAudioContext;
  32858. private _initializeAudioContext;
  32859. private _tryToRun;
  32860. private _triggerRunningState;
  32861. private _triggerSuspendedState;
  32862. private _displayMuteButton;
  32863. private _moveButtonToTopLeft;
  32864. private _onResize;
  32865. private _hideMuteButton;
  32866. /**
  32867. * Destroy and release the resources associated with the audio ccontext.
  32868. */
  32869. dispose(): void;
  32870. /**
  32871. * Gets the global volume sets on the master gain.
  32872. * @returns the global volume if set or -1 otherwise
  32873. */
  32874. getGlobalVolume(): number;
  32875. /**
  32876. * Sets the global volume of your experience (sets on the master gain).
  32877. * @param newVolume Defines the new global volume of the application
  32878. */
  32879. setGlobalVolume(newVolume: number): void;
  32880. /**
  32881. * Connect the audio engine to an audio analyser allowing some amazing
  32882. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32884. * @param analyser The analyser to connect to the engine
  32885. */
  32886. connectToAnalyser(analyser: Analyser): void;
  32887. }
  32888. }
  32889. declare module BABYLON {
  32890. /**
  32891. * Interface used to present a loading screen while loading a scene
  32892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32893. */
  32894. export interface ILoadingScreen {
  32895. /**
  32896. * Function called to display the loading screen
  32897. */
  32898. displayLoadingUI: () => void;
  32899. /**
  32900. * Function called to hide the loading screen
  32901. */
  32902. hideLoadingUI: () => void;
  32903. /**
  32904. * Gets or sets the color to use for the background
  32905. */
  32906. loadingUIBackgroundColor: string;
  32907. /**
  32908. * Gets or sets the text to display while loading
  32909. */
  32910. loadingUIText: string;
  32911. }
  32912. /**
  32913. * Class used for the default loading screen
  32914. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32915. */
  32916. export class DefaultLoadingScreen implements ILoadingScreen {
  32917. private _renderingCanvas;
  32918. private _loadingText;
  32919. private _loadingDivBackgroundColor;
  32920. private _loadingDiv;
  32921. private _loadingTextDiv;
  32922. /** Gets or sets the logo url to use for the default loading screen */
  32923. static DefaultLogoUrl: string;
  32924. /** Gets or sets the spinner url to use for the default loading screen */
  32925. static DefaultSpinnerUrl: string;
  32926. /**
  32927. * Creates a new default loading screen
  32928. * @param _renderingCanvas defines the canvas used to render the scene
  32929. * @param _loadingText defines the default text to display
  32930. * @param _loadingDivBackgroundColor defines the default background color
  32931. */
  32932. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32933. /**
  32934. * Function called to display the loading screen
  32935. */
  32936. displayLoadingUI(): void;
  32937. /**
  32938. * Function called to hide the loading screen
  32939. */
  32940. hideLoadingUI(): void;
  32941. /**
  32942. * Gets or sets the text to display while loading
  32943. */
  32944. set loadingUIText(text: string);
  32945. get loadingUIText(): string;
  32946. /**
  32947. * Gets or sets the color to use for the background
  32948. */
  32949. get loadingUIBackgroundColor(): string;
  32950. set loadingUIBackgroundColor(color: string);
  32951. private _resizeLoadingUI;
  32952. }
  32953. }
  32954. declare module BABYLON {
  32955. /**
  32956. * Interface for any object that can request an animation frame
  32957. */
  32958. export interface ICustomAnimationFrameRequester {
  32959. /**
  32960. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32961. */
  32962. renderFunction?: Function;
  32963. /**
  32964. * Called to request the next frame to render to
  32965. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32966. */
  32967. requestAnimationFrame: Function;
  32968. /**
  32969. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32970. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32971. */
  32972. requestID?: number;
  32973. }
  32974. }
  32975. declare module BABYLON {
  32976. /**
  32977. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32978. */
  32979. export class PerformanceMonitor {
  32980. private _enabled;
  32981. private _rollingFrameTime;
  32982. private _lastFrameTimeMs;
  32983. /**
  32984. * constructor
  32985. * @param frameSampleSize The number of samples required to saturate the sliding window
  32986. */
  32987. constructor(frameSampleSize?: number);
  32988. /**
  32989. * Samples current frame
  32990. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32991. */
  32992. sampleFrame(timeMs?: number): void;
  32993. /**
  32994. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32995. */
  32996. get averageFrameTime(): number;
  32997. /**
  32998. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32999. */
  33000. get averageFrameTimeVariance(): number;
  33001. /**
  33002. * Returns the frame time of the most recent frame
  33003. */
  33004. get instantaneousFrameTime(): number;
  33005. /**
  33006. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33007. */
  33008. get averageFPS(): number;
  33009. /**
  33010. * Returns the average framerate in frames per second using the most recent frame time
  33011. */
  33012. get instantaneousFPS(): number;
  33013. /**
  33014. * Returns true if enough samples have been taken to completely fill the sliding window
  33015. */
  33016. get isSaturated(): boolean;
  33017. /**
  33018. * Enables contributions to the sliding window sample set
  33019. */
  33020. enable(): void;
  33021. /**
  33022. * Disables contributions to the sliding window sample set
  33023. * Samples will not be interpolated over the disabled period
  33024. */
  33025. disable(): void;
  33026. /**
  33027. * Returns true if sampling is enabled
  33028. */
  33029. get isEnabled(): boolean;
  33030. /**
  33031. * Resets performance monitor
  33032. */
  33033. reset(): void;
  33034. }
  33035. /**
  33036. * RollingAverage
  33037. *
  33038. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33039. */
  33040. export class RollingAverage {
  33041. /**
  33042. * Current average
  33043. */
  33044. average: number;
  33045. /**
  33046. * Current variance
  33047. */
  33048. variance: number;
  33049. protected _samples: Array<number>;
  33050. protected _sampleCount: number;
  33051. protected _pos: number;
  33052. protected _m2: number;
  33053. /**
  33054. * constructor
  33055. * @param length The number of samples required to saturate the sliding window
  33056. */
  33057. constructor(length: number);
  33058. /**
  33059. * Adds a sample to the sample set
  33060. * @param v The sample value
  33061. */
  33062. add(v: number): void;
  33063. /**
  33064. * Returns previously added values or null if outside of history or outside the sliding window domain
  33065. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33066. * @return Value previously recorded with add() or null if outside of range
  33067. */
  33068. history(i: number): number;
  33069. /**
  33070. * Returns true if enough samples have been taken to completely fill the sliding window
  33071. * @return true if sample-set saturated
  33072. */
  33073. isSaturated(): boolean;
  33074. /**
  33075. * Resets the rolling average (equivalent to 0 samples taken so far)
  33076. */
  33077. reset(): void;
  33078. /**
  33079. * Wraps a value around the sample range boundaries
  33080. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33081. * @return Wrapped position in sample range
  33082. */
  33083. protected _wrapPosition(i: number): number;
  33084. }
  33085. }
  33086. declare module BABYLON {
  33087. /**
  33088. * This class is used to track a performance counter which is number based.
  33089. * The user has access to many properties which give statistics of different nature.
  33090. *
  33091. * The implementer can track two kinds of Performance Counter: time and count.
  33092. * 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.
  33093. * 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.
  33094. */
  33095. export class PerfCounter {
  33096. /**
  33097. * Gets or sets a global boolean to turn on and off all the counters
  33098. */
  33099. static Enabled: boolean;
  33100. /**
  33101. * Returns the smallest value ever
  33102. */
  33103. get min(): number;
  33104. /**
  33105. * Returns the biggest value ever
  33106. */
  33107. get max(): number;
  33108. /**
  33109. * Returns the average value since the performance counter is running
  33110. */
  33111. get average(): number;
  33112. /**
  33113. * Returns the average value of the last second the counter was monitored
  33114. */
  33115. get lastSecAverage(): number;
  33116. /**
  33117. * Returns the current value
  33118. */
  33119. get current(): number;
  33120. /**
  33121. * Gets the accumulated total
  33122. */
  33123. get total(): number;
  33124. /**
  33125. * Gets the total value count
  33126. */
  33127. get count(): number;
  33128. /**
  33129. * Creates a new counter
  33130. */
  33131. constructor();
  33132. /**
  33133. * Call this method to start monitoring a new frame.
  33134. * 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.
  33135. */
  33136. fetchNewFrame(): void;
  33137. /**
  33138. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33139. * @param newCount the count value to add to the monitored count
  33140. * @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.
  33141. */
  33142. addCount(newCount: number, fetchResult: boolean): void;
  33143. /**
  33144. * Start monitoring this performance counter
  33145. */
  33146. beginMonitoring(): void;
  33147. /**
  33148. * Compute the time lapsed since the previous beginMonitoring() call.
  33149. * @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
  33150. */
  33151. endMonitoring(newFrame?: boolean): void;
  33152. private _fetchResult;
  33153. private _startMonitoringTime;
  33154. private _min;
  33155. private _max;
  33156. private _average;
  33157. private _current;
  33158. private _totalValueCount;
  33159. private _totalAccumulated;
  33160. private _lastSecAverage;
  33161. private _lastSecAccumulated;
  33162. private _lastSecTime;
  33163. private _lastSecValueCount;
  33164. }
  33165. }
  33166. declare module BABYLON {
  33167. interface ThinEngine {
  33168. /**
  33169. * Sets alpha constants used by some alpha blending modes
  33170. * @param r defines the red component
  33171. * @param g defines the green component
  33172. * @param b defines the blue component
  33173. * @param a defines the alpha component
  33174. */
  33175. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33176. /**
  33177. * Sets the current alpha mode
  33178. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33179. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33180. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33181. */
  33182. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33183. /**
  33184. * Gets the current alpha mode
  33185. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33186. * @returns the current alpha mode
  33187. */
  33188. getAlphaMode(): number;
  33189. /**
  33190. * Sets the current alpha equation
  33191. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33192. */
  33193. setAlphaEquation(equation: number): void;
  33194. /**
  33195. * Gets the current alpha equation.
  33196. * @returns the current alpha equation
  33197. */
  33198. getAlphaEquation(): number;
  33199. }
  33200. }
  33201. declare module BABYLON {
  33202. /**
  33203. * Defines the interface used by display changed events
  33204. */
  33205. export interface IDisplayChangedEventArgs {
  33206. /** Gets the vrDisplay object (if any) */
  33207. vrDisplay: Nullable<any>;
  33208. /** Gets a boolean indicating if webVR is supported */
  33209. vrSupported: boolean;
  33210. }
  33211. /**
  33212. * Defines the interface used by objects containing a viewport (like a camera)
  33213. */
  33214. interface IViewportOwnerLike {
  33215. /**
  33216. * Gets or sets the viewport
  33217. */
  33218. viewport: IViewportLike;
  33219. }
  33220. /**
  33221. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33222. */
  33223. export class Engine extends ThinEngine {
  33224. /** Defines that alpha blending is disabled */
  33225. static readonly ALPHA_DISABLE: number;
  33226. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33227. static readonly ALPHA_ADD: number;
  33228. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33229. static readonly ALPHA_COMBINE: number;
  33230. /** Defines that alpha blending to DEST - SRC * DEST */
  33231. static readonly ALPHA_SUBTRACT: number;
  33232. /** Defines that alpha blending to SRC * DEST */
  33233. static readonly ALPHA_MULTIPLY: number;
  33234. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33235. static readonly ALPHA_MAXIMIZED: number;
  33236. /** Defines that alpha blending to SRC + DEST */
  33237. static readonly ALPHA_ONEONE: number;
  33238. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33239. static readonly ALPHA_PREMULTIPLIED: number;
  33240. /**
  33241. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33242. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33243. */
  33244. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33245. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33246. static readonly ALPHA_INTERPOLATE: number;
  33247. /**
  33248. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33249. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33250. */
  33251. static readonly ALPHA_SCREENMODE: number;
  33252. /** Defines that the ressource is not delayed*/
  33253. static readonly DELAYLOADSTATE_NONE: number;
  33254. /** Defines that the ressource was successfully delay loaded */
  33255. static readonly DELAYLOADSTATE_LOADED: number;
  33256. /** Defines that the ressource is currently delay loading */
  33257. static readonly DELAYLOADSTATE_LOADING: number;
  33258. /** Defines that the ressource is delayed and has not started loading */
  33259. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33260. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33261. static readonly NEVER: number;
  33262. /** 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 */
  33263. static readonly ALWAYS: number;
  33264. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33265. static readonly LESS: number;
  33266. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33267. static readonly EQUAL: number;
  33268. /** 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 */
  33269. static readonly LEQUAL: number;
  33270. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33271. static readonly GREATER: number;
  33272. /** 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 */
  33273. static readonly GEQUAL: number;
  33274. /** 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 */
  33275. static readonly NOTEQUAL: number;
  33276. /** Passed to stencilOperation to specify that stencil value must be kept */
  33277. static readonly KEEP: number;
  33278. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33279. static readonly REPLACE: number;
  33280. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33281. static readonly INCR: number;
  33282. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33283. static readonly DECR: number;
  33284. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33285. static readonly INVERT: number;
  33286. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33287. static readonly INCR_WRAP: number;
  33288. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33289. static readonly DECR_WRAP: number;
  33290. /** Texture is not repeating outside of 0..1 UVs */
  33291. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33292. /** Texture is repeating outside of 0..1 UVs */
  33293. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33294. /** Texture is repeating and mirrored */
  33295. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33296. /** ALPHA */
  33297. static readonly TEXTUREFORMAT_ALPHA: number;
  33298. /** LUMINANCE */
  33299. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33300. /** LUMINANCE_ALPHA */
  33301. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33302. /** RGB */
  33303. static readonly TEXTUREFORMAT_RGB: number;
  33304. /** RGBA */
  33305. static readonly TEXTUREFORMAT_RGBA: number;
  33306. /** RED */
  33307. static readonly TEXTUREFORMAT_RED: number;
  33308. /** RED (2nd reference) */
  33309. static readonly TEXTUREFORMAT_R: number;
  33310. /** RG */
  33311. static readonly TEXTUREFORMAT_RG: number;
  33312. /** RED_INTEGER */
  33313. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33314. /** RED_INTEGER (2nd reference) */
  33315. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33316. /** RG_INTEGER */
  33317. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33318. /** RGB_INTEGER */
  33319. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33320. /** RGBA_INTEGER */
  33321. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33322. /** UNSIGNED_BYTE */
  33323. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33324. /** UNSIGNED_BYTE (2nd reference) */
  33325. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33326. /** FLOAT */
  33327. static readonly TEXTURETYPE_FLOAT: number;
  33328. /** HALF_FLOAT */
  33329. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33330. /** BYTE */
  33331. static readonly TEXTURETYPE_BYTE: number;
  33332. /** SHORT */
  33333. static readonly TEXTURETYPE_SHORT: number;
  33334. /** UNSIGNED_SHORT */
  33335. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33336. /** INT */
  33337. static readonly TEXTURETYPE_INT: number;
  33338. /** UNSIGNED_INT */
  33339. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33340. /** UNSIGNED_SHORT_4_4_4_4 */
  33341. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33342. /** UNSIGNED_SHORT_5_5_5_1 */
  33343. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33344. /** UNSIGNED_SHORT_5_6_5 */
  33345. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33346. /** UNSIGNED_INT_2_10_10_10_REV */
  33347. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33348. /** UNSIGNED_INT_24_8 */
  33349. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33350. /** UNSIGNED_INT_10F_11F_11F_REV */
  33351. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33352. /** UNSIGNED_INT_5_9_9_9_REV */
  33353. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33354. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33355. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33356. /** nearest is mag = nearest and min = nearest and mip = linear */
  33357. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33358. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33359. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33360. /** Trilinear is mag = linear and min = linear and mip = linear */
  33361. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33362. /** nearest is mag = nearest and min = nearest and mip = linear */
  33363. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33364. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33365. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33366. /** Trilinear is mag = linear and min = linear and mip = linear */
  33367. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33368. /** mag = nearest and min = nearest and mip = nearest */
  33369. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33370. /** mag = nearest and min = linear and mip = nearest */
  33371. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33372. /** mag = nearest and min = linear and mip = linear */
  33373. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33374. /** mag = nearest and min = linear and mip = none */
  33375. static readonly TEXTURE_NEAREST_LINEAR: number;
  33376. /** mag = nearest and min = nearest and mip = none */
  33377. static readonly TEXTURE_NEAREST_NEAREST: number;
  33378. /** mag = linear and min = nearest and mip = nearest */
  33379. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33380. /** mag = linear and min = nearest and mip = linear */
  33381. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33382. /** mag = linear and min = linear and mip = none */
  33383. static readonly TEXTURE_LINEAR_LINEAR: number;
  33384. /** mag = linear and min = nearest and mip = none */
  33385. static readonly TEXTURE_LINEAR_NEAREST: number;
  33386. /** Explicit coordinates mode */
  33387. static readonly TEXTURE_EXPLICIT_MODE: number;
  33388. /** Spherical coordinates mode */
  33389. static readonly TEXTURE_SPHERICAL_MODE: number;
  33390. /** Planar coordinates mode */
  33391. static readonly TEXTURE_PLANAR_MODE: number;
  33392. /** Cubic coordinates mode */
  33393. static readonly TEXTURE_CUBIC_MODE: number;
  33394. /** Projection coordinates mode */
  33395. static readonly TEXTURE_PROJECTION_MODE: number;
  33396. /** Skybox coordinates mode */
  33397. static readonly TEXTURE_SKYBOX_MODE: number;
  33398. /** Inverse Cubic coordinates mode */
  33399. static readonly TEXTURE_INVCUBIC_MODE: number;
  33400. /** Equirectangular coordinates mode */
  33401. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33402. /** Equirectangular Fixed coordinates mode */
  33403. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33404. /** Equirectangular Fixed Mirrored coordinates mode */
  33405. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33406. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33407. static readonly SCALEMODE_FLOOR: number;
  33408. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33409. static readonly SCALEMODE_NEAREST: number;
  33410. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33411. static readonly SCALEMODE_CEILING: number;
  33412. /**
  33413. * Returns the current npm package of the sdk
  33414. */
  33415. static get NpmPackage(): string;
  33416. /**
  33417. * Returns the current version of the framework
  33418. */
  33419. static get Version(): string;
  33420. /** Gets the list of created engines */
  33421. static get Instances(): Engine[];
  33422. /**
  33423. * Gets the latest created engine
  33424. */
  33425. static get LastCreatedEngine(): Nullable<Engine>;
  33426. /**
  33427. * Gets the latest created scene
  33428. */
  33429. static get LastCreatedScene(): Nullable<Scene>;
  33430. /**
  33431. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33432. * @param flag defines which part of the materials must be marked as dirty
  33433. * @param predicate defines a predicate used to filter which materials should be affected
  33434. */
  33435. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33436. /**
  33437. * Method called to create the default loading screen.
  33438. * This can be overriden in your own app.
  33439. * @param canvas The rendering canvas element
  33440. * @returns The loading screen
  33441. */
  33442. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33443. /**
  33444. * Method called to create the default rescale post process on each engine.
  33445. */
  33446. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33447. /**
  33448. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33449. **/
  33450. enableOfflineSupport: boolean;
  33451. /**
  33452. * 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)
  33453. **/
  33454. disableManifestCheck: boolean;
  33455. /**
  33456. * Gets the list of created scenes
  33457. */
  33458. scenes: Scene[];
  33459. /**
  33460. * Event raised when a new scene is created
  33461. */
  33462. onNewSceneAddedObservable: Observable<Scene>;
  33463. /**
  33464. * Gets the list of created postprocesses
  33465. */
  33466. postProcesses: PostProcess[];
  33467. /**
  33468. * Gets a boolean indicating if the pointer is currently locked
  33469. */
  33470. isPointerLock: boolean;
  33471. /**
  33472. * Observable event triggered each time the rendering canvas is resized
  33473. */
  33474. onResizeObservable: Observable<Engine>;
  33475. /**
  33476. * Observable event triggered each time the canvas loses focus
  33477. */
  33478. onCanvasBlurObservable: Observable<Engine>;
  33479. /**
  33480. * Observable event triggered each time the canvas gains focus
  33481. */
  33482. onCanvasFocusObservable: Observable<Engine>;
  33483. /**
  33484. * Observable event triggered each time the canvas receives pointerout event
  33485. */
  33486. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33487. /**
  33488. * Observable raised when the engine begins a new frame
  33489. */
  33490. onBeginFrameObservable: Observable<Engine>;
  33491. /**
  33492. * If set, will be used to request the next animation frame for the render loop
  33493. */
  33494. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33495. /**
  33496. * Observable raised when the engine ends the current frame
  33497. */
  33498. onEndFrameObservable: Observable<Engine>;
  33499. /**
  33500. * Observable raised when the engine is about to compile a shader
  33501. */
  33502. onBeforeShaderCompilationObservable: Observable<Engine>;
  33503. /**
  33504. * Observable raised when the engine has jsut compiled a shader
  33505. */
  33506. onAfterShaderCompilationObservable: Observable<Engine>;
  33507. /**
  33508. * Gets the audio engine
  33509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33510. * @ignorenaming
  33511. */
  33512. static audioEngine: IAudioEngine;
  33513. /**
  33514. * Default AudioEngine factory responsible of creating the Audio Engine.
  33515. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33516. */
  33517. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33518. /**
  33519. * Default offline support factory responsible of creating a tool used to store data locally.
  33520. * By default, this will create a Database object if the workload has been embedded.
  33521. */
  33522. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33523. private _loadingScreen;
  33524. private _pointerLockRequested;
  33525. private _dummyFramebuffer;
  33526. private _rescalePostProcess;
  33527. private _deterministicLockstep;
  33528. private _lockstepMaxSteps;
  33529. private _timeStep;
  33530. protected get _supportsHardwareTextureRescaling(): boolean;
  33531. private _fps;
  33532. private _deltaTime;
  33533. /** @hidden */
  33534. _drawCalls: PerfCounter;
  33535. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33536. canvasTabIndex: number;
  33537. /**
  33538. * Turn this value on if you want to pause FPS computation when in background
  33539. */
  33540. disablePerformanceMonitorInBackground: boolean;
  33541. private _performanceMonitor;
  33542. /**
  33543. * Gets the performance monitor attached to this engine
  33544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33545. */
  33546. get performanceMonitor(): PerformanceMonitor;
  33547. private _onFocus;
  33548. private _onBlur;
  33549. private _onCanvasPointerOut;
  33550. private _onCanvasBlur;
  33551. private _onCanvasFocus;
  33552. private _onFullscreenChange;
  33553. private _onPointerLockChange;
  33554. /**
  33555. * Gets the HTML element used to attach event listeners
  33556. * @returns a HTML element
  33557. */
  33558. getInputElement(): Nullable<HTMLElement>;
  33559. /**
  33560. * Creates a new engine
  33561. * @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
  33562. * @param antialias defines enable antialiasing (default: false)
  33563. * @param options defines further options to be sent to the getContext() function
  33564. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33565. */
  33566. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33567. /**
  33568. * Gets current aspect ratio
  33569. * @param viewportOwner defines the camera to use to get the aspect ratio
  33570. * @param useScreen defines if screen size must be used (or the current render target if any)
  33571. * @returns a number defining the aspect ratio
  33572. */
  33573. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33574. /**
  33575. * Gets current screen aspect ratio
  33576. * @returns a number defining the aspect ratio
  33577. */
  33578. getScreenAspectRatio(): number;
  33579. /**
  33580. * Gets the client rect of the HTML canvas attached with the current webGL context
  33581. * @returns a client rectanglee
  33582. */
  33583. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33584. /**
  33585. * Gets the client rect of the HTML element used for events
  33586. * @returns a client rectanglee
  33587. */
  33588. getInputElementClientRect(): Nullable<ClientRect>;
  33589. /**
  33590. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33591. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33592. * @returns true if engine is in deterministic lock step mode
  33593. */
  33594. isDeterministicLockStep(): boolean;
  33595. /**
  33596. * Gets the max steps when engine is running in deterministic lock step
  33597. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33598. * @returns the max steps
  33599. */
  33600. getLockstepMaxSteps(): number;
  33601. /**
  33602. * Returns the time in ms between steps when using deterministic lock step.
  33603. * @returns time step in (ms)
  33604. */
  33605. getTimeStep(): number;
  33606. /**
  33607. * Force the mipmap generation for the given render target texture
  33608. * @param texture defines the render target texture to use
  33609. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33610. */
  33611. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33612. /** States */
  33613. /**
  33614. * Set various states to the webGL context
  33615. * @param culling defines backface culling state
  33616. * @param zOffset defines the value to apply to zOffset (0 by default)
  33617. * @param force defines if states must be applied even if cache is up to date
  33618. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33619. */
  33620. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33621. /**
  33622. * Set the z offset to apply to current rendering
  33623. * @param value defines the offset to apply
  33624. */
  33625. setZOffset(value: number): void;
  33626. /**
  33627. * Gets the current value of the zOffset
  33628. * @returns the current zOffset state
  33629. */
  33630. getZOffset(): number;
  33631. /**
  33632. * Enable or disable depth buffering
  33633. * @param enable defines the state to set
  33634. */
  33635. setDepthBuffer(enable: boolean): void;
  33636. /**
  33637. * Gets a boolean indicating if depth writing is enabled
  33638. * @returns the current depth writing state
  33639. */
  33640. getDepthWrite(): boolean;
  33641. /**
  33642. * Enable or disable depth writing
  33643. * @param enable defines the state to set
  33644. */
  33645. setDepthWrite(enable: boolean): void;
  33646. /**
  33647. * Gets a boolean indicating if stencil buffer is enabled
  33648. * @returns the current stencil buffer state
  33649. */
  33650. getStencilBuffer(): boolean;
  33651. /**
  33652. * Enable or disable the stencil buffer
  33653. * @param enable defines if the stencil buffer must be enabled or disabled
  33654. */
  33655. setStencilBuffer(enable: boolean): void;
  33656. /**
  33657. * Gets the current stencil mask
  33658. * @returns a number defining the new stencil mask to use
  33659. */
  33660. getStencilMask(): number;
  33661. /**
  33662. * Sets the current stencil mask
  33663. * @param mask defines the new stencil mask to use
  33664. */
  33665. setStencilMask(mask: number): void;
  33666. /**
  33667. * Gets the current stencil function
  33668. * @returns a number defining the stencil function to use
  33669. */
  33670. getStencilFunction(): number;
  33671. /**
  33672. * Gets the current stencil reference value
  33673. * @returns a number defining the stencil reference value to use
  33674. */
  33675. getStencilFunctionReference(): number;
  33676. /**
  33677. * Gets the current stencil mask
  33678. * @returns a number defining the stencil mask to use
  33679. */
  33680. getStencilFunctionMask(): number;
  33681. /**
  33682. * Sets the current stencil function
  33683. * @param stencilFunc defines the new stencil function to use
  33684. */
  33685. setStencilFunction(stencilFunc: number): void;
  33686. /**
  33687. * Sets the current stencil reference
  33688. * @param reference defines the new stencil reference to use
  33689. */
  33690. setStencilFunctionReference(reference: number): void;
  33691. /**
  33692. * Sets the current stencil mask
  33693. * @param mask defines the new stencil mask to use
  33694. */
  33695. setStencilFunctionMask(mask: number): void;
  33696. /**
  33697. * Gets the current stencil operation when stencil fails
  33698. * @returns a number defining stencil operation to use when stencil fails
  33699. */
  33700. getStencilOperationFail(): number;
  33701. /**
  33702. * Gets the current stencil operation when depth fails
  33703. * @returns a number defining stencil operation to use when depth fails
  33704. */
  33705. getStencilOperationDepthFail(): number;
  33706. /**
  33707. * Gets the current stencil operation when stencil passes
  33708. * @returns a number defining stencil operation to use when stencil passes
  33709. */
  33710. getStencilOperationPass(): number;
  33711. /**
  33712. * Sets the stencil operation to use when stencil fails
  33713. * @param operation defines the stencil operation to use when stencil fails
  33714. */
  33715. setStencilOperationFail(operation: number): void;
  33716. /**
  33717. * Sets the stencil operation to use when depth fails
  33718. * @param operation defines the stencil operation to use when depth fails
  33719. */
  33720. setStencilOperationDepthFail(operation: number): void;
  33721. /**
  33722. * Sets the stencil operation to use when stencil passes
  33723. * @param operation defines the stencil operation to use when stencil passes
  33724. */
  33725. setStencilOperationPass(operation: number): void;
  33726. /**
  33727. * Sets a boolean indicating if the dithering state is enabled or disabled
  33728. * @param value defines the dithering state
  33729. */
  33730. setDitheringState(value: boolean): void;
  33731. /**
  33732. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33733. * @param value defines the rasterizer state
  33734. */
  33735. setRasterizerState(value: boolean): void;
  33736. /**
  33737. * Gets the current depth function
  33738. * @returns a number defining the depth function
  33739. */
  33740. getDepthFunction(): Nullable<number>;
  33741. /**
  33742. * Sets the current depth function
  33743. * @param depthFunc defines the function to use
  33744. */
  33745. setDepthFunction(depthFunc: number): void;
  33746. /**
  33747. * Sets the current depth function to GREATER
  33748. */
  33749. setDepthFunctionToGreater(): void;
  33750. /**
  33751. * Sets the current depth function to GEQUAL
  33752. */
  33753. setDepthFunctionToGreaterOrEqual(): void;
  33754. /**
  33755. * Sets the current depth function to LESS
  33756. */
  33757. setDepthFunctionToLess(): void;
  33758. /**
  33759. * Sets the current depth function to LEQUAL
  33760. */
  33761. setDepthFunctionToLessOrEqual(): void;
  33762. private _cachedStencilBuffer;
  33763. private _cachedStencilFunction;
  33764. private _cachedStencilMask;
  33765. private _cachedStencilOperationPass;
  33766. private _cachedStencilOperationFail;
  33767. private _cachedStencilOperationDepthFail;
  33768. private _cachedStencilReference;
  33769. /**
  33770. * Caches the the state of the stencil buffer
  33771. */
  33772. cacheStencilState(): void;
  33773. /**
  33774. * Restores the state of the stencil buffer
  33775. */
  33776. restoreStencilState(): void;
  33777. /**
  33778. * Directly set the WebGL Viewport
  33779. * @param x defines the x coordinate of the viewport (in screen space)
  33780. * @param y defines the y coordinate of the viewport (in screen space)
  33781. * @param width defines the width of the viewport (in screen space)
  33782. * @param height defines the height of the viewport (in screen space)
  33783. * @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
  33784. */
  33785. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33786. /**
  33787. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33788. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33789. * @param y defines the y-coordinate of the corner of the clear rectangle
  33790. * @param width defines the width of the clear rectangle
  33791. * @param height defines the height of the clear rectangle
  33792. * @param clearColor defines the clear color
  33793. */
  33794. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33795. /**
  33796. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33797. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33798. * @param y defines the y-coordinate of the corner of the clear rectangle
  33799. * @param width defines the width of the clear rectangle
  33800. * @param height defines the height of the clear rectangle
  33801. */
  33802. enableScissor(x: number, y: number, width: number, height: number): void;
  33803. /**
  33804. * Disable previously set scissor test rectangle
  33805. */
  33806. disableScissor(): void;
  33807. protected _reportDrawCall(): void;
  33808. /**
  33809. * Initializes a webVR display and starts listening to display change events
  33810. * The onVRDisplayChangedObservable will be notified upon these changes
  33811. * @returns The onVRDisplayChangedObservable
  33812. */
  33813. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33814. /** @hidden */
  33815. _prepareVRComponent(): void;
  33816. /** @hidden */
  33817. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33818. /** @hidden */
  33819. _submitVRFrame(): void;
  33820. /**
  33821. * Call this function to leave webVR mode
  33822. * Will do nothing if webVR is not supported or if there is no webVR device
  33823. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33824. */
  33825. disableVR(): void;
  33826. /**
  33827. * Gets a boolean indicating that the system is in VR mode and is presenting
  33828. * @returns true if VR mode is engaged
  33829. */
  33830. isVRPresenting(): boolean;
  33831. /** @hidden */
  33832. _requestVRFrame(): void;
  33833. /** @hidden */
  33834. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33835. /**
  33836. * Gets the source code of the vertex shader associated with a specific webGL program
  33837. * @param program defines the program to use
  33838. * @returns a string containing the source code of the vertex shader associated with the program
  33839. */
  33840. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33841. /**
  33842. * Gets the source code of the fragment shader associated with a specific webGL program
  33843. * @param program defines the program to use
  33844. * @returns a string containing the source code of the fragment shader associated with the program
  33845. */
  33846. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33847. /**
  33848. * Sets a depth stencil texture from a render target to the according uniform.
  33849. * @param channel The texture channel
  33850. * @param uniform The uniform to set
  33851. * @param texture The render target texture containing the depth stencil texture to apply
  33852. */
  33853. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33854. /**
  33855. * Sets a texture to the webGL context from a postprocess
  33856. * @param channel defines the channel to use
  33857. * @param postProcess defines the source postprocess
  33858. */
  33859. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33860. /**
  33861. * Binds the output of the passed in post process to the texture channel specified
  33862. * @param channel The channel the texture should be bound to
  33863. * @param postProcess The post process which's output should be bound
  33864. */
  33865. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33866. /** @hidden */
  33867. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33868. protected _rebuildBuffers(): void;
  33869. /** @hidden */
  33870. _renderFrame(): void;
  33871. _renderLoop(): void;
  33872. /** @hidden */
  33873. _renderViews(): boolean;
  33874. /**
  33875. * Toggle full screen mode
  33876. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33877. */
  33878. switchFullscreen(requestPointerLock: boolean): void;
  33879. /**
  33880. * Enters full screen mode
  33881. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33882. */
  33883. enterFullscreen(requestPointerLock: boolean): void;
  33884. /**
  33885. * Exits full screen mode
  33886. */
  33887. exitFullscreen(): void;
  33888. /**
  33889. * Enters Pointerlock mode
  33890. */
  33891. enterPointerlock(): void;
  33892. /**
  33893. * Exits Pointerlock mode
  33894. */
  33895. exitPointerlock(): void;
  33896. /**
  33897. * Begin a new frame
  33898. */
  33899. beginFrame(): void;
  33900. /**
  33901. * Enf the current frame
  33902. */
  33903. endFrame(): void;
  33904. resize(): void;
  33905. /**
  33906. * Force a specific size of the canvas
  33907. * @param width defines the new canvas' width
  33908. * @param height defines the new canvas' height
  33909. */
  33910. setSize(width: number, height: number): void;
  33911. /**
  33912. * Updates a dynamic vertex buffer.
  33913. * @param vertexBuffer the vertex buffer to update
  33914. * @param data the data used to update the vertex buffer
  33915. * @param byteOffset the byte offset of the data
  33916. * @param byteLength the byte length of the data
  33917. */
  33918. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33919. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33920. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33921. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33922. _releaseTexture(texture: InternalTexture): void;
  33923. /**
  33924. * @hidden
  33925. * Rescales a texture
  33926. * @param source input texutre
  33927. * @param destination destination texture
  33928. * @param scene scene to use to render the resize
  33929. * @param internalFormat format to use when resizing
  33930. * @param onComplete callback to be called when resize has completed
  33931. */
  33932. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33933. /**
  33934. * Gets the current framerate
  33935. * @returns a number representing the framerate
  33936. */
  33937. getFps(): number;
  33938. /**
  33939. * Gets the time spent between current and previous frame
  33940. * @returns a number representing the delta time in ms
  33941. */
  33942. getDeltaTime(): number;
  33943. private _measureFps;
  33944. /** @hidden */
  33945. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33946. /**
  33947. * Update a dynamic index buffer
  33948. * @param indexBuffer defines the target index buffer
  33949. * @param indices defines the data to update
  33950. * @param offset defines the offset in the target index buffer where update should start
  33951. */
  33952. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33953. /**
  33954. * Updates the sample count of a render target texture
  33955. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33956. * @param texture defines the texture to update
  33957. * @param samples defines the sample count to set
  33958. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33959. */
  33960. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33961. /**
  33962. * Updates a depth texture Comparison Mode and Function.
  33963. * If the comparison Function is equal to 0, the mode will be set to none.
  33964. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33965. * @param texture The texture to set the comparison function for
  33966. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33967. */
  33968. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33969. /**
  33970. * Creates a webGL buffer to use with instanciation
  33971. * @param capacity defines the size of the buffer
  33972. * @returns the webGL buffer
  33973. */
  33974. createInstancesBuffer(capacity: number): DataBuffer;
  33975. /**
  33976. * Delete a webGL buffer used with instanciation
  33977. * @param buffer defines the webGL buffer to delete
  33978. */
  33979. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33980. private _clientWaitAsync;
  33981. /** @hidden */
  33982. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  33983. /** @hidden */
  33984. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33985. dispose(): void;
  33986. private _disableTouchAction;
  33987. /**
  33988. * Display the loading screen
  33989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33990. */
  33991. displayLoadingUI(): void;
  33992. /**
  33993. * Hide the loading screen
  33994. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33995. */
  33996. hideLoadingUI(): void;
  33997. /**
  33998. * Gets the current loading screen object
  33999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34000. */
  34001. get loadingScreen(): ILoadingScreen;
  34002. /**
  34003. * Sets the current loading screen object
  34004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34005. */
  34006. set loadingScreen(loadingScreen: ILoadingScreen);
  34007. /**
  34008. * Sets the current loading screen text
  34009. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34010. */
  34011. set loadingUIText(text: string);
  34012. /**
  34013. * Sets the current loading screen background color
  34014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34015. */
  34016. set loadingUIBackgroundColor(color: string);
  34017. /** Pointerlock and fullscreen */
  34018. /**
  34019. * Ask the browser to promote the current element to pointerlock mode
  34020. * @param element defines the DOM element to promote
  34021. */
  34022. static _RequestPointerlock(element: HTMLElement): void;
  34023. /**
  34024. * Asks the browser to exit pointerlock mode
  34025. */
  34026. static _ExitPointerlock(): void;
  34027. /**
  34028. * Ask the browser to promote the current element to fullscreen rendering mode
  34029. * @param element defines the DOM element to promote
  34030. */
  34031. static _RequestFullscreen(element: HTMLElement): void;
  34032. /**
  34033. * Asks the browser to exit fullscreen mode
  34034. */
  34035. static _ExitFullscreen(): void;
  34036. }
  34037. }
  34038. declare module BABYLON {
  34039. /**
  34040. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34041. * during the life time of the application.
  34042. */
  34043. export class EngineStore {
  34044. /** Gets the list of created engines */
  34045. static Instances: Engine[];
  34046. /** @hidden */
  34047. static _LastCreatedScene: Nullable<Scene>;
  34048. /**
  34049. * Gets the latest created engine
  34050. */
  34051. static get LastCreatedEngine(): Nullable<Engine>;
  34052. /**
  34053. * Gets the latest created scene
  34054. */
  34055. static get LastCreatedScene(): Nullable<Scene>;
  34056. /**
  34057. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34058. * @ignorenaming
  34059. */
  34060. static UseFallbackTexture: boolean;
  34061. /**
  34062. * Texture content used if a texture cannot loaded
  34063. * @ignorenaming
  34064. */
  34065. static FallbackTexture: string;
  34066. }
  34067. }
  34068. declare module BABYLON {
  34069. /**
  34070. * Helper class that provides a small promise polyfill
  34071. */
  34072. export class PromisePolyfill {
  34073. /**
  34074. * Static function used to check if the polyfill is required
  34075. * If this is the case then the function will inject the polyfill to window.Promise
  34076. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34077. */
  34078. static Apply(force?: boolean): void;
  34079. }
  34080. }
  34081. declare module BABYLON {
  34082. /**
  34083. * Interface for screenshot methods with describe argument called `size` as object with options
  34084. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34085. */
  34086. export interface IScreenshotSize {
  34087. /**
  34088. * number in pixels for canvas height
  34089. */
  34090. height?: number;
  34091. /**
  34092. * multiplier allowing render at a higher or lower resolution
  34093. * If value is defined then height and width will be ignored and taken from camera
  34094. */
  34095. precision?: number;
  34096. /**
  34097. * number in pixels for canvas width
  34098. */
  34099. width?: number;
  34100. }
  34101. }
  34102. declare module BABYLON {
  34103. interface IColor4Like {
  34104. r: float;
  34105. g: float;
  34106. b: float;
  34107. a: float;
  34108. }
  34109. /**
  34110. * Class containing a set of static utilities functions
  34111. */
  34112. export class Tools {
  34113. /**
  34114. * Gets or sets the base URL to use to load assets
  34115. */
  34116. static get BaseUrl(): string;
  34117. static set BaseUrl(value: string);
  34118. /**
  34119. * Enable/Disable Custom HTTP Request Headers globally.
  34120. * default = false
  34121. * @see CustomRequestHeaders
  34122. */
  34123. static UseCustomRequestHeaders: boolean;
  34124. /**
  34125. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34126. * i.e. when loading files, where the server/service expects an Authorization header
  34127. */
  34128. static CustomRequestHeaders: {
  34129. [key: string]: string;
  34130. };
  34131. /**
  34132. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34133. */
  34134. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34135. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34136. /**
  34137. * Default behaviour for cors in the application.
  34138. * It can be a string if the expected behavior is identical in the entire app.
  34139. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34140. */
  34141. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34142. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34143. /**
  34144. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34145. * @ignorenaming
  34146. */
  34147. static get UseFallbackTexture(): boolean;
  34148. static set UseFallbackTexture(value: boolean);
  34149. /**
  34150. * Use this object to register external classes like custom textures or material
  34151. * to allow the laoders to instantiate them
  34152. */
  34153. static get RegisteredExternalClasses(): {
  34154. [key: string]: Object;
  34155. };
  34156. static set RegisteredExternalClasses(classes: {
  34157. [key: string]: Object;
  34158. });
  34159. /**
  34160. * Texture content used if a texture cannot loaded
  34161. * @ignorenaming
  34162. */
  34163. static get fallbackTexture(): string;
  34164. static set fallbackTexture(value: string);
  34165. /**
  34166. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34167. * @param u defines the coordinate on X axis
  34168. * @param v defines the coordinate on Y axis
  34169. * @param width defines the width of the source data
  34170. * @param height defines the height of the source data
  34171. * @param pixels defines the source byte array
  34172. * @param color defines the output color
  34173. */
  34174. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34175. /**
  34176. * Interpolates between a and b via alpha
  34177. * @param a The lower value (returned when alpha = 0)
  34178. * @param b The upper value (returned when alpha = 1)
  34179. * @param alpha The interpolation-factor
  34180. * @return The mixed value
  34181. */
  34182. static Mix(a: number, b: number, alpha: number): number;
  34183. /**
  34184. * Tries to instantiate a new object from a given class name
  34185. * @param className defines the class name to instantiate
  34186. * @returns the new object or null if the system was not able to do the instantiation
  34187. */
  34188. static Instantiate(className: string): any;
  34189. /**
  34190. * Provides a slice function that will work even on IE
  34191. * @param data defines the array to slice
  34192. * @param start defines the start of the data (optional)
  34193. * @param end defines the end of the data (optional)
  34194. * @returns the new sliced array
  34195. */
  34196. static Slice<T>(data: T, start?: number, end?: number): T;
  34197. /**
  34198. * Polyfill for setImmediate
  34199. * @param action defines the action to execute after the current execution block
  34200. */
  34201. static SetImmediate(action: () => void): void;
  34202. /**
  34203. * Function indicating if a number is an exponent of 2
  34204. * @param value defines the value to test
  34205. * @returns true if the value is an exponent of 2
  34206. */
  34207. static IsExponentOfTwo(value: number): boolean;
  34208. private static _tmpFloatArray;
  34209. /**
  34210. * Returns the nearest 32-bit single precision float representation of a Number
  34211. * @param value A Number. If the parameter is of a different type, it will get converted
  34212. * to a number or to NaN if it cannot be converted
  34213. * @returns number
  34214. */
  34215. static FloatRound(value: number): number;
  34216. /**
  34217. * Extracts the filename from a path
  34218. * @param path defines the path to use
  34219. * @returns the filename
  34220. */
  34221. static GetFilename(path: string): string;
  34222. /**
  34223. * Extracts the "folder" part of a path (everything before the filename).
  34224. * @param uri The URI to extract the info from
  34225. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34226. * @returns The "folder" part of the path
  34227. */
  34228. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34229. /**
  34230. * Extracts text content from a DOM element hierarchy
  34231. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34232. */
  34233. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34234. /**
  34235. * Convert an angle in radians to degrees
  34236. * @param angle defines the angle to convert
  34237. * @returns the angle in degrees
  34238. */
  34239. static ToDegrees(angle: number): number;
  34240. /**
  34241. * Convert an angle in degrees to radians
  34242. * @param angle defines the angle to convert
  34243. * @returns the angle in radians
  34244. */
  34245. static ToRadians(angle: number): number;
  34246. /**
  34247. * Returns an array if obj is not an array
  34248. * @param obj defines the object to evaluate as an array
  34249. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34250. * @returns either obj directly if obj is an array or a new array containing obj
  34251. */
  34252. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34253. /**
  34254. * Gets the pointer prefix to use
  34255. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34256. */
  34257. static GetPointerPrefix(): string;
  34258. /**
  34259. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34260. * @param url define the url we are trying
  34261. * @param element define the dom element where to configure the cors policy
  34262. */
  34263. static SetCorsBehavior(url: string | string[], element: {
  34264. crossOrigin: string | null;
  34265. }): void;
  34266. /**
  34267. * Removes unwanted characters from an url
  34268. * @param url defines the url to clean
  34269. * @returns the cleaned url
  34270. */
  34271. static CleanUrl(url: string): string;
  34272. /**
  34273. * Gets or sets a function used to pre-process url before using them to load assets
  34274. */
  34275. static get PreprocessUrl(): (url: string) => string;
  34276. static set PreprocessUrl(processor: (url: string) => string);
  34277. /**
  34278. * Loads an image as an HTMLImageElement.
  34279. * @param input url string, ArrayBuffer, or Blob to load
  34280. * @param onLoad callback called when the image successfully loads
  34281. * @param onError callback called when the image fails to load
  34282. * @param offlineProvider offline provider for caching
  34283. * @param mimeType optional mime type
  34284. * @returns the HTMLImageElement of the loaded image
  34285. */
  34286. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34287. /**
  34288. * Loads a file from a url
  34289. * @param url url string, ArrayBuffer, or Blob to load
  34290. * @param onSuccess callback called when the file successfully loads
  34291. * @param onProgress callback called while file is loading (if the server supports this mode)
  34292. * @param offlineProvider defines the offline provider for caching
  34293. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34294. * @param onError callback called when the file fails to load
  34295. * @returns a file request object
  34296. */
  34297. 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;
  34298. /**
  34299. * Loads a file from a url
  34300. * @param url the file url to load
  34301. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34302. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34303. */
  34304. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34305. /**
  34306. * Load a script (identified by an url). When the url returns, the
  34307. * content of this file is added into a new script element, attached to the DOM (body element)
  34308. * @param scriptUrl defines the url of the script to laod
  34309. * @param onSuccess defines the callback called when the script is loaded
  34310. * @param onError defines the callback to call if an error occurs
  34311. * @param scriptId defines the id of the script element
  34312. */
  34313. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34314. /**
  34315. * Load an asynchronous script (identified by an url). When the url returns, the
  34316. * content of this file is added into a new script element, attached to the DOM (body element)
  34317. * @param scriptUrl defines the url of the script to laod
  34318. * @param scriptId defines the id of the script element
  34319. * @returns a promise request object
  34320. */
  34321. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34322. /**
  34323. * Loads a file from a blob
  34324. * @param fileToLoad defines the blob to use
  34325. * @param callback defines the callback to call when data is loaded
  34326. * @param progressCallback defines the callback to call during loading process
  34327. * @returns a file request object
  34328. */
  34329. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34330. /**
  34331. * Reads a file from a File object
  34332. * @param file defines the file to load
  34333. * @param onSuccess defines the callback to call when data is loaded
  34334. * @param onProgress defines the callback to call during loading process
  34335. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34336. * @param onError defines the callback to call when an error occurs
  34337. * @returns a file request object
  34338. */
  34339. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34340. /**
  34341. * Creates a data url from a given string content
  34342. * @param content defines the content to convert
  34343. * @returns the new data url link
  34344. */
  34345. static FileAsURL(content: string): string;
  34346. /**
  34347. * Format the given number to a specific decimal format
  34348. * @param value defines the number to format
  34349. * @param decimals defines the number of decimals to use
  34350. * @returns the formatted string
  34351. */
  34352. static Format(value: number, decimals?: number): string;
  34353. /**
  34354. * Tries to copy an object by duplicating every property
  34355. * @param source defines the source object
  34356. * @param destination defines the target object
  34357. * @param doNotCopyList defines a list of properties to avoid
  34358. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34359. */
  34360. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34361. /**
  34362. * Gets a boolean indicating if the given object has no own property
  34363. * @param obj defines the object to test
  34364. * @returns true if object has no own property
  34365. */
  34366. static IsEmpty(obj: any): boolean;
  34367. /**
  34368. * Function used to register events at window level
  34369. * @param windowElement defines the Window object to use
  34370. * @param events defines the events to register
  34371. */
  34372. static RegisterTopRootEvents(windowElement: Window, events: {
  34373. name: string;
  34374. handler: Nullable<(e: FocusEvent) => any>;
  34375. }[]): void;
  34376. /**
  34377. * Function used to unregister events from window level
  34378. * @param windowElement defines the Window object to use
  34379. * @param events defines the events to unregister
  34380. */
  34381. static UnregisterTopRootEvents(windowElement: Window, events: {
  34382. name: string;
  34383. handler: Nullable<(e: FocusEvent) => any>;
  34384. }[]): void;
  34385. /**
  34386. * @ignore
  34387. */
  34388. static _ScreenshotCanvas: HTMLCanvasElement;
  34389. /**
  34390. * Dumps the current bound framebuffer
  34391. * @param width defines the rendering width
  34392. * @param height defines the rendering height
  34393. * @param engine defines the hosting engine
  34394. * @param successCallback defines the callback triggered once the data are available
  34395. * @param mimeType defines the mime type of the result
  34396. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34397. */
  34398. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34399. /**
  34400. * Converts the canvas data to blob.
  34401. * This acts as a polyfill for browsers not supporting the to blob function.
  34402. * @param canvas Defines the canvas to extract the data from
  34403. * @param successCallback Defines the callback triggered once the data are available
  34404. * @param mimeType Defines the mime type of the result
  34405. */
  34406. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34407. /**
  34408. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34409. * @param successCallback defines the callback triggered once the data are available
  34410. * @param mimeType defines the mime type of the result
  34411. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34412. */
  34413. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34414. /**
  34415. * Downloads a blob in the browser
  34416. * @param blob defines the blob to download
  34417. * @param fileName defines the name of the downloaded file
  34418. */
  34419. static Download(blob: Blob, fileName: string): void;
  34420. /**
  34421. * Captures a screenshot of the current rendering
  34422. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34423. * @param engine defines the rendering engine
  34424. * @param camera defines the source camera
  34425. * @param size This parameter can be set to a single number or to an object with the
  34426. * following (optional) properties: precision, width, height. If a single number is passed,
  34427. * it will be used for both width and height. If an object is passed, the screenshot size
  34428. * will be derived from the parameters. The precision property is a multiplier allowing
  34429. * rendering at a higher or lower resolution
  34430. * @param successCallback defines the callback receives a single parameter which contains the
  34431. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34432. * src parameter of an <img> to display it
  34433. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34434. * Check your browser for supported MIME types
  34435. */
  34436. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34437. /**
  34438. * Captures a screenshot of the current rendering
  34439. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34440. * @param engine defines the rendering engine
  34441. * @param camera defines the source camera
  34442. * @param size This parameter can be set to a single number or to an object with the
  34443. * following (optional) properties: precision, width, height. If a single number is passed,
  34444. * it will be used for both width and height. If an object is passed, the screenshot size
  34445. * will be derived from the parameters. The precision property is a multiplier allowing
  34446. * rendering at a higher or lower resolution
  34447. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34448. * Check your browser for supported MIME types
  34449. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34450. * to the src parameter of an <img> to display it
  34451. */
  34452. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34453. /**
  34454. * Generates an image screenshot from the specified camera.
  34455. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34456. * @param engine The engine to use for rendering
  34457. * @param camera The camera to use for rendering
  34458. * @param size This parameter can be set to a single number or to an object with the
  34459. * following (optional) properties: precision, width, height. If a single number is passed,
  34460. * it will be used for both width and height. If an object is passed, the screenshot size
  34461. * will be derived from the parameters. The precision property is a multiplier allowing
  34462. * rendering at a higher or lower resolution
  34463. * @param successCallback The callback receives a single parameter which contains the
  34464. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34465. * src parameter of an <img> to display it
  34466. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34467. * Check your browser for supported MIME types
  34468. * @param samples Texture samples (default: 1)
  34469. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34470. * @param fileName A name for for the downloaded file.
  34471. */
  34472. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34473. /**
  34474. * Generates an image screenshot from the specified camera.
  34475. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34476. * @param engine The engine to use for rendering
  34477. * @param camera The camera to use for rendering
  34478. * @param size This parameter can be set to a single number or to an object with the
  34479. * following (optional) properties: precision, width, height. If a single number is passed,
  34480. * it will be used for both width and height. If an object is passed, the screenshot size
  34481. * will be derived from the parameters. The precision property is a multiplier allowing
  34482. * rendering at a higher or lower resolution
  34483. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34484. * Check your browser for supported MIME types
  34485. * @param samples Texture samples (default: 1)
  34486. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34487. * @param fileName A name for for the downloaded file.
  34488. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34489. * to the src parameter of an <img> to display it
  34490. */
  34491. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34492. /**
  34493. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34494. * Be aware Math.random() could cause collisions, but:
  34495. * "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"
  34496. * @returns a pseudo random id
  34497. */
  34498. static RandomId(): string;
  34499. /**
  34500. * Test if the given uri is a base64 string
  34501. * @param uri The uri to test
  34502. * @return True if the uri is a base64 string or false otherwise
  34503. */
  34504. static IsBase64(uri: string): boolean;
  34505. /**
  34506. * Decode the given base64 uri.
  34507. * @param uri The uri to decode
  34508. * @return The decoded base64 data.
  34509. */
  34510. static DecodeBase64(uri: string): ArrayBuffer;
  34511. /**
  34512. * Gets the absolute url.
  34513. * @param url the input url
  34514. * @return the absolute url
  34515. */
  34516. static GetAbsoluteUrl(url: string): string;
  34517. /**
  34518. * No log
  34519. */
  34520. static readonly NoneLogLevel: number;
  34521. /**
  34522. * Only message logs
  34523. */
  34524. static readonly MessageLogLevel: number;
  34525. /**
  34526. * Only warning logs
  34527. */
  34528. static readonly WarningLogLevel: number;
  34529. /**
  34530. * Only error logs
  34531. */
  34532. static readonly ErrorLogLevel: number;
  34533. /**
  34534. * All logs
  34535. */
  34536. static readonly AllLogLevel: number;
  34537. /**
  34538. * Gets a value indicating the number of loading errors
  34539. * @ignorenaming
  34540. */
  34541. static get errorsCount(): number;
  34542. /**
  34543. * Callback called when a new log is added
  34544. */
  34545. static OnNewCacheEntry: (entry: string) => void;
  34546. /**
  34547. * Log a message to the console
  34548. * @param message defines the message to log
  34549. */
  34550. static Log(message: string): void;
  34551. /**
  34552. * Write a warning message to the console
  34553. * @param message defines the message to log
  34554. */
  34555. static Warn(message: string): void;
  34556. /**
  34557. * Write an error message to the console
  34558. * @param message defines the message to log
  34559. */
  34560. static Error(message: string): void;
  34561. /**
  34562. * Gets current log cache (list of logs)
  34563. */
  34564. static get LogCache(): string;
  34565. /**
  34566. * Clears the log cache
  34567. */
  34568. static ClearLogCache(): void;
  34569. /**
  34570. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34571. */
  34572. static set LogLevels(level: number);
  34573. /**
  34574. * Checks if the window object exists
  34575. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34576. */
  34577. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34578. /**
  34579. * No performance log
  34580. */
  34581. static readonly PerformanceNoneLogLevel: number;
  34582. /**
  34583. * Use user marks to log performance
  34584. */
  34585. static readonly PerformanceUserMarkLogLevel: number;
  34586. /**
  34587. * Log performance to the console
  34588. */
  34589. static readonly PerformanceConsoleLogLevel: number;
  34590. private static _performance;
  34591. /**
  34592. * Sets the current performance log level
  34593. */
  34594. static set PerformanceLogLevel(level: number);
  34595. private static _StartPerformanceCounterDisabled;
  34596. private static _EndPerformanceCounterDisabled;
  34597. private static _StartUserMark;
  34598. private static _EndUserMark;
  34599. private static _StartPerformanceConsole;
  34600. private static _EndPerformanceConsole;
  34601. /**
  34602. * Starts a performance counter
  34603. */
  34604. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34605. /**
  34606. * Ends a specific performance coutner
  34607. */
  34608. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34609. /**
  34610. * Gets either window.performance.now() if supported or Date.now() else
  34611. */
  34612. static get Now(): number;
  34613. /**
  34614. * This method will return the name of the class used to create the instance of the given object.
  34615. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34616. * @param object the object to get the class name from
  34617. * @param isType defines if the object is actually a type
  34618. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34619. */
  34620. static GetClassName(object: any, isType?: boolean): string;
  34621. /**
  34622. * Gets the first element of an array satisfying a given predicate
  34623. * @param array defines the array to browse
  34624. * @param predicate defines the predicate to use
  34625. * @returns null if not found or the element
  34626. */
  34627. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34628. /**
  34629. * This method will return the name of the full name of the class, including its owning module (if any).
  34630. * 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).
  34631. * @param object the object to get the class name from
  34632. * @param isType defines if the object is actually a type
  34633. * @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.
  34634. * @ignorenaming
  34635. */
  34636. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34637. /**
  34638. * Returns a promise that resolves after the given amount of time.
  34639. * @param delay Number of milliseconds to delay
  34640. * @returns Promise that resolves after the given amount of time
  34641. */
  34642. static DelayAsync(delay: number): Promise<void>;
  34643. /**
  34644. * Utility function to detect if the current user agent is Safari
  34645. * @returns whether or not the current user agent is safari
  34646. */
  34647. static IsSafari(): boolean;
  34648. }
  34649. /**
  34650. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34651. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34652. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34653. * @param name The name of the class, case should be preserved
  34654. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34655. */
  34656. export function className(name: string, module?: string): (target: Object) => void;
  34657. /**
  34658. * An implementation of a loop for asynchronous functions.
  34659. */
  34660. export class AsyncLoop {
  34661. /**
  34662. * Defines the number of iterations for the loop
  34663. */
  34664. iterations: number;
  34665. /**
  34666. * Defines the current index of the loop.
  34667. */
  34668. index: number;
  34669. private _done;
  34670. private _fn;
  34671. private _successCallback;
  34672. /**
  34673. * Constructor.
  34674. * @param iterations the number of iterations.
  34675. * @param func the function to run each iteration
  34676. * @param successCallback the callback that will be called upon succesful execution
  34677. * @param offset starting offset.
  34678. */
  34679. constructor(
  34680. /**
  34681. * Defines the number of iterations for the loop
  34682. */
  34683. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34684. /**
  34685. * Execute the next iteration. Must be called after the last iteration was finished.
  34686. */
  34687. executeNext(): void;
  34688. /**
  34689. * Break the loop and run the success callback.
  34690. */
  34691. breakLoop(): void;
  34692. /**
  34693. * Create and run an async loop.
  34694. * @param iterations the number of iterations.
  34695. * @param fn the function to run each iteration
  34696. * @param successCallback the callback that will be called upon succesful execution
  34697. * @param offset starting offset.
  34698. * @returns the created async loop object
  34699. */
  34700. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34701. /**
  34702. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34703. * @param iterations total number of iterations
  34704. * @param syncedIterations number of synchronous iterations in each async iteration.
  34705. * @param fn the function to call each iteration.
  34706. * @param callback a success call back that will be called when iterating stops.
  34707. * @param breakFunction a break condition (optional)
  34708. * @param timeout timeout settings for the setTimeout function. default - 0.
  34709. * @returns the created async loop object
  34710. */
  34711. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34712. }
  34713. }
  34714. declare module BABYLON {
  34715. /**
  34716. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34717. * The underlying implementation relies on an associative array to ensure the best performances.
  34718. * The value can be anything including 'null' but except 'undefined'
  34719. */
  34720. export class StringDictionary<T> {
  34721. /**
  34722. * This will clear this dictionary and copy the content from the 'source' one.
  34723. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34724. * @param source the dictionary to take the content from and copy to this dictionary
  34725. */
  34726. copyFrom(source: StringDictionary<T>): void;
  34727. /**
  34728. * Get a value based from its key
  34729. * @param key the given key to get the matching value from
  34730. * @return the value if found, otherwise undefined is returned
  34731. */
  34732. get(key: string): T | undefined;
  34733. /**
  34734. * Get a value from its key or add it if it doesn't exist.
  34735. * This method will ensure you that a given key/data will be present in the dictionary.
  34736. * @param key the given key to get the matching value from
  34737. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34738. * The factory will only be invoked if there's no data for the given key.
  34739. * @return the value corresponding to the key.
  34740. */
  34741. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34742. /**
  34743. * Get a value from its key if present in the dictionary otherwise add it
  34744. * @param key the key to get the value from
  34745. * @param val if there's no such key/value pair in the dictionary add it with this value
  34746. * @return the value corresponding to the key
  34747. */
  34748. getOrAdd(key: string, val: T): T;
  34749. /**
  34750. * Check if there's a given key in the dictionary
  34751. * @param key the key to check for
  34752. * @return true if the key is present, false otherwise
  34753. */
  34754. contains(key: string): boolean;
  34755. /**
  34756. * Add a new key and its corresponding value
  34757. * @param key the key to add
  34758. * @param value the value corresponding to the key
  34759. * @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
  34760. */
  34761. add(key: string, value: T): boolean;
  34762. /**
  34763. * Update a specific value associated to a key
  34764. * @param key defines the key to use
  34765. * @param value defines the value to store
  34766. * @returns true if the value was updated (or false if the key was not found)
  34767. */
  34768. set(key: string, value: T): boolean;
  34769. /**
  34770. * Get the element of the given key and remove it from the dictionary
  34771. * @param key defines the key to search
  34772. * @returns the value associated with the key or null if not found
  34773. */
  34774. getAndRemove(key: string): Nullable<T>;
  34775. /**
  34776. * Remove a key/value from the dictionary.
  34777. * @param key the key to remove
  34778. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34779. */
  34780. remove(key: string): boolean;
  34781. /**
  34782. * Clear the whole content of the dictionary
  34783. */
  34784. clear(): void;
  34785. /**
  34786. * Gets the current count
  34787. */
  34788. get count(): number;
  34789. /**
  34790. * Execute a callback on each key/val of the dictionary.
  34791. * Note that you can remove any element in this dictionary in the callback implementation
  34792. * @param callback the callback to execute on a given key/value pair
  34793. */
  34794. forEach(callback: (key: string, val: T) => void): void;
  34795. /**
  34796. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34797. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34798. * Note that you can remove any element in this dictionary in the callback implementation
  34799. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34800. * @returns the first item
  34801. */
  34802. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34803. private _count;
  34804. private _data;
  34805. }
  34806. }
  34807. declare module BABYLON {
  34808. /** @hidden */
  34809. export interface ICollisionCoordinator {
  34810. createCollider(): Collider;
  34811. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34812. init(scene: Scene): void;
  34813. }
  34814. /** @hidden */
  34815. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34816. private _scene;
  34817. private _scaledPosition;
  34818. private _scaledVelocity;
  34819. private _finalPosition;
  34820. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34821. createCollider(): Collider;
  34822. init(scene: Scene): void;
  34823. private _collideWithWorld;
  34824. }
  34825. }
  34826. declare module BABYLON {
  34827. /**
  34828. * Class used to manage all inputs for the scene.
  34829. */
  34830. export class InputManager {
  34831. /** The distance in pixel that you have to move to prevent some events */
  34832. static DragMovementThreshold: number;
  34833. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34834. static LongPressDelay: number;
  34835. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34836. static DoubleClickDelay: number;
  34837. /** If you need to check double click without raising a single click at first click, enable this flag */
  34838. static ExclusiveDoubleClickMode: boolean;
  34839. private _wheelEventName;
  34840. private _onPointerMove;
  34841. private _onPointerDown;
  34842. private _onPointerUp;
  34843. private _initClickEvent;
  34844. private _initActionManager;
  34845. private _delayedSimpleClick;
  34846. private _delayedSimpleClickTimeout;
  34847. private _previousDelayedSimpleClickTimeout;
  34848. private _meshPickProceed;
  34849. private _previousButtonPressed;
  34850. private _currentPickResult;
  34851. private _previousPickResult;
  34852. private _totalPointersPressed;
  34853. private _doubleClickOccured;
  34854. private _pointerOverMesh;
  34855. private _pickedDownMesh;
  34856. private _pickedUpMesh;
  34857. private _pointerX;
  34858. private _pointerY;
  34859. private _unTranslatedPointerX;
  34860. private _unTranslatedPointerY;
  34861. private _startingPointerPosition;
  34862. private _previousStartingPointerPosition;
  34863. private _startingPointerTime;
  34864. private _previousStartingPointerTime;
  34865. private _pointerCaptures;
  34866. private _onKeyDown;
  34867. private _onKeyUp;
  34868. private _onCanvasFocusObserver;
  34869. private _onCanvasBlurObserver;
  34870. private _scene;
  34871. /**
  34872. * Creates a new InputManager
  34873. * @param scene defines the hosting scene
  34874. */
  34875. constructor(scene: Scene);
  34876. /**
  34877. * Gets the mesh that is currently under the pointer
  34878. */
  34879. get meshUnderPointer(): Nullable<AbstractMesh>;
  34880. /**
  34881. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34882. */
  34883. get unTranslatedPointer(): Vector2;
  34884. /**
  34885. * Gets or sets the current on-screen X position of the pointer
  34886. */
  34887. get pointerX(): number;
  34888. set pointerX(value: number);
  34889. /**
  34890. * Gets or sets the current on-screen Y position of the pointer
  34891. */
  34892. get pointerY(): number;
  34893. set pointerY(value: number);
  34894. private _updatePointerPosition;
  34895. private _processPointerMove;
  34896. private _setRayOnPointerInfo;
  34897. private _checkPrePointerObservable;
  34898. /**
  34899. * Use this method to simulate a pointer move on a mesh
  34900. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34901. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34902. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34903. */
  34904. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34905. /**
  34906. * Use this method to simulate a pointer down on a mesh
  34907. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34908. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34909. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34910. */
  34911. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34912. private _processPointerDown;
  34913. /** @hidden */
  34914. _isPointerSwiping(): boolean;
  34915. /**
  34916. * Use this method to simulate a pointer up on a mesh
  34917. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34918. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34919. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34920. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34921. */
  34922. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34923. private _processPointerUp;
  34924. /**
  34925. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34926. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34927. * @returns true if the pointer was captured
  34928. */
  34929. isPointerCaptured(pointerId?: number): boolean;
  34930. /**
  34931. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34932. * @param attachUp defines if you want to attach events to pointerup
  34933. * @param attachDown defines if you want to attach events to pointerdown
  34934. * @param attachMove defines if you want to attach events to pointermove
  34935. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34936. */
  34937. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34938. /**
  34939. * Detaches all event handlers
  34940. */
  34941. detachControl(): void;
  34942. /**
  34943. * Force the value of meshUnderPointer
  34944. * @param mesh defines the mesh to use
  34945. */
  34946. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34947. /**
  34948. * Gets the mesh under the pointer
  34949. * @returns a Mesh or null if no mesh is under the pointer
  34950. */
  34951. getPointerOverMesh(): Nullable<AbstractMesh>;
  34952. }
  34953. }
  34954. declare module BABYLON {
  34955. /**
  34956. * Helper class used to generate session unique ID
  34957. */
  34958. export class UniqueIdGenerator {
  34959. private static _UniqueIdCounter;
  34960. /**
  34961. * Gets an unique (relatively to the current scene) Id
  34962. */
  34963. static get UniqueId(): number;
  34964. }
  34965. }
  34966. declare module BABYLON {
  34967. /**
  34968. * This class defines the direct association between an animation and a target
  34969. */
  34970. export class TargetedAnimation {
  34971. /**
  34972. * Animation to perform
  34973. */
  34974. animation: Animation;
  34975. /**
  34976. * Target to animate
  34977. */
  34978. target: any;
  34979. /**
  34980. * Serialize the object
  34981. * @returns the JSON object representing the current entity
  34982. */
  34983. serialize(): any;
  34984. }
  34985. /**
  34986. * Use this class to create coordinated animations on multiple targets
  34987. */
  34988. export class AnimationGroup implements IDisposable {
  34989. /** The name of the animation group */
  34990. name: string;
  34991. private _scene;
  34992. private _targetedAnimations;
  34993. private _animatables;
  34994. private _from;
  34995. private _to;
  34996. private _isStarted;
  34997. private _isPaused;
  34998. private _speedRatio;
  34999. private _loopAnimation;
  35000. /**
  35001. * Gets or sets the unique id of the node
  35002. */
  35003. uniqueId: number;
  35004. /**
  35005. * This observable will notify when one animation have ended
  35006. */
  35007. onAnimationEndObservable: Observable<TargetedAnimation>;
  35008. /**
  35009. * Observer raised when one animation loops
  35010. */
  35011. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35012. /**
  35013. * Observer raised when all animations have looped
  35014. */
  35015. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35016. /**
  35017. * This observable will notify when all animations have ended.
  35018. */
  35019. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35020. /**
  35021. * This observable will notify when all animations have paused.
  35022. */
  35023. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35024. /**
  35025. * This observable will notify when all animations are playing.
  35026. */
  35027. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35028. /**
  35029. * Gets the first frame
  35030. */
  35031. get from(): number;
  35032. /**
  35033. * Gets the last frame
  35034. */
  35035. get to(): number;
  35036. /**
  35037. * Define if the animations are started
  35038. */
  35039. get isStarted(): boolean;
  35040. /**
  35041. * Gets a value indicating that the current group is playing
  35042. */
  35043. get isPlaying(): boolean;
  35044. /**
  35045. * Gets or sets the speed ratio to use for all animations
  35046. */
  35047. get speedRatio(): number;
  35048. /**
  35049. * Gets or sets the speed ratio to use for all animations
  35050. */
  35051. set speedRatio(value: number);
  35052. /**
  35053. * Gets or sets if all animations should loop or not
  35054. */
  35055. get loopAnimation(): boolean;
  35056. set loopAnimation(value: boolean);
  35057. /**
  35058. * Gets the targeted animations for this animation group
  35059. */
  35060. get targetedAnimations(): Array<TargetedAnimation>;
  35061. /**
  35062. * returning the list of animatables controlled by this animation group.
  35063. */
  35064. get animatables(): Array<Animatable>;
  35065. /**
  35066. * Instantiates a new Animation Group.
  35067. * This helps managing several animations at once.
  35068. * @see http://doc.babylonjs.com/how_to/group
  35069. * @param name Defines the name of the group
  35070. * @param scene Defines the scene the group belongs to
  35071. */
  35072. constructor(
  35073. /** The name of the animation group */
  35074. name: string, scene?: Nullable<Scene>);
  35075. /**
  35076. * Add an animation (with its target) in the group
  35077. * @param animation defines the animation we want to add
  35078. * @param target defines the target of the animation
  35079. * @returns the TargetedAnimation object
  35080. */
  35081. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35082. /**
  35083. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35084. * It can add constant keys at begin or end
  35085. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35086. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35087. * @returns the animation group
  35088. */
  35089. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35090. private _animationLoopCount;
  35091. private _animationLoopFlags;
  35092. private _processLoop;
  35093. /**
  35094. * Start all animations on given targets
  35095. * @param loop defines if animations must loop
  35096. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35097. * @param from defines the from key (optional)
  35098. * @param to defines the to key (optional)
  35099. * @returns the current animation group
  35100. */
  35101. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35102. /**
  35103. * Pause all animations
  35104. * @returns the animation group
  35105. */
  35106. pause(): AnimationGroup;
  35107. /**
  35108. * Play all animations to initial state
  35109. * This function will start() the animations if they were not started or will restart() them if they were paused
  35110. * @param loop defines if animations must loop
  35111. * @returns the animation group
  35112. */
  35113. play(loop?: boolean): AnimationGroup;
  35114. /**
  35115. * Reset all animations to initial state
  35116. * @returns the animation group
  35117. */
  35118. reset(): AnimationGroup;
  35119. /**
  35120. * Restart animations from key 0
  35121. * @returns the animation group
  35122. */
  35123. restart(): AnimationGroup;
  35124. /**
  35125. * Stop all animations
  35126. * @returns the animation group
  35127. */
  35128. stop(): AnimationGroup;
  35129. /**
  35130. * Set animation weight for all animatables
  35131. * @param weight defines the weight to use
  35132. * @return the animationGroup
  35133. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35134. */
  35135. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35136. /**
  35137. * Synchronize and normalize all animatables with a source animatable
  35138. * @param root defines the root animatable to synchronize with
  35139. * @return the animationGroup
  35140. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35141. */
  35142. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35143. /**
  35144. * Goes to a specific frame in this animation group
  35145. * @param frame the frame number to go to
  35146. * @return the animationGroup
  35147. */
  35148. goToFrame(frame: number): AnimationGroup;
  35149. /**
  35150. * Dispose all associated resources
  35151. */
  35152. dispose(): void;
  35153. private _checkAnimationGroupEnded;
  35154. /**
  35155. * Clone the current animation group and returns a copy
  35156. * @param newName defines the name of the new group
  35157. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35158. * @returns the new aniamtion group
  35159. */
  35160. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35161. /**
  35162. * Serializes the animationGroup to an object
  35163. * @returns Serialized object
  35164. */
  35165. serialize(): any;
  35166. /**
  35167. * Returns a new AnimationGroup object parsed from the source provided.
  35168. * @param parsedAnimationGroup defines the source
  35169. * @param scene defines the scene that will receive the animationGroup
  35170. * @returns a new AnimationGroup
  35171. */
  35172. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35173. /**
  35174. * Returns the string "AnimationGroup"
  35175. * @returns "AnimationGroup"
  35176. */
  35177. getClassName(): string;
  35178. /**
  35179. * Creates a detailled string about the object
  35180. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35181. * @returns a string representing the object
  35182. */
  35183. toString(fullDetails?: boolean): string;
  35184. }
  35185. }
  35186. declare module BABYLON {
  35187. /**
  35188. * Define an interface for all classes that will hold resources
  35189. */
  35190. export interface IDisposable {
  35191. /**
  35192. * Releases all held resources
  35193. */
  35194. dispose(): void;
  35195. }
  35196. /** Interface defining initialization parameters for Scene class */
  35197. export interface SceneOptions {
  35198. /**
  35199. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35200. * It will improve performance when the number of geometries becomes important.
  35201. */
  35202. useGeometryUniqueIdsMap?: boolean;
  35203. /**
  35204. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35205. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35206. */
  35207. useMaterialMeshMap?: boolean;
  35208. /**
  35209. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35210. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35211. */
  35212. useClonedMeshMap?: boolean;
  35213. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35214. virtual?: boolean;
  35215. }
  35216. /**
  35217. * Represents a scene to be rendered by the engine.
  35218. * @see http://doc.babylonjs.com/features/scene
  35219. */
  35220. export class Scene extends AbstractScene implements IAnimatable {
  35221. /** The fog is deactivated */
  35222. static readonly FOGMODE_NONE: number;
  35223. /** The fog density is following an exponential function */
  35224. static readonly FOGMODE_EXP: number;
  35225. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35226. static readonly FOGMODE_EXP2: number;
  35227. /** The fog density is following a linear function. */
  35228. static readonly FOGMODE_LINEAR: number;
  35229. /**
  35230. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35231. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35232. */
  35233. static MinDeltaTime: number;
  35234. /**
  35235. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35236. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35237. */
  35238. static MaxDeltaTime: number;
  35239. /**
  35240. * Factory used to create the default material.
  35241. * @param name The name of the material to create
  35242. * @param scene The scene to create the material for
  35243. * @returns The default material
  35244. */
  35245. static DefaultMaterialFactory(scene: Scene): Material;
  35246. /**
  35247. * Factory used to create the a collision coordinator.
  35248. * @returns The collision coordinator
  35249. */
  35250. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35251. /** @hidden */
  35252. _inputManager: InputManager;
  35253. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35254. cameraToUseForPointers: Nullable<Camera>;
  35255. /** @hidden */
  35256. readonly _isScene: boolean;
  35257. /** @hidden */
  35258. _blockEntityCollection: boolean;
  35259. /**
  35260. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35261. */
  35262. autoClear: boolean;
  35263. /**
  35264. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35265. */
  35266. autoClearDepthAndStencil: boolean;
  35267. /**
  35268. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35269. */
  35270. clearColor: Color4;
  35271. /**
  35272. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35273. */
  35274. ambientColor: Color3;
  35275. /**
  35276. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35277. * It should only be one of the following (if not the default embedded one):
  35278. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35279. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35280. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35281. * The material properties need to be setup according to the type of texture in use.
  35282. */
  35283. environmentBRDFTexture: BaseTexture;
  35284. /** @hidden */
  35285. protected _environmentTexture: Nullable<BaseTexture>;
  35286. /**
  35287. * Texture used in all pbr material as the reflection texture.
  35288. * As in the majority of the scene they are the same (exception for multi room and so on),
  35289. * this is easier to reference from here than from all the materials.
  35290. */
  35291. get environmentTexture(): Nullable<BaseTexture>;
  35292. /**
  35293. * Texture used in all pbr material as the reflection texture.
  35294. * As in the majority of the scene they are the same (exception for multi room and so on),
  35295. * this is easier to set here than in all the materials.
  35296. */
  35297. set environmentTexture(value: Nullable<BaseTexture>);
  35298. /** @hidden */
  35299. protected _environmentIntensity: number;
  35300. /**
  35301. * Intensity of the environment in all pbr material.
  35302. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35303. * As in the majority of the scene they are the same (exception for multi room and so on),
  35304. * this is easier to reference from here than from all the materials.
  35305. */
  35306. get environmentIntensity(): number;
  35307. /**
  35308. * Intensity of the environment in all pbr material.
  35309. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35310. * As in the majority of the scene they are the same (exception for multi room and so on),
  35311. * this is easier to set here than in all the materials.
  35312. */
  35313. set environmentIntensity(value: number);
  35314. /** @hidden */
  35315. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35316. /**
  35317. * Default image processing configuration used either in the rendering
  35318. * Forward main pass or through the imageProcessingPostProcess if present.
  35319. * As in the majority of the scene they are the same (exception for multi camera),
  35320. * this is easier to reference from here than from all the materials and post process.
  35321. *
  35322. * No setter as we it is a shared configuration, you can set the values instead.
  35323. */
  35324. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35325. private _forceWireframe;
  35326. /**
  35327. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35328. */
  35329. set forceWireframe(value: boolean);
  35330. get forceWireframe(): boolean;
  35331. private _skipFrustumClipping;
  35332. /**
  35333. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35334. */
  35335. set skipFrustumClipping(value: boolean);
  35336. get skipFrustumClipping(): boolean;
  35337. private _forcePointsCloud;
  35338. /**
  35339. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35340. */
  35341. set forcePointsCloud(value: boolean);
  35342. get forcePointsCloud(): boolean;
  35343. /**
  35344. * Gets or sets the active clipplane 1
  35345. */
  35346. clipPlane: Nullable<Plane>;
  35347. /**
  35348. * Gets or sets the active clipplane 2
  35349. */
  35350. clipPlane2: Nullable<Plane>;
  35351. /**
  35352. * Gets or sets the active clipplane 3
  35353. */
  35354. clipPlane3: Nullable<Plane>;
  35355. /**
  35356. * Gets or sets the active clipplane 4
  35357. */
  35358. clipPlane4: Nullable<Plane>;
  35359. /**
  35360. * Gets or sets the active clipplane 5
  35361. */
  35362. clipPlane5: Nullable<Plane>;
  35363. /**
  35364. * Gets or sets the active clipplane 6
  35365. */
  35366. clipPlane6: Nullable<Plane>;
  35367. /**
  35368. * Gets or sets a boolean indicating if animations are enabled
  35369. */
  35370. animationsEnabled: boolean;
  35371. private _animationPropertiesOverride;
  35372. /**
  35373. * Gets or sets the animation properties override
  35374. */
  35375. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35376. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35377. /**
  35378. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35379. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35380. */
  35381. useConstantAnimationDeltaTime: boolean;
  35382. /**
  35383. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35384. * Please note that it requires to run a ray cast through the scene on every frame
  35385. */
  35386. constantlyUpdateMeshUnderPointer: boolean;
  35387. /**
  35388. * Defines the HTML cursor to use when hovering over interactive elements
  35389. */
  35390. hoverCursor: string;
  35391. /**
  35392. * Defines the HTML default cursor to use (empty by default)
  35393. */
  35394. defaultCursor: string;
  35395. /**
  35396. * Defines whether cursors are handled by the scene.
  35397. */
  35398. doNotHandleCursors: boolean;
  35399. /**
  35400. * This is used to call preventDefault() on pointer down
  35401. * in order to block unwanted artifacts like system double clicks
  35402. */
  35403. preventDefaultOnPointerDown: boolean;
  35404. /**
  35405. * This is used to call preventDefault() on pointer up
  35406. * in order to block unwanted artifacts like system double clicks
  35407. */
  35408. preventDefaultOnPointerUp: boolean;
  35409. /**
  35410. * Gets or sets user defined metadata
  35411. */
  35412. metadata: any;
  35413. /**
  35414. * For internal use only. Please do not use.
  35415. */
  35416. reservedDataStore: any;
  35417. /**
  35418. * Gets the name of the plugin used to load this scene (null by default)
  35419. */
  35420. loadingPluginName: string;
  35421. /**
  35422. * Use this array to add regular expressions used to disable offline support for specific urls
  35423. */
  35424. disableOfflineSupportExceptionRules: RegExp[];
  35425. /**
  35426. * An event triggered when the scene is disposed.
  35427. */
  35428. onDisposeObservable: Observable<Scene>;
  35429. private _onDisposeObserver;
  35430. /** Sets a function to be executed when this scene is disposed. */
  35431. set onDispose(callback: () => void);
  35432. /**
  35433. * An event triggered before rendering the scene (right after animations and physics)
  35434. */
  35435. onBeforeRenderObservable: Observable<Scene>;
  35436. private _onBeforeRenderObserver;
  35437. /** Sets a function to be executed before rendering this scene */
  35438. set beforeRender(callback: Nullable<() => void>);
  35439. /**
  35440. * An event triggered after rendering the scene
  35441. */
  35442. onAfterRenderObservable: Observable<Scene>;
  35443. /**
  35444. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35445. */
  35446. onAfterRenderCameraObservable: Observable<Camera>;
  35447. private _onAfterRenderObserver;
  35448. /** Sets a function to be executed after rendering this scene */
  35449. set afterRender(callback: Nullable<() => void>);
  35450. /**
  35451. * An event triggered before animating the scene
  35452. */
  35453. onBeforeAnimationsObservable: Observable<Scene>;
  35454. /**
  35455. * An event triggered after animations processing
  35456. */
  35457. onAfterAnimationsObservable: Observable<Scene>;
  35458. /**
  35459. * An event triggered before draw calls are ready to be sent
  35460. */
  35461. onBeforeDrawPhaseObservable: Observable<Scene>;
  35462. /**
  35463. * An event triggered after draw calls have been sent
  35464. */
  35465. onAfterDrawPhaseObservable: Observable<Scene>;
  35466. /**
  35467. * An event triggered when the scene is ready
  35468. */
  35469. onReadyObservable: Observable<Scene>;
  35470. /**
  35471. * An event triggered before rendering a camera
  35472. */
  35473. onBeforeCameraRenderObservable: Observable<Camera>;
  35474. private _onBeforeCameraRenderObserver;
  35475. /** Sets a function to be executed before rendering a camera*/
  35476. set beforeCameraRender(callback: () => void);
  35477. /**
  35478. * An event triggered after rendering a camera
  35479. */
  35480. onAfterCameraRenderObservable: Observable<Camera>;
  35481. private _onAfterCameraRenderObserver;
  35482. /** Sets a function to be executed after rendering a camera*/
  35483. set afterCameraRender(callback: () => void);
  35484. /**
  35485. * An event triggered when active meshes evaluation is about to start
  35486. */
  35487. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35488. /**
  35489. * An event triggered when active meshes evaluation is done
  35490. */
  35491. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35492. /**
  35493. * An event triggered when particles rendering is about to start
  35494. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35495. */
  35496. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35497. /**
  35498. * An event triggered when particles rendering is done
  35499. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35500. */
  35501. onAfterParticlesRenderingObservable: Observable<Scene>;
  35502. /**
  35503. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35504. */
  35505. onDataLoadedObservable: Observable<Scene>;
  35506. /**
  35507. * An event triggered when a camera is created
  35508. */
  35509. onNewCameraAddedObservable: Observable<Camera>;
  35510. /**
  35511. * An event triggered when a camera is removed
  35512. */
  35513. onCameraRemovedObservable: Observable<Camera>;
  35514. /**
  35515. * An event triggered when a light is created
  35516. */
  35517. onNewLightAddedObservable: Observable<Light>;
  35518. /**
  35519. * An event triggered when a light is removed
  35520. */
  35521. onLightRemovedObservable: Observable<Light>;
  35522. /**
  35523. * An event triggered when a geometry is created
  35524. */
  35525. onNewGeometryAddedObservable: Observable<Geometry>;
  35526. /**
  35527. * An event triggered when a geometry is removed
  35528. */
  35529. onGeometryRemovedObservable: Observable<Geometry>;
  35530. /**
  35531. * An event triggered when a transform node is created
  35532. */
  35533. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35534. /**
  35535. * An event triggered when a transform node is removed
  35536. */
  35537. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35538. /**
  35539. * An event triggered when a mesh is created
  35540. */
  35541. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35542. /**
  35543. * An event triggered when a mesh is removed
  35544. */
  35545. onMeshRemovedObservable: Observable<AbstractMesh>;
  35546. /**
  35547. * An event triggered when a skeleton is created
  35548. */
  35549. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35550. /**
  35551. * An event triggered when a skeleton is removed
  35552. */
  35553. onSkeletonRemovedObservable: Observable<Skeleton>;
  35554. /**
  35555. * An event triggered when a material is created
  35556. */
  35557. onNewMaterialAddedObservable: Observable<Material>;
  35558. /**
  35559. * An event triggered when a material is removed
  35560. */
  35561. onMaterialRemovedObservable: Observable<Material>;
  35562. /**
  35563. * An event triggered when a texture is created
  35564. */
  35565. onNewTextureAddedObservable: Observable<BaseTexture>;
  35566. /**
  35567. * An event triggered when a texture is removed
  35568. */
  35569. onTextureRemovedObservable: Observable<BaseTexture>;
  35570. /**
  35571. * An event triggered when render targets are about to be rendered
  35572. * Can happen multiple times per frame.
  35573. */
  35574. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35575. /**
  35576. * An event triggered when render targets were rendered.
  35577. * Can happen multiple times per frame.
  35578. */
  35579. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35580. /**
  35581. * An event triggered before calculating deterministic simulation step
  35582. */
  35583. onBeforeStepObservable: Observable<Scene>;
  35584. /**
  35585. * An event triggered after calculating deterministic simulation step
  35586. */
  35587. onAfterStepObservable: Observable<Scene>;
  35588. /**
  35589. * An event triggered when the activeCamera property is updated
  35590. */
  35591. onActiveCameraChanged: Observable<Scene>;
  35592. /**
  35593. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35594. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35595. * 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)
  35596. */
  35597. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35598. /**
  35599. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35600. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35601. * 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)
  35602. */
  35603. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35604. /**
  35605. * This Observable will when a mesh has been imported into the scene.
  35606. */
  35607. onMeshImportedObservable: Observable<AbstractMesh>;
  35608. /**
  35609. * This Observable will when an animation file has been imported into the scene.
  35610. */
  35611. onAnimationFileImportedObservable: Observable<Scene>;
  35612. /**
  35613. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35614. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35615. */
  35616. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35617. /** @hidden */
  35618. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35619. /**
  35620. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35621. */
  35622. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35623. /**
  35624. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35625. */
  35626. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35627. /**
  35628. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35629. */
  35630. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35631. /** Callback called when a pointer move is detected */
  35632. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35633. /** Callback called when a pointer down is detected */
  35634. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35635. /** Callback called when a pointer up is detected */
  35636. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35637. /** Callback called when a pointer pick is detected */
  35638. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35639. /**
  35640. * 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).
  35641. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35642. */
  35643. onPrePointerObservable: Observable<PointerInfoPre>;
  35644. /**
  35645. * Observable event triggered each time an input event is received from the rendering canvas
  35646. */
  35647. onPointerObservable: Observable<PointerInfo>;
  35648. /**
  35649. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35650. */
  35651. get unTranslatedPointer(): Vector2;
  35652. /**
  35653. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35654. */
  35655. static get DragMovementThreshold(): number;
  35656. static set DragMovementThreshold(value: number);
  35657. /**
  35658. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35659. */
  35660. static get LongPressDelay(): number;
  35661. static set LongPressDelay(value: number);
  35662. /**
  35663. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35664. */
  35665. static get DoubleClickDelay(): number;
  35666. static set DoubleClickDelay(value: number);
  35667. /** If you need to check double click without raising a single click at first click, enable this flag */
  35668. static get ExclusiveDoubleClickMode(): boolean;
  35669. static set ExclusiveDoubleClickMode(value: boolean);
  35670. /** @hidden */
  35671. _mirroredCameraPosition: Nullable<Vector3>;
  35672. /**
  35673. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35674. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35675. */
  35676. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35677. /**
  35678. * Observable event triggered each time an keyboard event is received from the hosting window
  35679. */
  35680. onKeyboardObservable: Observable<KeyboardInfo>;
  35681. private _useRightHandedSystem;
  35682. /**
  35683. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35684. */
  35685. set useRightHandedSystem(value: boolean);
  35686. get useRightHandedSystem(): boolean;
  35687. private _timeAccumulator;
  35688. private _currentStepId;
  35689. private _currentInternalStep;
  35690. /**
  35691. * Sets the step Id used by deterministic lock step
  35692. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35693. * @param newStepId defines the step Id
  35694. */
  35695. setStepId(newStepId: number): void;
  35696. /**
  35697. * Gets the step Id used by deterministic lock step
  35698. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35699. * @returns the step Id
  35700. */
  35701. getStepId(): number;
  35702. /**
  35703. * Gets the internal step used by deterministic lock step
  35704. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35705. * @returns the internal step
  35706. */
  35707. getInternalStep(): number;
  35708. private _fogEnabled;
  35709. /**
  35710. * Gets or sets a boolean indicating if fog is enabled on this scene
  35711. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35712. * (Default is true)
  35713. */
  35714. set fogEnabled(value: boolean);
  35715. get fogEnabled(): boolean;
  35716. private _fogMode;
  35717. /**
  35718. * Gets or sets the fog mode to use
  35719. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35720. * | mode | value |
  35721. * | --- | --- |
  35722. * | FOGMODE_NONE | 0 |
  35723. * | FOGMODE_EXP | 1 |
  35724. * | FOGMODE_EXP2 | 2 |
  35725. * | FOGMODE_LINEAR | 3 |
  35726. */
  35727. set fogMode(value: number);
  35728. get fogMode(): number;
  35729. /**
  35730. * Gets or sets the fog color to use
  35731. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35732. * (Default is Color3(0.2, 0.2, 0.3))
  35733. */
  35734. fogColor: Color3;
  35735. /**
  35736. * Gets or sets the fog density to use
  35737. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35738. * (Default is 0.1)
  35739. */
  35740. fogDensity: number;
  35741. /**
  35742. * Gets or sets the fog start distance to use
  35743. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35744. * (Default is 0)
  35745. */
  35746. fogStart: number;
  35747. /**
  35748. * Gets or sets the fog end distance to use
  35749. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35750. * (Default is 1000)
  35751. */
  35752. fogEnd: number;
  35753. private _shadowsEnabled;
  35754. /**
  35755. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35756. */
  35757. set shadowsEnabled(value: boolean);
  35758. get shadowsEnabled(): boolean;
  35759. private _lightsEnabled;
  35760. /**
  35761. * Gets or sets a boolean indicating if lights are enabled on this scene
  35762. */
  35763. set lightsEnabled(value: boolean);
  35764. get lightsEnabled(): boolean;
  35765. /** All of the active cameras added to this scene. */
  35766. activeCameras: Camera[];
  35767. /** @hidden */
  35768. _activeCamera: Nullable<Camera>;
  35769. /** Gets or sets the current active camera */
  35770. get activeCamera(): Nullable<Camera>;
  35771. set activeCamera(value: Nullable<Camera>);
  35772. private _defaultMaterial;
  35773. /** The default material used on meshes when no material is affected */
  35774. get defaultMaterial(): Material;
  35775. /** The default material used on meshes when no material is affected */
  35776. set defaultMaterial(value: Material);
  35777. private _texturesEnabled;
  35778. /**
  35779. * Gets or sets a boolean indicating if textures are enabled on this scene
  35780. */
  35781. set texturesEnabled(value: boolean);
  35782. get texturesEnabled(): boolean;
  35783. /**
  35784. * Gets or sets a boolean indicating if particles are enabled on this scene
  35785. */
  35786. particlesEnabled: boolean;
  35787. /**
  35788. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35789. */
  35790. spritesEnabled: boolean;
  35791. private _skeletonsEnabled;
  35792. /**
  35793. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35794. */
  35795. set skeletonsEnabled(value: boolean);
  35796. get skeletonsEnabled(): boolean;
  35797. /**
  35798. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35799. */
  35800. lensFlaresEnabled: boolean;
  35801. /**
  35802. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35803. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35804. */
  35805. collisionsEnabled: boolean;
  35806. private _collisionCoordinator;
  35807. /** @hidden */
  35808. get collisionCoordinator(): ICollisionCoordinator;
  35809. /**
  35810. * Defines the gravity applied to this scene (used only for collisions)
  35811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35812. */
  35813. gravity: Vector3;
  35814. /**
  35815. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35816. */
  35817. postProcessesEnabled: boolean;
  35818. /**
  35819. * The list of postprocesses added to the scene
  35820. */
  35821. postProcesses: PostProcess[];
  35822. /**
  35823. * Gets the current postprocess manager
  35824. */
  35825. postProcessManager: PostProcessManager;
  35826. /**
  35827. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35828. */
  35829. renderTargetsEnabled: boolean;
  35830. /**
  35831. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35832. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35833. */
  35834. dumpNextRenderTargets: boolean;
  35835. /**
  35836. * The list of user defined render targets added to the scene
  35837. */
  35838. customRenderTargets: RenderTargetTexture[];
  35839. /**
  35840. * Defines if texture loading must be delayed
  35841. * If true, textures will only be loaded when they need to be rendered
  35842. */
  35843. useDelayedTextureLoading: boolean;
  35844. /**
  35845. * Gets the list of meshes imported to the scene through SceneLoader
  35846. */
  35847. importedMeshesFiles: String[];
  35848. /**
  35849. * Gets or sets a boolean indicating if probes are enabled on this scene
  35850. */
  35851. probesEnabled: boolean;
  35852. /**
  35853. * Gets or sets the current offline provider to use to store scene data
  35854. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35855. */
  35856. offlineProvider: IOfflineProvider;
  35857. /**
  35858. * Gets or sets the action manager associated with the scene
  35859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35860. */
  35861. actionManager: AbstractActionManager;
  35862. private _meshesForIntersections;
  35863. /**
  35864. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35865. */
  35866. proceduralTexturesEnabled: boolean;
  35867. private _engine;
  35868. private _totalVertices;
  35869. /** @hidden */
  35870. _activeIndices: PerfCounter;
  35871. /** @hidden */
  35872. _activeParticles: PerfCounter;
  35873. /** @hidden */
  35874. _activeBones: PerfCounter;
  35875. private _animationRatio;
  35876. /** @hidden */
  35877. _animationTimeLast: number;
  35878. /** @hidden */
  35879. _animationTime: number;
  35880. /**
  35881. * Gets or sets a general scale for animation speed
  35882. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35883. */
  35884. animationTimeScale: number;
  35885. /** @hidden */
  35886. _cachedMaterial: Nullable<Material>;
  35887. /** @hidden */
  35888. _cachedEffect: Nullable<Effect>;
  35889. /** @hidden */
  35890. _cachedVisibility: Nullable<number>;
  35891. private _renderId;
  35892. private _frameId;
  35893. private _executeWhenReadyTimeoutId;
  35894. private _intermediateRendering;
  35895. private _viewUpdateFlag;
  35896. private _projectionUpdateFlag;
  35897. /** @hidden */
  35898. _toBeDisposed: Nullable<IDisposable>[];
  35899. private _activeRequests;
  35900. /** @hidden */
  35901. _pendingData: any[];
  35902. private _isDisposed;
  35903. /**
  35904. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35905. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35906. */
  35907. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35908. private _activeMeshes;
  35909. private _processedMaterials;
  35910. private _renderTargets;
  35911. /** @hidden */
  35912. _activeParticleSystems: SmartArray<IParticleSystem>;
  35913. private _activeSkeletons;
  35914. private _softwareSkinnedMeshes;
  35915. private _renderingManager;
  35916. /** @hidden */
  35917. _activeAnimatables: Animatable[];
  35918. private _transformMatrix;
  35919. private _sceneUbo;
  35920. /** @hidden */
  35921. _viewMatrix: Matrix;
  35922. private _projectionMatrix;
  35923. /** @hidden */
  35924. _forcedViewPosition: Nullable<Vector3>;
  35925. /** @hidden */
  35926. _frustumPlanes: Plane[];
  35927. /**
  35928. * Gets the list of frustum planes (built from the active camera)
  35929. */
  35930. get frustumPlanes(): Plane[];
  35931. /**
  35932. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35933. * This is useful if there are more lights that the maximum simulteanous authorized
  35934. */
  35935. requireLightSorting: boolean;
  35936. /** @hidden */
  35937. readonly useMaterialMeshMap: boolean;
  35938. /** @hidden */
  35939. readonly useClonedMeshMap: boolean;
  35940. private _externalData;
  35941. private _uid;
  35942. /**
  35943. * @hidden
  35944. * Backing store of defined scene components.
  35945. */
  35946. _components: ISceneComponent[];
  35947. /**
  35948. * @hidden
  35949. * Backing store of defined scene components.
  35950. */
  35951. _serializableComponents: ISceneSerializableComponent[];
  35952. /**
  35953. * List of components to register on the next registration step.
  35954. */
  35955. private _transientComponents;
  35956. /**
  35957. * Registers the transient components if needed.
  35958. */
  35959. private _registerTransientComponents;
  35960. /**
  35961. * @hidden
  35962. * Add a component to the scene.
  35963. * Note that the ccomponent could be registered on th next frame if this is called after
  35964. * the register component stage.
  35965. * @param component Defines the component to add to the scene
  35966. */
  35967. _addComponent(component: ISceneComponent): void;
  35968. /**
  35969. * @hidden
  35970. * Gets a component from the scene.
  35971. * @param name defines the name of the component to retrieve
  35972. * @returns the component or null if not present
  35973. */
  35974. _getComponent(name: string): Nullable<ISceneComponent>;
  35975. /**
  35976. * @hidden
  35977. * Defines the actions happening before camera updates.
  35978. */
  35979. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35980. /**
  35981. * @hidden
  35982. * Defines the actions happening before clear the canvas.
  35983. */
  35984. _beforeClearStage: Stage<SimpleStageAction>;
  35985. /**
  35986. * @hidden
  35987. * Defines the actions when collecting render targets for the frame.
  35988. */
  35989. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35990. /**
  35991. * @hidden
  35992. * Defines the actions happening for one camera in the frame.
  35993. */
  35994. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35995. /**
  35996. * @hidden
  35997. * Defines the actions happening during the per mesh ready checks.
  35998. */
  35999. _isReadyForMeshStage: Stage<MeshStageAction>;
  36000. /**
  36001. * @hidden
  36002. * Defines the actions happening before evaluate active mesh checks.
  36003. */
  36004. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36005. /**
  36006. * @hidden
  36007. * Defines the actions happening during the evaluate sub mesh checks.
  36008. */
  36009. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36010. /**
  36011. * @hidden
  36012. * Defines the actions happening during the active mesh stage.
  36013. */
  36014. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36015. /**
  36016. * @hidden
  36017. * Defines the actions happening during the per camera render target step.
  36018. */
  36019. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36020. /**
  36021. * @hidden
  36022. * Defines the actions happening just before the active camera is drawing.
  36023. */
  36024. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36025. /**
  36026. * @hidden
  36027. * Defines the actions happening just before a render target is drawing.
  36028. */
  36029. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36030. /**
  36031. * @hidden
  36032. * Defines the actions happening just before a rendering group is drawing.
  36033. */
  36034. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36035. /**
  36036. * @hidden
  36037. * Defines the actions happening just before a mesh is drawing.
  36038. */
  36039. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36040. /**
  36041. * @hidden
  36042. * Defines the actions happening just after a mesh has been drawn.
  36043. */
  36044. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36045. /**
  36046. * @hidden
  36047. * Defines the actions happening just after a rendering group has been drawn.
  36048. */
  36049. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36050. /**
  36051. * @hidden
  36052. * Defines the actions happening just after the active camera has been drawn.
  36053. */
  36054. _afterCameraDrawStage: Stage<CameraStageAction>;
  36055. /**
  36056. * @hidden
  36057. * Defines the actions happening just after a render target has been drawn.
  36058. */
  36059. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36060. /**
  36061. * @hidden
  36062. * Defines the actions happening just after rendering all cameras and computing intersections.
  36063. */
  36064. _afterRenderStage: Stage<SimpleStageAction>;
  36065. /**
  36066. * @hidden
  36067. * Defines the actions happening when a pointer move event happens.
  36068. */
  36069. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36070. /**
  36071. * @hidden
  36072. * Defines the actions happening when a pointer down event happens.
  36073. */
  36074. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36075. /**
  36076. * @hidden
  36077. * Defines the actions happening when a pointer up event happens.
  36078. */
  36079. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36080. /**
  36081. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36082. */
  36083. private geometriesByUniqueId;
  36084. /**
  36085. * Creates a new Scene
  36086. * @param engine defines the engine to use to render this scene
  36087. * @param options defines the scene options
  36088. */
  36089. constructor(engine: Engine, options?: SceneOptions);
  36090. /**
  36091. * Gets a string idenfifying the name of the class
  36092. * @returns "Scene" string
  36093. */
  36094. getClassName(): string;
  36095. private _defaultMeshCandidates;
  36096. /**
  36097. * @hidden
  36098. */
  36099. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36100. private _defaultSubMeshCandidates;
  36101. /**
  36102. * @hidden
  36103. */
  36104. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36105. /**
  36106. * Sets the default candidate providers for the scene.
  36107. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36108. * and getCollidingSubMeshCandidates to their default function
  36109. */
  36110. setDefaultCandidateProviders(): void;
  36111. /**
  36112. * Gets the mesh that is currently under the pointer
  36113. */
  36114. get meshUnderPointer(): Nullable<AbstractMesh>;
  36115. /**
  36116. * Gets or sets the current on-screen X position of the pointer
  36117. */
  36118. get pointerX(): number;
  36119. set pointerX(value: number);
  36120. /**
  36121. * Gets or sets the current on-screen Y position of the pointer
  36122. */
  36123. get pointerY(): number;
  36124. set pointerY(value: number);
  36125. /**
  36126. * Gets the cached material (ie. the latest rendered one)
  36127. * @returns the cached material
  36128. */
  36129. getCachedMaterial(): Nullable<Material>;
  36130. /**
  36131. * Gets the cached effect (ie. the latest rendered one)
  36132. * @returns the cached effect
  36133. */
  36134. getCachedEffect(): Nullable<Effect>;
  36135. /**
  36136. * Gets the cached visibility state (ie. the latest rendered one)
  36137. * @returns the cached visibility state
  36138. */
  36139. getCachedVisibility(): Nullable<number>;
  36140. /**
  36141. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36142. * @param material defines the current material
  36143. * @param effect defines the current effect
  36144. * @param visibility defines the current visibility state
  36145. * @returns true if one parameter is not cached
  36146. */
  36147. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36148. /**
  36149. * Gets the engine associated with the scene
  36150. * @returns an Engine
  36151. */
  36152. getEngine(): Engine;
  36153. /**
  36154. * Gets the total number of vertices rendered per frame
  36155. * @returns the total number of vertices rendered per frame
  36156. */
  36157. getTotalVertices(): number;
  36158. /**
  36159. * Gets the performance counter for total vertices
  36160. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36161. */
  36162. get totalVerticesPerfCounter(): PerfCounter;
  36163. /**
  36164. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36165. * @returns the total number of active indices rendered per frame
  36166. */
  36167. getActiveIndices(): number;
  36168. /**
  36169. * Gets the performance counter for active indices
  36170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36171. */
  36172. get totalActiveIndicesPerfCounter(): PerfCounter;
  36173. /**
  36174. * Gets the total number of active particles rendered per frame
  36175. * @returns the total number of active particles rendered per frame
  36176. */
  36177. getActiveParticles(): number;
  36178. /**
  36179. * Gets the performance counter for active particles
  36180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36181. */
  36182. get activeParticlesPerfCounter(): PerfCounter;
  36183. /**
  36184. * Gets the total number of active bones rendered per frame
  36185. * @returns the total number of active bones rendered per frame
  36186. */
  36187. getActiveBones(): number;
  36188. /**
  36189. * Gets the performance counter for active bones
  36190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36191. */
  36192. get activeBonesPerfCounter(): PerfCounter;
  36193. /**
  36194. * Gets the array of active meshes
  36195. * @returns an array of AbstractMesh
  36196. */
  36197. getActiveMeshes(): SmartArray<AbstractMesh>;
  36198. /**
  36199. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36200. * @returns a number
  36201. */
  36202. getAnimationRatio(): number;
  36203. /**
  36204. * Gets an unique Id for the current render phase
  36205. * @returns a number
  36206. */
  36207. getRenderId(): number;
  36208. /**
  36209. * Gets an unique Id for the current frame
  36210. * @returns a number
  36211. */
  36212. getFrameId(): number;
  36213. /** Call this function if you want to manually increment the render Id*/
  36214. incrementRenderId(): void;
  36215. private _createUbo;
  36216. /**
  36217. * Use this method to simulate a pointer move on a mesh
  36218. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36219. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36220. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36221. * @returns the current scene
  36222. */
  36223. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36224. /**
  36225. * Use this method to simulate a pointer down on a mesh
  36226. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36227. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36228. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36229. * @returns the current scene
  36230. */
  36231. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36232. /**
  36233. * Use this method to simulate a pointer up on a mesh
  36234. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36235. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36236. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36237. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36238. * @returns the current scene
  36239. */
  36240. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36241. /**
  36242. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36243. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36244. * @returns true if the pointer was captured
  36245. */
  36246. isPointerCaptured(pointerId?: number): boolean;
  36247. /**
  36248. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36249. * @param attachUp defines if you want to attach events to pointerup
  36250. * @param attachDown defines if you want to attach events to pointerdown
  36251. * @param attachMove defines if you want to attach events to pointermove
  36252. */
  36253. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36254. /** Detaches all event handlers*/
  36255. detachControl(): void;
  36256. /**
  36257. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36258. * Delay loaded resources are not taking in account
  36259. * @return true if all required resources are ready
  36260. */
  36261. isReady(): boolean;
  36262. /** Resets all cached information relative to material (including effect and visibility) */
  36263. resetCachedMaterial(): void;
  36264. /**
  36265. * Registers a function to be called before every frame render
  36266. * @param func defines the function to register
  36267. */
  36268. registerBeforeRender(func: () => void): void;
  36269. /**
  36270. * Unregisters a function called before every frame render
  36271. * @param func defines the function to unregister
  36272. */
  36273. unregisterBeforeRender(func: () => void): void;
  36274. /**
  36275. * Registers a function to be called after every frame render
  36276. * @param func defines the function to register
  36277. */
  36278. registerAfterRender(func: () => void): void;
  36279. /**
  36280. * Unregisters a function called after every frame render
  36281. * @param func defines the function to unregister
  36282. */
  36283. unregisterAfterRender(func: () => void): void;
  36284. private _executeOnceBeforeRender;
  36285. /**
  36286. * The provided function will run before render once and will be disposed afterwards.
  36287. * A timeout delay can be provided so that the function will be executed in N ms.
  36288. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36289. * @param func The function to be executed.
  36290. * @param timeout optional delay in ms
  36291. */
  36292. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36293. /** @hidden */
  36294. _addPendingData(data: any): void;
  36295. /** @hidden */
  36296. _removePendingData(data: any): void;
  36297. /**
  36298. * Returns the number of items waiting to be loaded
  36299. * @returns the number of items waiting to be loaded
  36300. */
  36301. getWaitingItemsCount(): number;
  36302. /**
  36303. * Returns a boolean indicating if the scene is still loading data
  36304. */
  36305. get isLoading(): boolean;
  36306. /**
  36307. * Registers a function to be executed when the scene is ready
  36308. * @param {Function} func - the function to be executed
  36309. */
  36310. executeWhenReady(func: () => void): void;
  36311. /**
  36312. * Returns a promise that resolves when the scene is ready
  36313. * @returns A promise that resolves when the scene is ready
  36314. */
  36315. whenReadyAsync(): Promise<void>;
  36316. /** @hidden */
  36317. _checkIsReady(): void;
  36318. /**
  36319. * Gets all animatable attached to the scene
  36320. */
  36321. get animatables(): Animatable[];
  36322. /**
  36323. * Resets the last animation time frame.
  36324. * Useful to override when animations start running when loading a scene for the first time.
  36325. */
  36326. resetLastAnimationTimeFrame(): void;
  36327. /**
  36328. * Gets the current view matrix
  36329. * @returns a Matrix
  36330. */
  36331. getViewMatrix(): Matrix;
  36332. /**
  36333. * Gets the current projection matrix
  36334. * @returns a Matrix
  36335. */
  36336. getProjectionMatrix(): Matrix;
  36337. /**
  36338. * Gets the current transform matrix
  36339. * @returns a Matrix made of View * Projection
  36340. */
  36341. getTransformMatrix(): Matrix;
  36342. /**
  36343. * Sets the current transform matrix
  36344. * @param viewL defines the View matrix to use
  36345. * @param projectionL defines the Projection matrix to use
  36346. * @param viewR defines the right View matrix to use (if provided)
  36347. * @param projectionR defines the right Projection matrix to use (if provided)
  36348. */
  36349. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36350. /**
  36351. * Gets the uniform buffer used to store scene data
  36352. * @returns a UniformBuffer
  36353. */
  36354. getSceneUniformBuffer(): UniformBuffer;
  36355. /**
  36356. * Gets an unique (relatively to the current scene) Id
  36357. * @returns an unique number for the scene
  36358. */
  36359. getUniqueId(): number;
  36360. /**
  36361. * Add a mesh to the list of scene's meshes
  36362. * @param newMesh defines the mesh to add
  36363. * @param recursive if all child meshes should also be added to the scene
  36364. */
  36365. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36366. /**
  36367. * Remove a mesh for the list of scene's meshes
  36368. * @param toRemove defines the mesh to remove
  36369. * @param recursive if all child meshes should also be removed from the scene
  36370. * @returns the index where the mesh was in the mesh list
  36371. */
  36372. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36373. /**
  36374. * Add a transform node to the list of scene's transform nodes
  36375. * @param newTransformNode defines the transform node to add
  36376. */
  36377. addTransformNode(newTransformNode: TransformNode): void;
  36378. /**
  36379. * Remove a transform node for the list of scene's transform nodes
  36380. * @param toRemove defines the transform node to remove
  36381. * @returns the index where the transform node was in the transform node list
  36382. */
  36383. removeTransformNode(toRemove: TransformNode): number;
  36384. /**
  36385. * Remove a skeleton for the list of scene's skeletons
  36386. * @param toRemove defines the skeleton to remove
  36387. * @returns the index where the skeleton was in the skeleton list
  36388. */
  36389. removeSkeleton(toRemove: Skeleton): number;
  36390. /**
  36391. * Remove a morph target for the list of scene's morph targets
  36392. * @param toRemove defines the morph target to remove
  36393. * @returns the index where the morph target was in the morph target list
  36394. */
  36395. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36396. /**
  36397. * Remove a light for the list of scene's lights
  36398. * @param toRemove defines the light to remove
  36399. * @returns the index where the light was in the light list
  36400. */
  36401. removeLight(toRemove: Light): number;
  36402. /**
  36403. * Remove a camera for the list of scene's cameras
  36404. * @param toRemove defines the camera to remove
  36405. * @returns the index where the camera was in the camera list
  36406. */
  36407. removeCamera(toRemove: Camera): number;
  36408. /**
  36409. * Remove a particle system for the list of scene's particle systems
  36410. * @param toRemove defines the particle system to remove
  36411. * @returns the index where the particle system was in the particle system list
  36412. */
  36413. removeParticleSystem(toRemove: IParticleSystem): number;
  36414. /**
  36415. * Remove a animation for the list of scene's animations
  36416. * @param toRemove defines the animation to remove
  36417. * @returns the index where the animation was in the animation list
  36418. */
  36419. removeAnimation(toRemove: Animation): number;
  36420. /**
  36421. * Will stop the animation of the given target
  36422. * @param target - the target
  36423. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36424. * @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)
  36425. */
  36426. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36427. /**
  36428. * Removes the given animation group from this scene.
  36429. * @param toRemove The animation group to remove
  36430. * @returns The index of the removed animation group
  36431. */
  36432. removeAnimationGroup(toRemove: AnimationGroup): number;
  36433. /**
  36434. * Removes the given multi-material from this scene.
  36435. * @param toRemove The multi-material to remove
  36436. * @returns The index of the removed multi-material
  36437. */
  36438. removeMultiMaterial(toRemove: MultiMaterial): number;
  36439. /**
  36440. * Removes the given material from this scene.
  36441. * @param toRemove The material to remove
  36442. * @returns The index of the removed material
  36443. */
  36444. removeMaterial(toRemove: Material): number;
  36445. /**
  36446. * Removes the given action manager from this scene.
  36447. * @param toRemove The action manager to remove
  36448. * @returns The index of the removed action manager
  36449. */
  36450. removeActionManager(toRemove: AbstractActionManager): number;
  36451. /**
  36452. * Removes the given texture from this scene.
  36453. * @param toRemove The texture to remove
  36454. * @returns The index of the removed texture
  36455. */
  36456. removeTexture(toRemove: BaseTexture): number;
  36457. /**
  36458. * Adds the given light to this scene
  36459. * @param newLight The light to add
  36460. */
  36461. addLight(newLight: Light): void;
  36462. /**
  36463. * Sorts the list list based on light priorities
  36464. */
  36465. sortLightsByPriority(): void;
  36466. /**
  36467. * Adds the given camera to this scene
  36468. * @param newCamera The camera to add
  36469. */
  36470. addCamera(newCamera: Camera): void;
  36471. /**
  36472. * Adds the given skeleton to this scene
  36473. * @param newSkeleton The skeleton to add
  36474. */
  36475. addSkeleton(newSkeleton: Skeleton): void;
  36476. /**
  36477. * Adds the given particle system to this scene
  36478. * @param newParticleSystem The particle system to add
  36479. */
  36480. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36481. /**
  36482. * Adds the given animation to this scene
  36483. * @param newAnimation The animation to add
  36484. */
  36485. addAnimation(newAnimation: Animation): void;
  36486. /**
  36487. * Adds the given animation group to this scene.
  36488. * @param newAnimationGroup The animation group to add
  36489. */
  36490. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36491. /**
  36492. * Adds the given multi-material to this scene
  36493. * @param newMultiMaterial The multi-material to add
  36494. */
  36495. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36496. /**
  36497. * Adds the given material to this scene
  36498. * @param newMaterial The material to add
  36499. */
  36500. addMaterial(newMaterial: Material): void;
  36501. /**
  36502. * Adds the given morph target to this scene
  36503. * @param newMorphTargetManager The morph target to add
  36504. */
  36505. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36506. /**
  36507. * Adds the given geometry to this scene
  36508. * @param newGeometry The geometry to add
  36509. */
  36510. addGeometry(newGeometry: Geometry): void;
  36511. /**
  36512. * Adds the given action manager to this scene
  36513. * @param newActionManager The action manager to add
  36514. */
  36515. addActionManager(newActionManager: AbstractActionManager): void;
  36516. /**
  36517. * Adds the given texture to this scene.
  36518. * @param newTexture The texture to add
  36519. */
  36520. addTexture(newTexture: BaseTexture): void;
  36521. /**
  36522. * Switch active camera
  36523. * @param newCamera defines the new active camera
  36524. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36525. */
  36526. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36527. /**
  36528. * sets the active camera of the scene using its ID
  36529. * @param id defines the camera's ID
  36530. * @return the new active camera or null if none found.
  36531. */
  36532. setActiveCameraByID(id: string): Nullable<Camera>;
  36533. /**
  36534. * sets the active camera of the scene using its name
  36535. * @param name defines the camera's name
  36536. * @returns the new active camera or null if none found.
  36537. */
  36538. setActiveCameraByName(name: string): Nullable<Camera>;
  36539. /**
  36540. * get an animation group using its name
  36541. * @param name defines the material's name
  36542. * @return the animation group or null if none found.
  36543. */
  36544. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36545. /**
  36546. * Get a material using its unique id
  36547. * @param uniqueId defines the material's unique id
  36548. * @return the material or null if none found.
  36549. */
  36550. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36551. /**
  36552. * get a material using its id
  36553. * @param id defines the material's ID
  36554. * @return the material or null if none found.
  36555. */
  36556. getMaterialByID(id: string): Nullable<Material>;
  36557. /**
  36558. * Gets a the last added material using a given id
  36559. * @param id defines the material's ID
  36560. * @return the last material with the given id or null if none found.
  36561. */
  36562. getLastMaterialByID(id: string): Nullable<Material>;
  36563. /**
  36564. * Gets a material using its name
  36565. * @param name defines the material's name
  36566. * @return the material or null if none found.
  36567. */
  36568. getMaterialByName(name: string): Nullable<Material>;
  36569. /**
  36570. * Get a texture using its unique id
  36571. * @param uniqueId defines the texture's unique id
  36572. * @return the texture or null if none found.
  36573. */
  36574. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36575. /**
  36576. * Gets a camera using its id
  36577. * @param id defines the id to look for
  36578. * @returns the camera or null if not found
  36579. */
  36580. getCameraByID(id: string): Nullable<Camera>;
  36581. /**
  36582. * Gets a camera using its unique id
  36583. * @param uniqueId defines the unique id to look for
  36584. * @returns the camera or null if not found
  36585. */
  36586. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36587. /**
  36588. * Gets a camera using its name
  36589. * @param name defines the camera's name
  36590. * @return the camera or null if none found.
  36591. */
  36592. getCameraByName(name: string): Nullable<Camera>;
  36593. /**
  36594. * Gets a bone using its id
  36595. * @param id defines the bone's id
  36596. * @return the bone or null if not found
  36597. */
  36598. getBoneByID(id: string): Nullable<Bone>;
  36599. /**
  36600. * Gets a bone using its id
  36601. * @param name defines the bone's name
  36602. * @return the bone or null if not found
  36603. */
  36604. getBoneByName(name: string): Nullable<Bone>;
  36605. /**
  36606. * Gets a light node using its name
  36607. * @param name defines the the light's name
  36608. * @return the light or null if none found.
  36609. */
  36610. getLightByName(name: string): Nullable<Light>;
  36611. /**
  36612. * Gets a light node using its id
  36613. * @param id defines the light's id
  36614. * @return the light or null if none found.
  36615. */
  36616. getLightByID(id: string): Nullable<Light>;
  36617. /**
  36618. * Gets a light node using its scene-generated unique ID
  36619. * @param uniqueId defines the light's unique id
  36620. * @return the light or null if none found.
  36621. */
  36622. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36623. /**
  36624. * Gets a particle system by id
  36625. * @param id defines the particle system id
  36626. * @return the corresponding system or null if none found
  36627. */
  36628. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36629. /**
  36630. * Gets a geometry using its ID
  36631. * @param id defines the geometry's id
  36632. * @return the geometry or null if none found.
  36633. */
  36634. getGeometryByID(id: string): Nullable<Geometry>;
  36635. private _getGeometryByUniqueID;
  36636. /**
  36637. * Add a new geometry to this scene
  36638. * @param geometry defines the geometry to be added to the scene.
  36639. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36640. * @return a boolean defining if the geometry was added or not
  36641. */
  36642. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36643. /**
  36644. * Removes an existing geometry
  36645. * @param geometry defines the geometry to be removed from the scene
  36646. * @return a boolean defining if the geometry was removed or not
  36647. */
  36648. removeGeometry(geometry: Geometry): boolean;
  36649. /**
  36650. * Gets the list of geometries attached to the scene
  36651. * @returns an array of Geometry
  36652. */
  36653. getGeometries(): Geometry[];
  36654. /**
  36655. * Gets the first added mesh found of a given ID
  36656. * @param id defines the id to search for
  36657. * @return the mesh found or null if not found at all
  36658. */
  36659. getMeshByID(id: string): Nullable<AbstractMesh>;
  36660. /**
  36661. * Gets a list of meshes using their id
  36662. * @param id defines the id to search for
  36663. * @returns a list of meshes
  36664. */
  36665. getMeshesByID(id: string): Array<AbstractMesh>;
  36666. /**
  36667. * Gets the first added transform node found of a given ID
  36668. * @param id defines the id to search for
  36669. * @return the found transform node or null if not found at all.
  36670. */
  36671. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36672. /**
  36673. * Gets a transform node with its auto-generated unique id
  36674. * @param uniqueId efines the unique id to search for
  36675. * @return the found transform node or null if not found at all.
  36676. */
  36677. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36678. /**
  36679. * Gets a list of transform nodes using their id
  36680. * @param id defines the id to search for
  36681. * @returns a list of transform nodes
  36682. */
  36683. getTransformNodesByID(id: string): Array<TransformNode>;
  36684. /**
  36685. * Gets a mesh with its auto-generated unique id
  36686. * @param uniqueId defines the unique id to search for
  36687. * @return the found mesh or null if not found at all.
  36688. */
  36689. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36690. /**
  36691. * Gets a the last added mesh using a given id
  36692. * @param id defines the id to search for
  36693. * @return the found mesh or null if not found at all.
  36694. */
  36695. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36696. /**
  36697. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36698. * @param id defines the id to search for
  36699. * @return the found node or null if not found at all
  36700. */
  36701. getLastEntryByID(id: string): Nullable<Node>;
  36702. /**
  36703. * Gets a node (Mesh, Camera, Light) using a given id
  36704. * @param id defines the id to search for
  36705. * @return the found node or null if not found at all
  36706. */
  36707. getNodeByID(id: string): Nullable<Node>;
  36708. /**
  36709. * Gets a node (Mesh, Camera, Light) using a given name
  36710. * @param name defines the name to search for
  36711. * @return the found node or null if not found at all.
  36712. */
  36713. getNodeByName(name: string): Nullable<Node>;
  36714. /**
  36715. * Gets a mesh using a given name
  36716. * @param name defines the name to search for
  36717. * @return the found mesh or null if not found at all.
  36718. */
  36719. getMeshByName(name: string): Nullable<AbstractMesh>;
  36720. /**
  36721. * Gets a transform node using a given name
  36722. * @param name defines the name to search for
  36723. * @return the found transform node or null if not found at all.
  36724. */
  36725. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36726. /**
  36727. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36728. * @param id defines the id to search for
  36729. * @return the found skeleton or null if not found at all.
  36730. */
  36731. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36732. /**
  36733. * Gets a skeleton using a given auto generated unique id
  36734. * @param uniqueId defines the unique id to search for
  36735. * @return the found skeleton or null if not found at all.
  36736. */
  36737. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36738. /**
  36739. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36740. * @param id defines the id to search for
  36741. * @return the found skeleton or null if not found at all.
  36742. */
  36743. getSkeletonById(id: string): Nullable<Skeleton>;
  36744. /**
  36745. * Gets a skeleton using a given name
  36746. * @param name defines the name to search for
  36747. * @return the found skeleton or null if not found at all.
  36748. */
  36749. getSkeletonByName(name: string): Nullable<Skeleton>;
  36750. /**
  36751. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36752. * @param id defines the id to search for
  36753. * @return the found morph target manager or null if not found at all.
  36754. */
  36755. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36756. /**
  36757. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36758. * @param id defines the id to search for
  36759. * @return the found morph target or null if not found at all.
  36760. */
  36761. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36762. /**
  36763. * Gets a boolean indicating if the given mesh is active
  36764. * @param mesh defines the mesh to look for
  36765. * @returns true if the mesh is in the active list
  36766. */
  36767. isActiveMesh(mesh: AbstractMesh): boolean;
  36768. /**
  36769. * Return a unique id as a string which can serve as an identifier for the scene
  36770. */
  36771. get uid(): string;
  36772. /**
  36773. * Add an externaly attached data from its key.
  36774. * This method call will fail and return false, if such key already exists.
  36775. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36776. * @param key the unique key that identifies the data
  36777. * @param data the data object to associate to the key for this Engine instance
  36778. * @return true if no such key were already present and the data was added successfully, false otherwise
  36779. */
  36780. addExternalData<T>(key: string, data: T): boolean;
  36781. /**
  36782. * Get an externaly attached data from its key
  36783. * @param key the unique key that identifies the data
  36784. * @return the associated data, if present (can be null), or undefined if not present
  36785. */
  36786. getExternalData<T>(key: string): Nullable<T>;
  36787. /**
  36788. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36789. * @param key the unique key that identifies the data
  36790. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36791. * @return the associated data, can be null if the factory returned null.
  36792. */
  36793. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36794. /**
  36795. * Remove an externaly attached data from the Engine instance
  36796. * @param key the unique key that identifies the data
  36797. * @return true if the data was successfully removed, false if it doesn't exist
  36798. */
  36799. removeExternalData(key: string): boolean;
  36800. private _evaluateSubMesh;
  36801. /**
  36802. * Clear the processed materials smart array preventing retention point in material dispose.
  36803. */
  36804. freeProcessedMaterials(): void;
  36805. private _preventFreeActiveMeshesAndRenderingGroups;
  36806. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36807. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36808. * when disposing several meshes in a row or a hierarchy of meshes.
  36809. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36810. */
  36811. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36812. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36813. /**
  36814. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36815. */
  36816. freeActiveMeshes(): void;
  36817. /**
  36818. * Clear the info related to rendering groups preventing retention points during dispose.
  36819. */
  36820. freeRenderingGroups(): void;
  36821. /** @hidden */
  36822. _isInIntermediateRendering(): boolean;
  36823. /**
  36824. * Lambda returning the list of potentially active meshes.
  36825. */
  36826. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36827. /**
  36828. * Lambda returning the list of potentially active sub meshes.
  36829. */
  36830. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36831. /**
  36832. * Lambda returning the list of potentially intersecting sub meshes.
  36833. */
  36834. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36835. /**
  36836. * Lambda returning the list of potentially colliding sub meshes.
  36837. */
  36838. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36839. private _activeMeshesFrozen;
  36840. private _skipEvaluateActiveMeshesCompletely;
  36841. /**
  36842. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36843. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36844. * @returns the current scene
  36845. */
  36846. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36847. /**
  36848. * Use this function to restart evaluating active meshes on every frame
  36849. * @returns the current scene
  36850. */
  36851. unfreezeActiveMeshes(): Scene;
  36852. private _evaluateActiveMeshes;
  36853. private _activeMesh;
  36854. /**
  36855. * Update the transform matrix to update from the current active camera
  36856. * @param force defines a boolean used to force the update even if cache is up to date
  36857. */
  36858. updateTransformMatrix(force?: boolean): void;
  36859. private _bindFrameBuffer;
  36860. /** @hidden */
  36861. _allowPostProcessClearColor: boolean;
  36862. /** @hidden */
  36863. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36864. private _processSubCameras;
  36865. private _checkIntersections;
  36866. /** @hidden */
  36867. _advancePhysicsEngineStep(step: number): void;
  36868. /**
  36869. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36870. */
  36871. getDeterministicFrameTime: () => number;
  36872. /** @hidden */
  36873. _animate(): void;
  36874. /** Execute all animations (for a frame) */
  36875. animate(): void;
  36876. /**
  36877. * Render the scene
  36878. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36879. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36880. */
  36881. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36882. /**
  36883. * Freeze all materials
  36884. * A frozen material will not be updatable but should be faster to render
  36885. */
  36886. freezeMaterials(): void;
  36887. /**
  36888. * Unfreeze all materials
  36889. * A frozen material will not be updatable but should be faster to render
  36890. */
  36891. unfreezeMaterials(): void;
  36892. /**
  36893. * Releases all held ressources
  36894. */
  36895. dispose(): void;
  36896. /**
  36897. * Gets if the scene is already disposed
  36898. */
  36899. get isDisposed(): boolean;
  36900. /**
  36901. * Call this function to reduce memory footprint of the scene.
  36902. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36903. */
  36904. clearCachedVertexData(): void;
  36905. /**
  36906. * This function will remove the local cached buffer data from texture.
  36907. * It will save memory but will prevent the texture from being rebuilt
  36908. */
  36909. cleanCachedTextureBuffer(): void;
  36910. /**
  36911. * Get the world extend vectors with an optional filter
  36912. *
  36913. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36914. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36915. */
  36916. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36917. min: Vector3;
  36918. max: Vector3;
  36919. };
  36920. /**
  36921. * Creates a ray that can be used to pick in the scene
  36922. * @param x defines the x coordinate of the origin (on-screen)
  36923. * @param y defines the y coordinate of the origin (on-screen)
  36924. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36925. * @param camera defines the camera to use for the picking
  36926. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36927. * @returns a Ray
  36928. */
  36929. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36930. /**
  36931. * Creates a ray that can be used to pick in the scene
  36932. * @param x defines the x coordinate of the origin (on-screen)
  36933. * @param y defines the y coordinate of the origin (on-screen)
  36934. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36935. * @param result defines the ray where to store the picking ray
  36936. * @param camera defines the camera to use for the picking
  36937. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36938. * @returns the current scene
  36939. */
  36940. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36941. /**
  36942. * Creates a ray that can be used to pick in the scene
  36943. * @param x defines the x coordinate of the origin (on-screen)
  36944. * @param y defines the y coordinate of the origin (on-screen)
  36945. * @param camera defines the camera to use for the picking
  36946. * @returns a Ray
  36947. */
  36948. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36949. /**
  36950. * Creates a ray that can be used to pick in the scene
  36951. * @param x defines the x coordinate of the origin (on-screen)
  36952. * @param y defines the y coordinate of the origin (on-screen)
  36953. * @param result defines the ray where to store the picking ray
  36954. * @param camera defines the camera to use for the picking
  36955. * @returns the current scene
  36956. */
  36957. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36958. /** Launch a ray to try to pick a mesh in the scene
  36959. * @param x position on screen
  36960. * @param y position on screen
  36961. * @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
  36962. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36963. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36964. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36965. * @returns a PickingInfo
  36966. */
  36967. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36968. /** Use the given ray to pick a mesh in the scene
  36969. * @param ray The ray to use to pick meshes
  36970. * @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
  36971. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36972. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36973. * @returns a PickingInfo
  36974. */
  36975. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36976. /**
  36977. * Launch a ray to try to pick a mesh in the scene
  36978. * @param x X position on screen
  36979. * @param y Y position on screen
  36980. * @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
  36981. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36982. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36983. * @returns an array of PickingInfo
  36984. */
  36985. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36986. /**
  36987. * Launch a ray to try to pick a mesh in the scene
  36988. * @param ray Ray to use
  36989. * @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
  36990. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36991. * @returns an array of PickingInfo
  36992. */
  36993. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36994. /**
  36995. * Force the value of meshUnderPointer
  36996. * @param mesh defines the mesh to use
  36997. */
  36998. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36999. /**
  37000. * Gets the mesh under the pointer
  37001. * @returns a Mesh or null if no mesh is under the pointer
  37002. */
  37003. getPointerOverMesh(): Nullable<AbstractMesh>;
  37004. /** @hidden */
  37005. _rebuildGeometries(): void;
  37006. /** @hidden */
  37007. _rebuildTextures(): void;
  37008. private _getByTags;
  37009. /**
  37010. * Get a list of meshes by tags
  37011. * @param tagsQuery defines the tags query to use
  37012. * @param forEach defines a predicate used to filter results
  37013. * @returns an array of Mesh
  37014. */
  37015. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37016. /**
  37017. * Get a list of cameras by tags
  37018. * @param tagsQuery defines the tags query to use
  37019. * @param forEach defines a predicate used to filter results
  37020. * @returns an array of Camera
  37021. */
  37022. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37023. /**
  37024. * Get a list of lights by tags
  37025. * @param tagsQuery defines the tags query to use
  37026. * @param forEach defines a predicate used to filter results
  37027. * @returns an array of Light
  37028. */
  37029. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37030. /**
  37031. * Get a list of materials by tags
  37032. * @param tagsQuery defines the tags query to use
  37033. * @param forEach defines a predicate used to filter results
  37034. * @returns an array of Material
  37035. */
  37036. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37037. /**
  37038. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37039. * This allowed control for front to back rendering or reversly depending of the special needs.
  37040. *
  37041. * @param renderingGroupId The rendering group id corresponding to its index
  37042. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37043. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37044. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37045. */
  37046. 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;
  37047. /**
  37048. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37049. *
  37050. * @param renderingGroupId The rendering group id corresponding to its index
  37051. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37052. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37053. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37054. */
  37055. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37056. /**
  37057. * Gets the current auto clear configuration for one rendering group of the rendering
  37058. * manager.
  37059. * @param index the rendering group index to get the information for
  37060. * @returns The auto clear setup for the requested rendering group
  37061. */
  37062. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37063. private _blockMaterialDirtyMechanism;
  37064. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37065. get blockMaterialDirtyMechanism(): boolean;
  37066. set blockMaterialDirtyMechanism(value: boolean);
  37067. /**
  37068. * Will flag all materials as dirty to trigger new shader compilation
  37069. * @param flag defines the flag used to specify which material part must be marked as dirty
  37070. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37071. */
  37072. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37073. /** @hidden */
  37074. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  37075. /** @hidden */
  37076. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37077. /** @hidden */
  37078. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  37079. /** @hidden */
  37080. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37081. /** @hidden */
  37082. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37083. /** @hidden */
  37084. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37085. }
  37086. }
  37087. declare module BABYLON {
  37088. /**
  37089. * Set of assets to keep when moving a scene into an asset container.
  37090. */
  37091. export class KeepAssets extends AbstractScene {
  37092. }
  37093. /**
  37094. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37095. */
  37096. export class InstantiatedEntries {
  37097. /**
  37098. * List of new root nodes (eg. nodes with no parent)
  37099. */
  37100. rootNodes: TransformNode[];
  37101. /**
  37102. * List of new skeletons
  37103. */
  37104. skeletons: Skeleton[];
  37105. /**
  37106. * List of new animation groups
  37107. */
  37108. animationGroups: AnimationGroup[];
  37109. }
  37110. /**
  37111. * Container with a set of assets that can be added or removed from a scene.
  37112. */
  37113. export class AssetContainer extends AbstractScene {
  37114. private _wasAddedToScene;
  37115. /**
  37116. * The scene the AssetContainer belongs to.
  37117. */
  37118. scene: Scene;
  37119. /**
  37120. * Instantiates an AssetContainer.
  37121. * @param scene The scene the AssetContainer belongs to.
  37122. */
  37123. constructor(scene: Scene);
  37124. /**
  37125. * Instantiate or clone all meshes and add the new ones to the scene.
  37126. * Skeletons and animation groups will all be cloned
  37127. * @param nameFunction defines an optional function used to get new names for clones
  37128. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37129. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37130. */
  37131. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37132. /**
  37133. * Adds all the assets from the container to the scene.
  37134. */
  37135. addAllToScene(): void;
  37136. /**
  37137. * Removes all the assets in the container from the scene
  37138. */
  37139. removeAllFromScene(): void;
  37140. /**
  37141. * Disposes all the assets in the container
  37142. */
  37143. dispose(): void;
  37144. private _moveAssets;
  37145. /**
  37146. * Removes all the assets contained in the scene and adds them to the container.
  37147. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37148. */
  37149. moveAllFromScene(keepAssets?: KeepAssets): void;
  37150. /**
  37151. * 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.
  37152. * @returns the root mesh
  37153. */
  37154. createRootMesh(): Mesh;
  37155. /**
  37156. * Merge animations from this asset container into a scene
  37157. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37158. * @param animatables set of animatables to retarget to a node from the scene
  37159. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37160. */
  37161. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37162. }
  37163. }
  37164. declare module BABYLON {
  37165. /**
  37166. * Defines how the parser contract is defined.
  37167. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37168. */
  37169. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37170. /**
  37171. * Defines how the individual parser contract is defined.
  37172. * These parser can parse an individual asset
  37173. */
  37174. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37175. /**
  37176. * Base class of the scene acting as a container for the different elements composing a scene.
  37177. * This class is dynamically extended by the different components of the scene increasing
  37178. * flexibility and reducing coupling
  37179. */
  37180. export abstract class AbstractScene {
  37181. /**
  37182. * Stores the list of available parsers in the application.
  37183. */
  37184. private static _BabylonFileParsers;
  37185. /**
  37186. * Stores the list of available individual parsers in the application.
  37187. */
  37188. private static _IndividualBabylonFileParsers;
  37189. /**
  37190. * Adds a parser in the list of available ones
  37191. * @param name Defines the name of the parser
  37192. * @param parser Defines the parser to add
  37193. */
  37194. static AddParser(name: string, parser: BabylonFileParser): void;
  37195. /**
  37196. * Gets a general parser from the list of avaialble ones
  37197. * @param name Defines the name of the parser
  37198. * @returns the requested parser or null
  37199. */
  37200. static GetParser(name: string): Nullable<BabylonFileParser>;
  37201. /**
  37202. * Adds n individual parser in the list of available ones
  37203. * @param name Defines the name of the parser
  37204. * @param parser Defines the parser to add
  37205. */
  37206. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37207. /**
  37208. * Gets an individual parser from the list of avaialble ones
  37209. * @param name Defines the name of the parser
  37210. * @returns the requested parser or null
  37211. */
  37212. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37213. /**
  37214. * Parser json data and populate both a scene and its associated container object
  37215. * @param jsonData Defines the data to parse
  37216. * @param scene Defines the scene to parse the data for
  37217. * @param container Defines the container attached to the parsing sequence
  37218. * @param rootUrl Defines the root url of the data
  37219. */
  37220. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37221. /**
  37222. * Gets the list of root nodes (ie. nodes with no parent)
  37223. */
  37224. rootNodes: Node[];
  37225. /** All of the cameras added to this scene
  37226. * @see http://doc.babylonjs.com/babylon101/cameras
  37227. */
  37228. cameras: Camera[];
  37229. /**
  37230. * All of the lights added to this scene
  37231. * @see http://doc.babylonjs.com/babylon101/lights
  37232. */
  37233. lights: Light[];
  37234. /**
  37235. * All of the (abstract) meshes added to this scene
  37236. */
  37237. meshes: AbstractMesh[];
  37238. /**
  37239. * The list of skeletons added to the scene
  37240. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37241. */
  37242. skeletons: Skeleton[];
  37243. /**
  37244. * All of the particle systems added to this scene
  37245. * @see http://doc.babylonjs.com/babylon101/particles
  37246. */
  37247. particleSystems: IParticleSystem[];
  37248. /**
  37249. * Gets a list of Animations associated with the scene
  37250. */
  37251. animations: Animation[];
  37252. /**
  37253. * All of the animation groups added to this scene
  37254. * @see http://doc.babylonjs.com/how_to/group
  37255. */
  37256. animationGroups: AnimationGroup[];
  37257. /**
  37258. * All of the multi-materials added to this scene
  37259. * @see http://doc.babylonjs.com/how_to/multi_materials
  37260. */
  37261. multiMaterials: MultiMaterial[];
  37262. /**
  37263. * All of the materials added to this scene
  37264. * In the context of a Scene, it is not supposed to be modified manually.
  37265. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37266. * Note also that the order of the Material within the array is not significant and might change.
  37267. * @see http://doc.babylonjs.com/babylon101/materials
  37268. */
  37269. materials: Material[];
  37270. /**
  37271. * The list of morph target managers added to the scene
  37272. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37273. */
  37274. morphTargetManagers: MorphTargetManager[];
  37275. /**
  37276. * The list of geometries used in the scene.
  37277. */
  37278. geometries: Geometry[];
  37279. /**
  37280. * All of the tranform nodes added to this scene
  37281. * In the context of a Scene, it is not supposed to be modified manually.
  37282. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37283. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37284. * @see http://doc.babylonjs.com/how_to/transformnode
  37285. */
  37286. transformNodes: TransformNode[];
  37287. /**
  37288. * ActionManagers available on the scene.
  37289. */
  37290. actionManagers: AbstractActionManager[];
  37291. /**
  37292. * Textures to keep.
  37293. */
  37294. textures: BaseTexture[];
  37295. /**
  37296. * Environment texture for the scene
  37297. */
  37298. environmentTexture: Nullable<BaseTexture>;
  37299. /**
  37300. * @returns all meshes, lights, cameras, transformNodes and bones
  37301. */
  37302. getNodes(): Array<Node>;
  37303. }
  37304. }
  37305. declare module BABYLON {
  37306. /**
  37307. * Interface used to define options for Sound class
  37308. */
  37309. export interface ISoundOptions {
  37310. /**
  37311. * Does the sound autoplay once loaded.
  37312. */
  37313. autoplay?: boolean;
  37314. /**
  37315. * Does the sound loop after it finishes playing once.
  37316. */
  37317. loop?: boolean;
  37318. /**
  37319. * Sound's volume
  37320. */
  37321. volume?: number;
  37322. /**
  37323. * Is it a spatial sound?
  37324. */
  37325. spatialSound?: boolean;
  37326. /**
  37327. * Maximum distance to hear that sound
  37328. */
  37329. maxDistance?: number;
  37330. /**
  37331. * Uses user defined attenuation function
  37332. */
  37333. useCustomAttenuation?: boolean;
  37334. /**
  37335. * Define the roll off factor of spatial sounds.
  37336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37337. */
  37338. rolloffFactor?: number;
  37339. /**
  37340. * Define the reference distance the sound should be heard perfectly.
  37341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37342. */
  37343. refDistance?: number;
  37344. /**
  37345. * Define the distance attenuation model the sound will follow.
  37346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37347. */
  37348. distanceModel?: string;
  37349. /**
  37350. * Defines the playback speed (1 by default)
  37351. */
  37352. playbackRate?: number;
  37353. /**
  37354. * Defines if the sound is from a streaming source
  37355. */
  37356. streaming?: boolean;
  37357. /**
  37358. * Defines an optional length (in seconds) inside the sound file
  37359. */
  37360. length?: number;
  37361. /**
  37362. * Defines an optional offset (in seconds) inside the sound file
  37363. */
  37364. offset?: number;
  37365. /**
  37366. * If true, URLs will not be required to state the audio file codec to use.
  37367. */
  37368. skipCodecCheck?: boolean;
  37369. }
  37370. /**
  37371. * Defines a sound that can be played in the application.
  37372. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37374. */
  37375. export class Sound {
  37376. /**
  37377. * The name of the sound in the scene.
  37378. */
  37379. name: string;
  37380. /**
  37381. * Does the sound autoplay once loaded.
  37382. */
  37383. autoplay: boolean;
  37384. /**
  37385. * Does the sound loop after it finishes playing once.
  37386. */
  37387. loop: boolean;
  37388. /**
  37389. * Does the sound use a custom attenuation curve to simulate the falloff
  37390. * happening when the source gets further away from the camera.
  37391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37392. */
  37393. useCustomAttenuation: boolean;
  37394. /**
  37395. * The sound track id this sound belongs to.
  37396. */
  37397. soundTrackId: number;
  37398. /**
  37399. * Is this sound currently played.
  37400. */
  37401. isPlaying: boolean;
  37402. /**
  37403. * Is this sound currently paused.
  37404. */
  37405. isPaused: boolean;
  37406. /**
  37407. * Does this sound enables spatial sound.
  37408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37409. */
  37410. spatialSound: boolean;
  37411. /**
  37412. * Define the reference distance the sound should be heard perfectly.
  37413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37414. */
  37415. refDistance: number;
  37416. /**
  37417. * Define the roll off factor of spatial sounds.
  37418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37419. */
  37420. rolloffFactor: number;
  37421. /**
  37422. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37424. */
  37425. maxDistance: number;
  37426. /**
  37427. * Define the distance attenuation model the sound will follow.
  37428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37429. */
  37430. distanceModel: string;
  37431. /**
  37432. * @hidden
  37433. * Back Compat
  37434. **/
  37435. onended: () => any;
  37436. /**
  37437. * Observable event when the current playing sound finishes.
  37438. */
  37439. onEndedObservable: Observable<Sound>;
  37440. private _panningModel;
  37441. private _playbackRate;
  37442. private _streaming;
  37443. private _startTime;
  37444. private _startOffset;
  37445. private _position;
  37446. /** @hidden */
  37447. _positionInEmitterSpace: boolean;
  37448. private _localDirection;
  37449. private _volume;
  37450. private _isReadyToPlay;
  37451. private _isDirectional;
  37452. private _readyToPlayCallback;
  37453. private _audioBuffer;
  37454. private _soundSource;
  37455. private _streamingSource;
  37456. private _soundPanner;
  37457. private _soundGain;
  37458. private _inputAudioNode;
  37459. private _outputAudioNode;
  37460. private _coneInnerAngle;
  37461. private _coneOuterAngle;
  37462. private _coneOuterGain;
  37463. private _scene;
  37464. private _connectedTransformNode;
  37465. private _customAttenuationFunction;
  37466. private _registerFunc;
  37467. private _isOutputConnected;
  37468. private _htmlAudioElement;
  37469. private _urlType;
  37470. private _length?;
  37471. private _offset?;
  37472. /** @hidden */
  37473. static _SceneComponentInitialization: (scene: Scene) => void;
  37474. /**
  37475. * Create a sound and attach it to a scene
  37476. * @param name Name of your sound
  37477. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37478. * @param scene defines the scene the sound belongs to
  37479. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37480. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37481. */
  37482. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37483. /**
  37484. * Release the sound and its associated resources
  37485. */
  37486. dispose(): void;
  37487. /**
  37488. * Gets if the sounds is ready to be played or not.
  37489. * @returns true if ready, otherwise false
  37490. */
  37491. isReady(): boolean;
  37492. private _soundLoaded;
  37493. /**
  37494. * Sets the data of the sound from an audiobuffer
  37495. * @param audioBuffer The audioBuffer containing the data
  37496. */
  37497. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37498. /**
  37499. * Updates the current sounds options such as maxdistance, loop...
  37500. * @param options A JSON object containing values named as the object properties
  37501. */
  37502. updateOptions(options: ISoundOptions): void;
  37503. private _createSpatialParameters;
  37504. private _updateSpatialParameters;
  37505. /**
  37506. * Switch the panning model to HRTF:
  37507. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37509. */
  37510. switchPanningModelToHRTF(): void;
  37511. /**
  37512. * Switch the panning model to Equal Power:
  37513. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37515. */
  37516. switchPanningModelToEqualPower(): void;
  37517. private _switchPanningModel;
  37518. /**
  37519. * Connect this sound to a sound track audio node like gain...
  37520. * @param soundTrackAudioNode the sound track audio node to connect to
  37521. */
  37522. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37523. /**
  37524. * Transform this sound into a directional source
  37525. * @param coneInnerAngle Size of the inner cone in degree
  37526. * @param coneOuterAngle Size of the outer cone in degree
  37527. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37528. */
  37529. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37530. /**
  37531. * Gets or sets the inner angle for the directional cone.
  37532. */
  37533. get directionalConeInnerAngle(): number;
  37534. /**
  37535. * Gets or sets the inner angle for the directional cone.
  37536. */
  37537. set directionalConeInnerAngle(value: number);
  37538. /**
  37539. * Gets or sets the outer angle for the directional cone.
  37540. */
  37541. get directionalConeOuterAngle(): number;
  37542. /**
  37543. * Gets or sets the outer angle for the directional cone.
  37544. */
  37545. set directionalConeOuterAngle(value: number);
  37546. /**
  37547. * Sets the position of the emitter if spatial sound is enabled
  37548. * @param newPosition Defines the new posisiton
  37549. */
  37550. setPosition(newPosition: Vector3): void;
  37551. /**
  37552. * Sets the local direction of the emitter if spatial sound is enabled
  37553. * @param newLocalDirection Defines the new local direction
  37554. */
  37555. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37556. private _updateDirection;
  37557. /** @hidden */
  37558. updateDistanceFromListener(): void;
  37559. /**
  37560. * Sets a new custom attenuation function for the sound.
  37561. * @param callback Defines the function used for the attenuation
  37562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37563. */
  37564. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37565. /**
  37566. * Play the sound
  37567. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37568. * @param offset (optional) Start the sound at a specific time in seconds
  37569. * @param length (optional) Sound duration (in seconds)
  37570. */
  37571. play(time?: number, offset?: number, length?: number): void;
  37572. private _onended;
  37573. /**
  37574. * Stop the sound
  37575. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37576. */
  37577. stop(time?: number): void;
  37578. /**
  37579. * Put the sound in pause
  37580. */
  37581. pause(): void;
  37582. /**
  37583. * Sets a dedicated volume for this sounds
  37584. * @param newVolume Define the new volume of the sound
  37585. * @param time Define time for gradual change to new volume
  37586. */
  37587. setVolume(newVolume: number, time?: number): void;
  37588. /**
  37589. * Set the sound play back rate
  37590. * @param newPlaybackRate Define the playback rate the sound should be played at
  37591. */
  37592. setPlaybackRate(newPlaybackRate: number): void;
  37593. /**
  37594. * Gets the volume of the sound.
  37595. * @returns the volume of the sound
  37596. */
  37597. getVolume(): number;
  37598. /**
  37599. * Attach the sound to a dedicated mesh
  37600. * @param transformNode The transform node to connect the sound with
  37601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37602. */
  37603. attachToMesh(transformNode: TransformNode): void;
  37604. /**
  37605. * Detach the sound from the previously attached mesh
  37606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37607. */
  37608. detachFromMesh(): void;
  37609. private _onRegisterAfterWorldMatrixUpdate;
  37610. /**
  37611. * Clone the current sound in the scene.
  37612. * @returns the new sound clone
  37613. */
  37614. clone(): Nullable<Sound>;
  37615. /**
  37616. * Gets the current underlying audio buffer containing the data
  37617. * @returns the audio buffer
  37618. */
  37619. getAudioBuffer(): Nullable<AudioBuffer>;
  37620. /**
  37621. * Serializes the Sound in a JSON representation
  37622. * @returns the JSON representation of the sound
  37623. */
  37624. serialize(): any;
  37625. /**
  37626. * Parse a JSON representation of a sound to innstantiate in a given scene
  37627. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37628. * @param scene Define the scene the new parsed sound should be created in
  37629. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37630. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37631. * @returns the newly parsed sound
  37632. */
  37633. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37634. }
  37635. }
  37636. declare module BABYLON {
  37637. /**
  37638. * This defines an action helpful to play a defined sound on a triggered action.
  37639. */
  37640. export class PlaySoundAction extends Action {
  37641. private _sound;
  37642. /**
  37643. * Instantiate the action
  37644. * @param triggerOptions defines the trigger options
  37645. * @param sound defines the sound to play
  37646. * @param condition defines the trigger related conditions
  37647. */
  37648. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37649. /** @hidden */
  37650. _prepare(): void;
  37651. /**
  37652. * Execute the action and play the sound.
  37653. */
  37654. execute(): void;
  37655. /**
  37656. * Serializes the actions and its related information.
  37657. * @param parent defines the object to serialize in
  37658. * @returns the serialized object
  37659. */
  37660. serialize(parent: any): any;
  37661. }
  37662. /**
  37663. * This defines an action helpful to stop a defined sound on a triggered action.
  37664. */
  37665. export class StopSoundAction extends Action {
  37666. private _sound;
  37667. /**
  37668. * Instantiate the action
  37669. * @param triggerOptions defines the trigger options
  37670. * @param sound defines the sound to stop
  37671. * @param condition defines the trigger related conditions
  37672. */
  37673. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37674. /** @hidden */
  37675. _prepare(): void;
  37676. /**
  37677. * Execute the action and stop the sound.
  37678. */
  37679. execute(): void;
  37680. /**
  37681. * Serializes the actions and its related information.
  37682. * @param parent defines the object to serialize in
  37683. * @returns the serialized object
  37684. */
  37685. serialize(parent: any): any;
  37686. }
  37687. }
  37688. declare module BABYLON {
  37689. /**
  37690. * This defines an action responsible to change the value of a property
  37691. * by interpolating between its current value and the newly set one once triggered.
  37692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37693. */
  37694. export class InterpolateValueAction extends Action {
  37695. /**
  37696. * Defines the path of the property where the value should be interpolated
  37697. */
  37698. propertyPath: string;
  37699. /**
  37700. * Defines the target value at the end of the interpolation.
  37701. */
  37702. value: any;
  37703. /**
  37704. * Defines the time it will take for the property to interpolate to the value.
  37705. */
  37706. duration: number;
  37707. /**
  37708. * Defines if the other scene animations should be stopped when the action has been triggered
  37709. */
  37710. stopOtherAnimations?: boolean;
  37711. /**
  37712. * Defines a callback raised once the interpolation animation has been done.
  37713. */
  37714. onInterpolationDone?: () => void;
  37715. /**
  37716. * Observable triggered once the interpolation animation has been done.
  37717. */
  37718. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37719. private _target;
  37720. private _effectiveTarget;
  37721. private _property;
  37722. /**
  37723. * Instantiate the action
  37724. * @param triggerOptions defines the trigger options
  37725. * @param target defines the object containing the value to interpolate
  37726. * @param propertyPath defines the path to the property in the target object
  37727. * @param value defines the target value at the end of the interpolation
  37728. * @param duration deines the time it will take for the property to interpolate to the value.
  37729. * @param condition defines the trigger related conditions
  37730. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37731. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37732. */
  37733. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37734. /** @hidden */
  37735. _prepare(): void;
  37736. /**
  37737. * Execute the action starts the value interpolation.
  37738. */
  37739. execute(): void;
  37740. /**
  37741. * Serializes the actions and its related information.
  37742. * @param parent defines the object to serialize in
  37743. * @returns the serialized object
  37744. */
  37745. serialize(parent: any): any;
  37746. }
  37747. }
  37748. declare module BABYLON {
  37749. /**
  37750. * Options allowed during the creation of a sound track.
  37751. */
  37752. export interface ISoundTrackOptions {
  37753. /**
  37754. * The volume the sound track should take during creation
  37755. */
  37756. volume?: number;
  37757. /**
  37758. * Define if the sound track is the main sound track of the scene
  37759. */
  37760. mainTrack?: boolean;
  37761. }
  37762. /**
  37763. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37764. * It will be also used in a future release to apply effects on a specific track.
  37765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37766. */
  37767. export class SoundTrack {
  37768. /**
  37769. * The unique identifier of the sound track in the scene.
  37770. */
  37771. id: number;
  37772. /**
  37773. * The list of sounds included in the sound track.
  37774. */
  37775. soundCollection: Array<Sound>;
  37776. private _outputAudioNode;
  37777. private _scene;
  37778. private _connectedAnalyser;
  37779. private _options;
  37780. private _isInitialized;
  37781. /**
  37782. * Creates a new sound track.
  37783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37784. * @param scene Define the scene the sound track belongs to
  37785. * @param options
  37786. */
  37787. constructor(scene: Scene, options?: ISoundTrackOptions);
  37788. private _initializeSoundTrackAudioGraph;
  37789. /**
  37790. * Release the sound track and its associated resources
  37791. */
  37792. dispose(): void;
  37793. /**
  37794. * Adds a sound to this sound track
  37795. * @param sound define the cound to add
  37796. * @ignoreNaming
  37797. */
  37798. AddSound(sound: Sound): void;
  37799. /**
  37800. * Removes a sound to this sound track
  37801. * @param sound define the cound to remove
  37802. * @ignoreNaming
  37803. */
  37804. RemoveSound(sound: Sound): void;
  37805. /**
  37806. * Set a global volume for the full sound track.
  37807. * @param newVolume Define the new volume of the sound track
  37808. */
  37809. setVolume(newVolume: number): void;
  37810. /**
  37811. * Switch the panning model to HRTF:
  37812. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37814. */
  37815. switchPanningModelToHRTF(): void;
  37816. /**
  37817. * Switch the panning model to Equal Power:
  37818. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37820. */
  37821. switchPanningModelToEqualPower(): void;
  37822. /**
  37823. * Connect the sound track to an audio analyser allowing some amazing
  37824. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37826. * @param analyser The analyser to connect to the engine
  37827. */
  37828. connectToAnalyser(analyser: Analyser): void;
  37829. }
  37830. }
  37831. declare module BABYLON {
  37832. interface AbstractScene {
  37833. /**
  37834. * The list of sounds used in the scene.
  37835. */
  37836. sounds: Nullable<Array<Sound>>;
  37837. }
  37838. interface Scene {
  37839. /**
  37840. * @hidden
  37841. * Backing field
  37842. */
  37843. _mainSoundTrack: SoundTrack;
  37844. /**
  37845. * The main sound track played by the scene.
  37846. * It cotains your primary collection of sounds.
  37847. */
  37848. mainSoundTrack: SoundTrack;
  37849. /**
  37850. * The list of sound tracks added to the scene
  37851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37852. */
  37853. soundTracks: Nullable<Array<SoundTrack>>;
  37854. /**
  37855. * Gets a sound using a given name
  37856. * @param name defines the name to search for
  37857. * @return the found sound or null if not found at all.
  37858. */
  37859. getSoundByName(name: string): Nullable<Sound>;
  37860. /**
  37861. * Gets or sets if audio support is enabled
  37862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37863. */
  37864. audioEnabled: boolean;
  37865. /**
  37866. * Gets or sets if audio will be output to headphones
  37867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37868. */
  37869. headphone: boolean;
  37870. /**
  37871. * Gets or sets custom audio listener position provider
  37872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37873. */
  37874. audioListenerPositionProvider: Nullable<() => Vector3>;
  37875. /**
  37876. * Gets or sets a refresh rate when using 3D audio positioning
  37877. */
  37878. audioPositioningRefreshRate: number;
  37879. }
  37880. /**
  37881. * Defines the sound scene component responsible to manage any sounds
  37882. * in a given scene.
  37883. */
  37884. export class AudioSceneComponent implements ISceneSerializableComponent {
  37885. /**
  37886. * The component name helpfull to identify the component in the list of scene components.
  37887. */
  37888. readonly name: string;
  37889. /**
  37890. * The scene the component belongs to.
  37891. */
  37892. scene: Scene;
  37893. private _audioEnabled;
  37894. /**
  37895. * Gets whether audio is enabled or not.
  37896. * Please use related enable/disable method to switch state.
  37897. */
  37898. get audioEnabled(): boolean;
  37899. private _headphone;
  37900. /**
  37901. * Gets whether audio is outputing to headphone or not.
  37902. * Please use the according Switch methods to change output.
  37903. */
  37904. get headphone(): boolean;
  37905. /**
  37906. * Gets or sets a refresh rate when using 3D audio positioning
  37907. */
  37908. audioPositioningRefreshRate: number;
  37909. private _audioListenerPositionProvider;
  37910. /**
  37911. * Gets the current audio listener position provider
  37912. */
  37913. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37914. /**
  37915. * Sets a custom listener position for all sounds in the scene
  37916. * By default, this is the position of the first active camera
  37917. */
  37918. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37919. /**
  37920. * Creates a new instance of the component for the given scene
  37921. * @param scene Defines the scene to register the component in
  37922. */
  37923. constructor(scene: Scene);
  37924. /**
  37925. * Registers the component in a given scene
  37926. */
  37927. register(): void;
  37928. /**
  37929. * Rebuilds the elements related to this component in case of
  37930. * context lost for instance.
  37931. */
  37932. rebuild(): void;
  37933. /**
  37934. * Serializes the component data to the specified json object
  37935. * @param serializationObject The object to serialize to
  37936. */
  37937. serialize(serializationObject: any): void;
  37938. /**
  37939. * Adds all the elements from the container to the scene
  37940. * @param container the container holding the elements
  37941. */
  37942. addFromContainer(container: AbstractScene): void;
  37943. /**
  37944. * Removes all the elements in the container from the scene
  37945. * @param container contains the elements to remove
  37946. * @param dispose if the removed element should be disposed (default: false)
  37947. */
  37948. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37949. /**
  37950. * Disposes the component and the associated ressources.
  37951. */
  37952. dispose(): void;
  37953. /**
  37954. * Disables audio in the associated scene.
  37955. */
  37956. disableAudio(): void;
  37957. /**
  37958. * Enables audio in the associated scene.
  37959. */
  37960. enableAudio(): void;
  37961. /**
  37962. * Switch audio to headphone output.
  37963. */
  37964. switchAudioModeForHeadphones(): void;
  37965. /**
  37966. * Switch audio to normal speakers.
  37967. */
  37968. switchAudioModeForNormalSpeakers(): void;
  37969. private _cachedCameraDirection;
  37970. private _cachedCameraPosition;
  37971. private _lastCheck;
  37972. private _afterRender;
  37973. }
  37974. }
  37975. declare module BABYLON {
  37976. /**
  37977. * Wraps one or more Sound objects and selects one with random weight for playback.
  37978. */
  37979. export class WeightedSound {
  37980. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37981. loop: boolean;
  37982. private _coneInnerAngle;
  37983. private _coneOuterAngle;
  37984. private _volume;
  37985. /** A Sound is currently playing. */
  37986. isPlaying: boolean;
  37987. /** A Sound is currently paused. */
  37988. isPaused: boolean;
  37989. private _sounds;
  37990. private _weights;
  37991. private _currentIndex?;
  37992. /**
  37993. * Creates a new WeightedSound from the list of sounds given.
  37994. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37995. * @param sounds Array of Sounds that will be selected from.
  37996. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37997. */
  37998. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37999. /**
  38000. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38001. */
  38002. get directionalConeInnerAngle(): number;
  38003. /**
  38004. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38005. */
  38006. set directionalConeInnerAngle(value: number);
  38007. /**
  38008. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38009. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38010. */
  38011. get directionalConeOuterAngle(): number;
  38012. /**
  38013. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38014. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38015. */
  38016. set directionalConeOuterAngle(value: number);
  38017. /**
  38018. * Playback volume.
  38019. */
  38020. get volume(): number;
  38021. /**
  38022. * Playback volume.
  38023. */
  38024. set volume(value: number);
  38025. private _onended;
  38026. /**
  38027. * Suspend playback
  38028. */
  38029. pause(): void;
  38030. /**
  38031. * Stop playback
  38032. */
  38033. stop(): void;
  38034. /**
  38035. * Start playback.
  38036. * @param startOffset Position the clip head at a specific time in seconds.
  38037. */
  38038. play(startOffset?: number): void;
  38039. }
  38040. }
  38041. declare module BABYLON {
  38042. /**
  38043. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38044. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38045. */
  38046. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38047. /**
  38048. * Gets the name of the behavior.
  38049. */
  38050. get name(): string;
  38051. /**
  38052. * The easing function used by animations
  38053. */
  38054. static EasingFunction: BackEase;
  38055. /**
  38056. * The easing mode used by animations
  38057. */
  38058. static EasingMode: number;
  38059. /**
  38060. * The duration of the animation, in milliseconds
  38061. */
  38062. transitionDuration: number;
  38063. /**
  38064. * Length of the distance animated by the transition when lower radius is reached
  38065. */
  38066. lowerRadiusTransitionRange: number;
  38067. /**
  38068. * Length of the distance animated by the transition when upper radius is reached
  38069. */
  38070. upperRadiusTransitionRange: number;
  38071. private _autoTransitionRange;
  38072. /**
  38073. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38074. */
  38075. get autoTransitionRange(): boolean;
  38076. /**
  38077. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38078. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38079. */
  38080. set autoTransitionRange(value: boolean);
  38081. private _attachedCamera;
  38082. private _onAfterCheckInputsObserver;
  38083. private _onMeshTargetChangedObserver;
  38084. /**
  38085. * Initializes the behavior.
  38086. */
  38087. init(): void;
  38088. /**
  38089. * Attaches the behavior to its arc rotate camera.
  38090. * @param camera Defines the camera to attach the behavior to
  38091. */
  38092. attach(camera: ArcRotateCamera): void;
  38093. /**
  38094. * Detaches the behavior from its current arc rotate camera.
  38095. */
  38096. detach(): void;
  38097. private _radiusIsAnimating;
  38098. private _radiusBounceTransition;
  38099. private _animatables;
  38100. private _cachedWheelPrecision;
  38101. /**
  38102. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38103. * @param radiusLimit The limit to check against.
  38104. * @return Bool to indicate if at limit.
  38105. */
  38106. private _isRadiusAtLimit;
  38107. /**
  38108. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38109. * @param radiusDelta The delta by which to animate to. Can be negative.
  38110. */
  38111. private _applyBoundRadiusAnimation;
  38112. /**
  38113. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38114. */
  38115. protected _clearAnimationLocks(): void;
  38116. /**
  38117. * Stops and removes all animations that have been applied to the camera
  38118. */
  38119. stopAllAnimations(): void;
  38120. }
  38121. }
  38122. declare module BABYLON {
  38123. /**
  38124. * 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.
  38125. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38126. */
  38127. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38128. /**
  38129. * Gets the name of the behavior.
  38130. */
  38131. get name(): string;
  38132. private _mode;
  38133. private _radiusScale;
  38134. private _positionScale;
  38135. private _defaultElevation;
  38136. private _elevationReturnTime;
  38137. private _elevationReturnWaitTime;
  38138. private _zoomStopsAnimation;
  38139. private _framingTime;
  38140. /**
  38141. * The easing function used by animations
  38142. */
  38143. static EasingFunction: ExponentialEase;
  38144. /**
  38145. * The easing mode used by animations
  38146. */
  38147. static EasingMode: number;
  38148. /**
  38149. * Sets the current mode used by the behavior
  38150. */
  38151. set mode(mode: number);
  38152. /**
  38153. * Gets current mode used by the behavior.
  38154. */
  38155. get mode(): number;
  38156. /**
  38157. * Sets the scale applied to the radius (1 by default)
  38158. */
  38159. set radiusScale(radius: number);
  38160. /**
  38161. * Gets the scale applied to the radius
  38162. */
  38163. get radiusScale(): number;
  38164. /**
  38165. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38166. */
  38167. set positionScale(scale: number);
  38168. /**
  38169. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38170. */
  38171. get positionScale(): number;
  38172. /**
  38173. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38174. * behaviour is triggered, in radians.
  38175. */
  38176. set defaultElevation(elevation: number);
  38177. /**
  38178. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38179. * behaviour is triggered, in radians.
  38180. */
  38181. get defaultElevation(): number;
  38182. /**
  38183. * Sets the time (in milliseconds) taken to return to the default beta position.
  38184. * Negative value indicates camera should not return to default.
  38185. */
  38186. set elevationReturnTime(speed: number);
  38187. /**
  38188. * Gets the time (in milliseconds) taken to return to the default beta position.
  38189. * Negative value indicates camera should not return to default.
  38190. */
  38191. get elevationReturnTime(): number;
  38192. /**
  38193. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38194. */
  38195. set elevationReturnWaitTime(time: number);
  38196. /**
  38197. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38198. */
  38199. get elevationReturnWaitTime(): number;
  38200. /**
  38201. * Sets the flag that indicates if user zooming should stop animation.
  38202. */
  38203. set zoomStopsAnimation(flag: boolean);
  38204. /**
  38205. * Gets the flag that indicates if user zooming should stop animation.
  38206. */
  38207. get zoomStopsAnimation(): boolean;
  38208. /**
  38209. * Sets the transition time when framing the mesh, in milliseconds
  38210. */
  38211. set framingTime(time: number);
  38212. /**
  38213. * Gets the transition time when framing the mesh, in milliseconds
  38214. */
  38215. get framingTime(): number;
  38216. /**
  38217. * Define if the behavior should automatically change the configured
  38218. * camera limits and sensibilities.
  38219. */
  38220. autoCorrectCameraLimitsAndSensibility: boolean;
  38221. private _onPrePointerObservableObserver;
  38222. private _onAfterCheckInputsObserver;
  38223. private _onMeshTargetChangedObserver;
  38224. private _attachedCamera;
  38225. private _isPointerDown;
  38226. private _lastInteractionTime;
  38227. /**
  38228. * Initializes the behavior.
  38229. */
  38230. init(): void;
  38231. /**
  38232. * Attaches the behavior to its arc rotate camera.
  38233. * @param camera Defines the camera to attach the behavior to
  38234. */
  38235. attach(camera: ArcRotateCamera): void;
  38236. /**
  38237. * Detaches the behavior from its current arc rotate camera.
  38238. */
  38239. detach(): void;
  38240. private _animatables;
  38241. private _betaIsAnimating;
  38242. private _betaTransition;
  38243. private _radiusTransition;
  38244. private _vectorTransition;
  38245. /**
  38246. * Targets the given mesh and updates zoom level accordingly.
  38247. * @param mesh The mesh to target.
  38248. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38249. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38250. */
  38251. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38252. /**
  38253. * Targets the given mesh with its children and updates zoom level accordingly.
  38254. * @param mesh The mesh to target.
  38255. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38256. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38257. */
  38258. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38259. /**
  38260. * Targets the given meshes with their children and updates zoom level accordingly.
  38261. * @param meshes The mesh to target.
  38262. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38263. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38264. */
  38265. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38266. /**
  38267. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38268. * @param minimumWorld Determines the smaller position of the bounding box extend
  38269. * @param maximumWorld Determines the bigger position of the bounding box extend
  38270. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38271. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38272. */
  38273. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38274. /**
  38275. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38276. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38277. * frustum width.
  38278. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38279. * to fully enclose the mesh in the viewing frustum.
  38280. */
  38281. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38282. /**
  38283. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38284. * is automatically returned to its default position (expected to be above ground plane).
  38285. */
  38286. private _maintainCameraAboveGround;
  38287. /**
  38288. * Returns the frustum slope based on the canvas ratio and camera FOV
  38289. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38290. */
  38291. private _getFrustumSlope;
  38292. /**
  38293. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38294. */
  38295. private _clearAnimationLocks;
  38296. /**
  38297. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38298. */
  38299. private _applyUserInteraction;
  38300. /**
  38301. * Stops and removes all animations that have been applied to the camera
  38302. */
  38303. stopAllAnimations(): void;
  38304. /**
  38305. * Gets a value indicating if the user is moving the camera
  38306. */
  38307. get isUserIsMoving(): boolean;
  38308. /**
  38309. * The camera can move all the way towards the mesh.
  38310. */
  38311. static IgnoreBoundsSizeMode: number;
  38312. /**
  38313. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38314. */
  38315. static FitFrustumSidesMode: number;
  38316. }
  38317. }
  38318. declare module BABYLON {
  38319. /**
  38320. * Base class for Camera Pointer Inputs.
  38321. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38322. * for example usage.
  38323. */
  38324. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38325. /**
  38326. * Defines the camera the input is attached to.
  38327. */
  38328. abstract camera: Camera;
  38329. /**
  38330. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38331. */
  38332. protected _altKey: boolean;
  38333. protected _ctrlKey: boolean;
  38334. protected _metaKey: boolean;
  38335. protected _shiftKey: boolean;
  38336. /**
  38337. * Which mouse buttons were pressed at time of last mouse event.
  38338. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38339. */
  38340. protected _buttonsPressed: number;
  38341. /**
  38342. * Defines the buttons associated with the input to handle camera move.
  38343. */
  38344. buttons: number[];
  38345. /**
  38346. * Attach the input controls to a specific dom element to get the input from.
  38347. * @param element Defines the element the controls should be listened from
  38348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38349. */
  38350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38351. /**
  38352. * Detach the current controls from the specified dom element.
  38353. * @param element Defines the element to stop listening the inputs from
  38354. */
  38355. detachControl(element: Nullable<HTMLElement>): void;
  38356. /**
  38357. * Gets the class name of the current input.
  38358. * @returns the class name
  38359. */
  38360. getClassName(): string;
  38361. /**
  38362. * Get the friendly name associated with the input class.
  38363. * @returns the input friendly name
  38364. */
  38365. getSimpleName(): string;
  38366. /**
  38367. * Called on pointer POINTERDOUBLETAP event.
  38368. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38369. */
  38370. protected onDoubleTap(type: string): void;
  38371. /**
  38372. * Called on pointer POINTERMOVE event if only a single touch is active.
  38373. * Override this method to provide functionality.
  38374. */
  38375. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38376. /**
  38377. * Called on pointer POINTERMOVE event if multiple touches are active.
  38378. * Override this method to provide functionality.
  38379. */
  38380. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38381. /**
  38382. * Called on JS contextmenu event.
  38383. * Override this method to provide functionality.
  38384. */
  38385. protected onContextMenu(evt: PointerEvent): void;
  38386. /**
  38387. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38388. * press.
  38389. * Override this method to provide functionality.
  38390. */
  38391. protected onButtonDown(evt: PointerEvent): void;
  38392. /**
  38393. * Called each time a new POINTERUP event occurs. Ie, for each button
  38394. * release.
  38395. * Override this method to provide functionality.
  38396. */
  38397. protected onButtonUp(evt: PointerEvent): void;
  38398. /**
  38399. * Called when window becomes inactive.
  38400. * Override this method to provide functionality.
  38401. */
  38402. protected onLostFocus(): void;
  38403. private _pointerInput;
  38404. private _observer;
  38405. private _onLostFocus;
  38406. private pointA;
  38407. private pointB;
  38408. }
  38409. }
  38410. declare module BABYLON {
  38411. /**
  38412. * Manage the pointers inputs to control an arc rotate camera.
  38413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38414. */
  38415. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38416. /**
  38417. * Defines the camera the input is attached to.
  38418. */
  38419. camera: ArcRotateCamera;
  38420. /**
  38421. * Gets the class name of the current input.
  38422. * @returns the class name
  38423. */
  38424. getClassName(): string;
  38425. /**
  38426. * Defines the buttons associated with the input to handle camera move.
  38427. */
  38428. buttons: number[];
  38429. /**
  38430. * Defines the pointer angular sensibility along the X axis or how fast is
  38431. * the camera rotating.
  38432. */
  38433. angularSensibilityX: number;
  38434. /**
  38435. * Defines the pointer angular sensibility along the Y axis or how fast is
  38436. * the camera rotating.
  38437. */
  38438. angularSensibilityY: number;
  38439. /**
  38440. * Defines the pointer pinch precision or how fast is the camera zooming.
  38441. */
  38442. pinchPrecision: number;
  38443. /**
  38444. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38445. * from 0.
  38446. * It defines the percentage of current camera.radius to use as delta when
  38447. * pinch zoom is used.
  38448. */
  38449. pinchDeltaPercentage: number;
  38450. /**
  38451. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38452. * that any object in the plane at the camera's target point will scale
  38453. * perfectly with finger motion.
  38454. * Overrides pinchDeltaPercentage and pinchPrecision.
  38455. */
  38456. useNaturalPinchZoom: boolean;
  38457. /**
  38458. * Defines the pointer panning sensibility or how fast is the camera moving.
  38459. */
  38460. panningSensibility: number;
  38461. /**
  38462. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38463. */
  38464. multiTouchPanning: boolean;
  38465. /**
  38466. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38467. * zoom (pinch) through multitouch.
  38468. */
  38469. multiTouchPanAndZoom: boolean;
  38470. /**
  38471. * Revers pinch action direction.
  38472. */
  38473. pinchInwards: boolean;
  38474. private _isPanClick;
  38475. private _twoFingerActivityCount;
  38476. private _isPinching;
  38477. /**
  38478. * Called on pointer POINTERMOVE event if only a single touch is active.
  38479. */
  38480. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38481. /**
  38482. * Called on pointer POINTERDOUBLETAP event.
  38483. */
  38484. protected onDoubleTap(type: string): void;
  38485. /**
  38486. * Called on pointer POINTERMOVE event if multiple touches are active.
  38487. */
  38488. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38489. /**
  38490. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38491. * press.
  38492. */
  38493. protected onButtonDown(evt: PointerEvent): void;
  38494. /**
  38495. * Called each time a new POINTERUP event occurs. Ie, for each button
  38496. * release.
  38497. */
  38498. protected onButtonUp(evt: PointerEvent): void;
  38499. /**
  38500. * Called when window becomes inactive.
  38501. */
  38502. protected onLostFocus(): void;
  38503. }
  38504. }
  38505. declare module BABYLON {
  38506. /**
  38507. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38509. */
  38510. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38511. /**
  38512. * Defines the camera the input is attached to.
  38513. */
  38514. camera: ArcRotateCamera;
  38515. /**
  38516. * Defines the list of key codes associated with the up action (increase alpha)
  38517. */
  38518. keysUp: number[];
  38519. /**
  38520. * Defines the list of key codes associated with the down action (decrease alpha)
  38521. */
  38522. keysDown: number[];
  38523. /**
  38524. * Defines the list of key codes associated with the left action (increase beta)
  38525. */
  38526. keysLeft: number[];
  38527. /**
  38528. * Defines the list of key codes associated with the right action (decrease beta)
  38529. */
  38530. keysRight: number[];
  38531. /**
  38532. * Defines the list of key codes associated with the reset action.
  38533. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38534. */
  38535. keysReset: number[];
  38536. /**
  38537. * Defines the panning sensibility of the inputs.
  38538. * (How fast is the camera panning)
  38539. */
  38540. panningSensibility: number;
  38541. /**
  38542. * Defines the zooming sensibility of the inputs.
  38543. * (How fast is the camera zooming)
  38544. */
  38545. zoomingSensibility: number;
  38546. /**
  38547. * Defines whether maintaining the alt key down switch the movement mode from
  38548. * orientation to zoom.
  38549. */
  38550. useAltToZoom: boolean;
  38551. /**
  38552. * Rotation speed of the camera
  38553. */
  38554. angularSpeed: number;
  38555. private _keys;
  38556. private _ctrlPressed;
  38557. private _altPressed;
  38558. private _onCanvasBlurObserver;
  38559. private _onKeyboardObserver;
  38560. private _engine;
  38561. private _scene;
  38562. /**
  38563. * Attach the input controls to a specific dom element to get the input from.
  38564. * @param element Defines the element the controls should be listened from
  38565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38566. */
  38567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38568. /**
  38569. * Detach the current controls from the specified dom element.
  38570. * @param element Defines the element to stop listening the inputs from
  38571. */
  38572. detachControl(element: Nullable<HTMLElement>): void;
  38573. /**
  38574. * Update the current camera state depending on the inputs that have been used this frame.
  38575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38576. */
  38577. checkInputs(): void;
  38578. /**
  38579. * Gets the class name of the current intput.
  38580. * @returns the class name
  38581. */
  38582. getClassName(): string;
  38583. /**
  38584. * Get the friendly name associated with the input class.
  38585. * @returns the input friendly name
  38586. */
  38587. getSimpleName(): string;
  38588. }
  38589. }
  38590. declare module BABYLON {
  38591. /**
  38592. * Manage the mouse wheel inputs to control an arc rotate camera.
  38593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38594. */
  38595. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38596. /**
  38597. * Defines the camera the input is attached to.
  38598. */
  38599. camera: ArcRotateCamera;
  38600. /**
  38601. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38602. */
  38603. wheelPrecision: number;
  38604. /**
  38605. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38606. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38607. */
  38608. wheelDeltaPercentage: number;
  38609. private _wheel;
  38610. private _observer;
  38611. private computeDeltaFromMouseWheelLegacyEvent;
  38612. /**
  38613. * Attach the input controls to a specific dom element to get the input from.
  38614. * @param element Defines the element the controls should be listened from
  38615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38616. */
  38617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38618. /**
  38619. * Detach the current controls from the specified dom element.
  38620. * @param element Defines the element to stop listening the inputs from
  38621. */
  38622. detachControl(element: Nullable<HTMLElement>): void;
  38623. /**
  38624. * Gets the class name of the current intput.
  38625. * @returns the class name
  38626. */
  38627. getClassName(): string;
  38628. /**
  38629. * Get the friendly name associated with the input class.
  38630. * @returns the input friendly name
  38631. */
  38632. getSimpleName(): string;
  38633. }
  38634. }
  38635. declare module BABYLON {
  38636. /**
  38637. * Default Inputs manager for the ArcRotateCamera.
  38638. * It groups all the default supported inputs for ease of use.
  38639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38640. */
  38641. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38642. /**
  38643. * Instantiates a new ArcRotateCameraInputsManager.
  38644. * @param camera Defines the camera the inputs belong to
  38645. */
  38646. constructor(camera: ArcRotateCamera);
  38647. /**
  38648. * Add mouse wheel input support to the input manager.
  38649. * @returns the current input manager
  38650. */
  38651. addMouseWheel(): ArcRotateCameraInputsManager;
  38652. /**
  38653. * Add pointers input support to the input manager.
  38654. * @returns the current input manager
  38655. */
  38656. addPointers(): ArcRotateCameraInputsManager;
  38657. /**
  38658. * Add keyboard input support to the input manager.
  38659. * @returns the current input manager
  38660. */
  38661. addKeyboard(): ArcRotateCameraInputsManager;
  38662. }
  38663. }
  38664. declare module BABYLON {
  38665. /**
  38666. * This represents an orbital type of camera.
  38667. *
  38668. * 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.
  38669. * 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.
  38670. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38671. */
  38672. export class ArcRotateCamera extends TargetCamera {
  38673. /**
  38674. * Defines the rotation angle of the camera along the longitudinal axis.
  38675. */
  38676. alpha: number;
  38677. /**
  38678. * Defines the rotation angle of the camera along the latitudinal axis.
  38679. */
  38680. beta: number;
  38681. /**
  38682. * Defines the radius of the camera from it s target point.
  38683. */
  38684. radius: number;
  38685. protected _target: Vector3;
  38686. protected _targetHost: Nullable<AbstractMesh>;
  38687. /**
  38688. * Defines the target point of the camera.
  38689. * The camera looks towards it form the radius distance.
  38690. */
  38691. get target(): Vector3;
  38692. set target(value: Vector3);
  38693. /**
  38694. * Define the current local position of the camera in the scene
  38695. */
  38696. get position(): Vector3;
  38697. set position(newPosition: Vector3);
  38698. protected _upVector: Vector3;
  38699. protected _upToYMatrix: Matrix;
  38700. protected _YToUpMatrix: Matrix;
  38701. /**
  38702. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38703. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38704. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38705. */
  38706. set upVector(vec: Vector3);
  38707. get upVector(): Vector3;
  38708. /**
  38709. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38710. */
  38711. setMatUp(): void;
  38712. /**
  38713. * Current inertia value on the longitudinal axis.
  38714. * The bigger this number the longer it will take for the camera to stop.
  38715. */
  38716. inertialAlphaOffset: number;
  38717. /**
  38718. * Current inertia value on the latitudinal axis.
  38719. * The bigger this number the longer it will take for the camera to stop.
  38720. */
  38721. inertialBetaOffset: number;
  38722. /**
  38723. * Current inertia value on the radius axis.
  38724. * The bigger this number the longer it will take for the camera to stop.
  38725. */
  38726. inertialRadiusOffset: number;
  38727. /**
  38728. * Minimum allowed angle on the longitudinal axis.
  38729. * This can help limiting how the Camera is able to move in the scene.
  38730. */
  38731. lowerAlphaLimit: Nullable<number>;
  38732. /**
  38733. * Maximum allowed angle on the longitudinal axis.
  38734. * This can help limiting how the Camera is able to move in the scene.
  38735. */
  38736. upperAlphaLimit: Nullable<number>;
  38737. /**
  38738. * Minimum allowed angle on the latitudinal axis.
  38739. * This can help limiting how the Camera is able to move in the scene.
  38740. */
  38741. lowerBetaLimit: number;
  38742. /**
  38743. * Maximum allowed angle on the latitudinal axis.
  38744. * This can help limiting how the Camera is able to move in the scene.
  38745. */
  38746. upperBetaLimit: number;
  38747. /**
  38748. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38749. * This can help limiting how the Camera is able to move in the scene.
  38750. */
  38751. lowerRadiusLimit: Nullable<number>;
  38752. /**
  38753. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38754. * This can help limiting how the Camera is able to move in the scene.
  38755. */
  38756. upperRadiusLimit: Nullable<number>;
  38757. /**
  38758. * Defines the current inertia value used during panning of the camera along the X axis.
  38759. */
  38760. inertialPanningX: number;
  38761. /**
  38762. * Defines the current inertia value used during panning of the camera along the Y axis.
  38763. */
  38764. inertialPanningY: number;
  38765. /**
  38766. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38767. * Basically if your fingers moves away from more than this distance you will be considered
  38768. * in pinch mode.
  38769. */
  38770. pinchToPanMaxDistance: number;
  38771. /**
  38772. * Defines the maximum distance the camera can pan.
  38773. * This could help keeping the cammera always in your scene.
  38774. */
  38775. panningDistanceLimit: Nullable<number>;
  38776. /**
  38777. * Defines the target of the camera before paning.
  38778. */
  38779. panningOriginTarget: Vector3;
  38780. /**
  38781. * Defines the value of the inertia used during panning.
  38782. * 0 would mean stop inertia and one would mean no decelleration at all.
  38783. */
  38784. panningInertia: number;
  38785. /**
  38786. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38787. */
  38788. get angularSensibilityX(): number;
  38789. set angularSensibilityX(value: number);
  38790. /**
  38791. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38792. */
  38793. get angularSensibilityY(): number;
  38794. set angularSensibilityY(value: number);
  38795. /**
  38796. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38797. */
  38798. get pinchPrecision(): number;
  38799. set pinchPrecision(value: number);
  38800. /**
  38801. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38802. * It will be used instead of pinchDeltaPrecision if different from 0.
  38803. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38804. */
  38805. get pinchDeltaPercentage(): number;
  38806. set pinchDeltaPercentage(value: number);
  38807. /**
  38808. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38809. * and pinch delta percentage.
  38810. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38811. * that any object in the plane at the camera's target point will scale
  38812. * perfectly with finger motion.
  38813. */
  38814. get useNaturalPinchZoom(): boolean;
  38815. set useNaturalPinchZoom(value: boolean);
  38816. /**
  38817. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38818. */
  38819. get panningSensibility(): number;
  38820. set panningSensibility(value: number);
  38821. /**
  38822. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38823. */
  38824. get keysUp(): number[];
  38825. set keysUp(value: number[]);
  38826. /**
  38827. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38828. */
  38829. get keysDown(): number[];
  38830. set keysDown(value: number[]);
  38831. /**
  38832. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38833. */
  38834. get keysLeft(): number[];
  38835. set keysLeft(value: number[]);
  38836. /**
  38837. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38838. */
  38839. get keysRight(): number[];
  38840. set keysRight(value: number[]);
  38841. /**
  38842. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38843. */
  38844. get wheelPrecision(): number;
  38845. set wheelPrecision(value: number);
  38846. /**
  38847. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38848. * It will be used instead of pinchDeltaPrecision if different from 0.
  38849. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38850. */
  38851. get wheelDeltaPercentage(): number;
  38852. set wheelDeltaPercentage(value: number);
  38853. /**
  38854. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38855. */
  38856. zoomOnFactor: number;
  38857. /**
  38858. * Defines a screen offset for the camera position.
  38859. */
  38860. targetScreenOffset: Vector2;
  38861. /**
  38862. * Allows the camera to be completely reversed.
  38863. * If false the camera can not arrive upside down.
  38864. */
  38865. allowUpsideDown: boolean;
  38866. /**
  38867. * Define if double tap/click is used to restore the previously saved state of the camera.
  38868. */
  38869. useInputToRestoreState: boolean;
  38870. /** @hidden */
  38871. _viewMatrix: Matrix;
  38872. /** @hidden */
  38873. _useCtrlForPanning: boolean;
  38874. /** @hidden */
  38875. _panningMouseButton: number;
  38876. /**
  38877. * Defines the input associated to the camera.
  38878. */
  38879. inputs: ArcRotateCameraInputsManager;
  38880. /** @hidden */
  38881. _reset: () => void;
  38882. /**
  38883. * Defines the allowed panning axis.
  38884. */
  38885. panningAxis: Vector3;
  38886. protected _localDirection: Vector3;
  38887. protected _transformedDirection: Vector3;
  38888. private _bouncingBehavior;
  38889. /**
  38890. * Gets the bouncing behavior of the camera if it has been enabled.
  38891. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38892. */
  38893. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38894. /**
  38895. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38896. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38897. */
  38898. get useBouncingBehavior(): boolean;
  38899. set useBouncingBehavior(value: boolean);
  38900. private _framingBehavior;
  38901. /**
  38902. * Gets the framing behavior of the camera if it has been enabled.
  38903. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38904. */
  38905. get framingBehavior(): Nullable<FramingBehavior>;
  38906. /**
  38907. * Defines if the framing behavior of the camera is enabled on the camera.
  38908. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38909. */
  38910. get useFramingBehavior(): boolean;
  38911. set useFramingBehavior(value: boolean);
  38912. private _autoRotationBehavior;
  38913. /**
  38914. * Gets the auto rotation behavior of the camera if it has been enabled.
  38915. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38916. */
  38917. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38918. /**
  38919. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38920. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38921. */
  38922. get useAutoRotationBehavior(): boolean;
  38923. set useAutoRotationBehavior(value: boolean);
  38924. /**
  38925. * Observable triggered when the mesh target has been changed on the camera.
  38926. */
  38927. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38928. /**
  38929. * Event raised when the camera is colliding with a mesh.
  38930. */
  38931. onCollide: (collidedMesh: AbstractMesh) => void;
  38932. /**
  38933. * Defines whether the camera should check collision with the objects oh the scene.
  38934. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38935. */
  38936. checkCollisions: boolean;
  38937. /**
  38938. * Defines the collision radius of the camera.
  38939. * This simulates a sphere around the camera.
  38940. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38941. */
  38942. collisionRadius: Vector3;
  38943. protected _collider: Collider;
  38944. protected _previousPosition: Vector3;
  38945. protected _collisionVelocity: Vector3;
  38946. protected _newPosition: Vector3;
  38947. protected _previousAlpha: number;
  38948. protected _previousBeta: number;
  38949. protected _previousRadius: number;
  38950. protected _collisionTriggered: boolean;
  38951. protected _targetBoundingCenter: Nullable<Vector3>;
  38952. private _computationVector;
  38953. /**
  38954. * Instantiates a new ArcRotateCamera in a given scene
  38955. * @param name Defines the name of the camera
  38956. * @param alpha Defines the camera rotation along the logitudinal axis
  38957. * @param beta Defines the camera rotation along the latitudinal axis
  38958. * @param radius Defines the camera distance from its target
  38959. * @param target Defines the camera target
  38960. * @param scene Defines the scene the camera belongs to
  38961. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38962. */
  38963. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38964. /** @hidden */
  38965. _initCache(): void;
  38966. /** @hidden */
  38967. _updateCache(ignoreParentClass?: boolean): void;
  38968. protected _getTargetPosition(): Vector3;
  38969. private _storedAlpha;
  38970. private _storedBeta;
  38971. private _storedRadius;
  38972. private _storedTarget;
  38973. private _storedTargetScreenOffset;
  38974. /**
  38975. * Stores the current state of the camera (alpha, beta, radius and target)
  38976. * @returns the camera itself
  38977. */
  38978. storeState(): Camera;
  38979. /**
  38980. * @hidden
  38981. * Restored camera state. You must call storeState() first
  38982. */
  38983. _restoreStateValues(): boolean;
  38984. /** @hidden */
  38985. _isSynchronizedViewMatrix(): boolean;
  38986. /**
  38987. * Attached controls to the current camera.
  38988. * @param element Defines the element the controls should be listened from
  38989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38990. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38991. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38992. */
  38993. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38994. /**
  38995. * Detach the current controls from the camera.
  38996. * The camera will stop reacting to inputs.
  38997. * @param element Defines the element to stop listening the inputs from
  38998. */
  38999. detachControl(element: HTMLElement): void;
  39000. /** @hidden */
  39001. _checkInputs(): void;
  39002. protected _checkLimits(): void;
  39003. /**
  39004. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39005. */
  39006. rebuildAnglesAndRadius(): void;
  39007. /**
  39008. * Use a position to define the current camera related information like alpha, beta and radius
  39009. * @param position Defines the position to set the camera at
  39010. */
  39011. setPosition(position: Vector3): void;
  39012. /**
  39013. * Defines the target the camera should look at.
  39014. * This will automatically adapt alpha beta and radius to fit within the new target.
  39015. * @param target Defines the new target as a Vector or a mesh
  39016. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39017. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39018. */
  39019. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39020. /** @hidden */
  39021. _getViewMatrix(): Matrix;
  39022. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39023. /**
  39024. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39025. * @param meshes Defines the mesh to zoom on
  39026. * @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)
  39027. */
  39028. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39029. /**
  39030. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39031. * The target will be changed but the radius
  39032. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39033. * @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)
  39034. */
  39035. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39036. min: Vector3;
  39037. max: Vector3;
  39038. distance: number;
  39039. }, doNotUpdateMaxZ?: boolean): void;
  39040. /**
  39041. * @override
  39042. * Override Camera.createRigCamera
  39043. */
  39044. createRigCamera(name: string, cameraIndex: number): Camera;
  39045. /**
  39046. * @hidden
  39047. * @override
  39048. * Override Camera._updateRigCameras
  39049. */
  39050. _updateRigCameras(): void;
  39051. /**
  39052. * Destroy the camera and release the current resources hold by it.
  39053. */
  39054. dispose(): void;
  39055. /**
  39056. * Gets the current object class name.
  39057. * @return the class name
  39058. */
  39059. getClassName(): string;
  39060. }
  39061. }
  39062. declare module BABYLON {
  39063. /**
  39064. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39065. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39066. */
  39067. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39068. /**
  39069. * Gets the name of the behavior.
  39070. */
  39071. get name(): string;
  39072. private _zoomStopsAnimation;
  39073. private _idleRotationSpeed;
  39074. private _idleRotationWaitTime;
  39075. private _idleRotationSpinupTime;
  39076. /**
  39077. * Sets the flag that indicates if user zooming should stop animation.
  39078. */
  39079. set zoomStopsAnimation(flag: boolean);
  39080. /**
  39081. * Gets the flag that indicates if user zooming should stop animation.
  39082. */
  39083. get zoomStopsAnimation(): boolean;
  39084. /**
  39085. * Sets the default speed at which the camera rotates around the model.
  39086. */
  39087. set idleRotationSpeed(speed: number);
  39088. /**
  39089. * Gets the default speed at which the camera rotates around the model.
  39090. */
  39091. get idleRotationSpeed(): number;
  39092. /**
  39093. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39094. */
  39095. set idleRotationWaitTime(time: number);
  39096. /**
  39097. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39098. */
  39099. get idleRotationWaitTime(): number;
  39100. /**
  39101. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39102. */
  39103. set idleRotationSpinupTime(time: number);
  39104. /**
  39105. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39106. */
  39107. get idleRotationSpinupTime(): number;
  39108. /**
  39109. * Gets a value indicating if the camera is currently rotating because of this behavior
  39110. */
  39111. get rotationInProgress(): boolean;
  39112. private _onPrePointerObservableObserver;
  39113. private _onAfterCheckInputsObserver;
  39114. private _attachedCamera;
  39115. private _isPointerDown;
  39116. private _lastFrameTime;
  39117. private _lastInteractionTime;
  39118. private _cameraRotationSpeed;
  39119. /**
  39120. * Initializes the behavior.
  39121. */
  39122. init(): void;
  39123. /**
  39124. * Attaches the behavior to its arc rotate camera.
  39125. * @param camera Defines the camera to attach the behavior to
  39126. */
  39127. attach(camera: ArcRotateCamera): void;
  39128. /**
  39129. * Detaches the behavior from its current arc rotate camera.
  39130. */
  39131. detach(): void;
  39132. /**
  39133. * Returns true if user is scrolling.
  39134. * @return true if user is scrolling.
  39135. */
  39136. private _userIsZooming;
  39137. private _lastFrameRadius;
  39138. private _shouldAnimationStopForInteraction;
  39139. /**
  39140. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39141. */
  39142. private _applyUserInteraction;
  39143. private _userIsMoving;
  39144. }
  39145. }
  39146. declare module BABYLON {
  39147. /**
  39148. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39149. */
  39150. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39151. private ui;
  39152. /**
  39153. * The name of the behavior
  39154. */
  39155. name: string;
  39156. /**
  39157. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39158. */
  39159. distanceAwayFromFace: number;
  39160. /**
  39161. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39162. */
  39163. distanceAwayFromBottomOfFace: number;
  39164. private _faceVectors;
  39165. private _target;
  39166. private _scene;
  39167. private _onRenderObserver;
  39168. private _tmpMatrix;
  39169. private _tmpVector;
  39170. /**
  39171. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39172. * @param ui The transform node that should be attched to the mesh
  39173. */
  39174. constructor(ui: TransformNode);
  39175. /**
  39176. * Initializes the behavior
  39177. */
  39178. init(): void;
  39179. private _closestFace;
  39180. private _zeroVector;
  39181. private _lookAtTmpMatrix;
  39182. private _lookAtToRef;
  39183. /**
  39184. * Attaches the AttachToBoxBehavior to the passed in mesh
  39185. * @param target The mesh that the specified node will be attached to
  39186. */
  39187. attach(target: Mesh): void;
  39188. /**
  39189. * Detaches the behavior from the mesh
  39190. */
  39191. detach(): void;
  39192. }
  39193. }
  39194. declare module BABYLON {
  39195. /**
  39196. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39197. */
  39198. export class FadeInOutBehavior implements Behavior<Mesh> {
  39199. /**
  39200. * Time in milliseconds to delay before fading in (Default: 0)
  39201. */
  39202. delay: number;
  39203. /**
  39204. * Time in milliseconds for the mesh to fade in (Default: 300)
  39205. */
  39206. fadeInTime: number;
  39207. private _millisecondsPerFrame;
  39208. private _hovered;
  39209. private _hoverValue;
  39210. private _ownerNode;
  39211. /**
  39212. * Instatiates the FadeInOutBehavior
  39213. */
  39214. constructor();
  39215. /**
  39216. * The name of the behavior
  39217. */
  39218. get name(): string;
  39219. /**
  39220. * Initializes the behavior
  39221. */
  39222. init(): void;
  39223. /**
  39224. * Attaches the fade behavior on the passed in mesh
  39225. * @param ownerNode The mesh that will be faded in/out once attached
  39226. */
  39227. attach(ownerNode: Mesh): void;
  39228. /**
  39229. * Detaches the behavior from the mesh
  39230. */
  39231. detach(): void;
  39232. /**
  39233. * Triggers the mesh to begin fading in or out
  39234. * @param value if the object should fade in or out (true to fade in)
  39235. */
  39236. fadeIn(value: boolean): void;
  39237. private _update;
  39238. private _setAllVisibility;
  39239. }
  39240. }
  39241. declare module BABYLON {
  39242. /**
  39243. * Class containing a set of static utilities functions for managing Pivots
  39244. * @hidden
  39245. */
  39246. export class PivotTools {
  39247. private static _PivotCached;
  39248. private static _OldPivotPoint;
  39249. private static _PivotTranslation;
  39250. private static _PivotTmpVector;
  39251. /** @hidden */
  39252. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39253. /** @hidden */
  39254. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39255. }
  39256. }
  39257. declare module BABYLON {
  39258. /**
  39259. * Class containing static functions to help procedurally build meshes
  39260. */
  39261. export class PlaneBuilder {
  39262. /**
  39263. * Creates a plane mesh
  39264. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39265. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39266. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39268. * * 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
  39269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39270. * @param name defines the name of the mesh
  39271. * @param options defines the options used to create the mesh
  39272. * @param scene defines the hosting scene
  39273. * @returns the plane mesh
  39274. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39275. */
  39276. static CreatePlane(name: string, options: {
  39277. size?: number;
  39278. width?: number;
  39279. height?: number;
  39280. sideOrientation?: number;
  39281. frontUVs?: Vector4;
  39282. backUVs?: Vector4;
  39283. updatable?: boolean;
  39284. sourcePlane?: Plane;
  39285. }, scene?: Nullable<Scene>): Mesh;
  39286. }
  39287. }
  39288. declare module BABYLON {
  39289. /**
  39290. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39291. */
  39292. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39293. private static _AnyMouseID;
  39294. /**
  39295. * Abstract mesh the behavior is set on
  39296. */
  39297. attachedNode: AbstractMesh;
  39298. private _dragPlane;
  39299. private _scene;
  39300. private _pointerObserver;
  39301. private _beforeRenderObserver;
  39302. private static _planeScene;
  39303. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39304. /**
  39305. * 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)
  39306. */
  39307. maxDragAngle: number;
  39308. /**
  39309. * @hidden
  39310. */
  39311. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39312. /**
  39313. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39314. */
  39315. currentDraggingPointerID: number;
  39316. /**
  39317. * The last position where the pointer hit the drag plane in world space
  39318. */
  39319. lastDragPosition: Vector3;
  39320. /**
  39321. * If the behavior is currently in a dragging state
  39322. */
  39323. dragging: boolean;
  39324. /**
  39325. * 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)
  39326. */
  39327. dragDeltaRatio: number;
  39328. /**
  39329. * If the drag plane orientation should be updated during the dragging (Default: true)
  39330. */
  39331. updateDragPlane: boolean;
  39332. private _debugMode;
  39333. private _moving;
  39334. /**
  39335. * Fires each time the attached mesh is dragged with the pointer
  39336. * * delta between last drag position and current drag position in world space
  39337. * * dragDistance along the drag axis
  39338. * * dragPlaneNormal normal of the current drag plane used during the drag
  39339. * * dragPlanePoint in world space where the drag intersects the drag plane
  39340. */
  39341. onDragObservable: Observable<{
  39342. delta: Vector3;
  39343. dragPlanePoint: Vector3;
  39344. dragPlaneNormal: Vector3;
  39345. dragDistance: number;
  39346. pointerId: number;
  39347. }>;
  39348. /**
  39349. * Fires each time a drag begins (eg. mouse down on mesh)
  39350. */
  39351. onDragStartObservable: Observable<{
  39352. dragPlanePoint: Vector3;
  39353. pointerId: number;
  39354. }>;
  39355. /**
  39356. * Fires each time a drag ends (eg. mouse release after drag)
  39357. */
  39358. onDragEndObservable: Observable<{
  39359. dragPlanePoint: Vector3;
  39360. pointerId: number;
  39361. }>;
  39362. /**
  39363. * If the attached mesh should be moved when dragged
  39364. */
  39365. moveAttached: boolean;
  39366. /**
  39367. * If the drag behavior will react to drag events (Default: true)
  39368. */
  39369. enabled: boolean;
  39370. /**
  39371. * If pointer events should start and release the drag (Default: true)
  39372. */
  39373. startAndReleaseDragOnPointerEvents: boolean;
  39374. /**
  39375. * If camera controls should be detached during the drag
  39376. */
  39377. detachCameraControls: boolean;
  39378. /**
  39379. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39380. */
  39381. useObjectOrientationForDragging: boolean;
  39382. private _options;
  39383. /**
  39384. * Gets the options used by the behavior
  39385. */
  39386. get options(): {
  39387. dragAxis?: Vector3;
  39388. dragPlaneNormal?: Vector3;
  39389. };
  39390. /**
  39391. * Sets the options used by the behavior
  39392. */
  39393. set options(options: {
  39394. dragAxis?: Vector3;
  39395. dragPlaneNormal?: Vector3;
  39396. });
  39397. /**
  39398. * Creates a pointer drag behavior that can be attached to a mesh
  39399. * @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)
  39400. */
  39401. constructor(options?: {
  39402. dragAxis?: Vector3;
  39403. dragPlaneNormal?: Vector3;
  39404. });
  39405. /**
  39406. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39407. */
  39408. validateDrag: (targetPosition: Vector3) => boolean;
  39409. /**
  39410. * The name of the behavior
  39411. */
  39412. get name(): string;
  39413. /**
  39414. * Initializes the behavior
  39415. */
  39416. init(): void;
  39417. private _tmpVector;
  39418. private _alternatePickedPoint;
  39419. private _worldDragAxis;
  39420. private _targetPosition;
  39421. private _attachedElement;
  39422. /**
  39423. * Attaches the drag behavior the passed in mesh
  39424. * @param ownerNode The mesh that will be dragged around once attached
  39425. * @param predicate Predicate to use for pick filtering
  39426. */
  39427. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39428. /**
  39429. * Force relase the drag action by code.
  39430. */
  39431. releaseDrag(): void;
  39432. private _startDragRay;
  39433. private _lastPointerRay;
  39434. /**
  39435. * Simulates the start of a pointer drag event on the behavior
  39436. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39437. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39438. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39439. */
  39440. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39441. private _startDrag;
  39442. private _dragDelta;
  39443. private _moveDrag;
  39444. private _pickWithRayOnDragPlane;
  39445. private _pointA;
  39446. private _pointB;
  39447. private _pointC;
  39448. private _lineA;
  39449. private _lineB;
  39450. private _localAxis;
  39451. private _lookAt;
  39452. private _updateDragPlanePosition;
  39453. /**
  39454. * Detaches the behavior from the mesh
  39455. */
  39456. detach(): void;
  39457. }
  39458. }
  39459. declare module BABYLON {
  39460. /**
  39461. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39462. */
  39463. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39464. private _dragBehaviorA;
  39465. private _dragBehaviorB;
  39466. private _startDistance;
  39467. private _initialScale;
  39468. private _targetScale;
  39469. private _ownerNode;
  39470. private _sceneRenderObserver;
  39471. /**
  39472. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39473. */
  39474. constructor();
  39475. /**
  39476. * The name of the behavior
  39477. */
  39478. get name(): string;
  39479. /**
  39480. * Initializes the behavior
  39481. */
  39482. init(): void;
  39483. private _getCurrentDistance;
  39484. /**
  39485. * Attaches the scale behavior the passed in mesh
  39486. * @param ownerNode The mesh that will be scaled around once attached
  39487. */
  39488. attach(ownerNode: Mesh): void;
  39489. /**
  39490. * Detaches the behavior from the mesh
  39491. */
  39492. detach(): void;
  39493. }
  39494. }
  39495. declare module BABYLON {
  39496. /**
  39497. * 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
  39498. */
  39499. export class SixDofDragBehavior implements Behavior<Mesh> {
  39500. private static _virtualScene;
  39501. private _ownerNode;
  39502. private _sceneRenderObserver;
  39503. private _scene;
  39504. private _targetPosition;
  39505. private _virtualOriginMesh;
  39506. private _virtualDragMesh;
  39507. private _pointerObserver;
  39508. private _moving;
  39509. private _startingOrientation;
  39510. /**
  39511. * 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)
  39512. */
  39513. private zDragFactor;
  39514. /**
  39515. * If the object should rotate to face the drag origin
  39516. */
  39517. rotateDraggedObject: boolean;
  39518. /**
  39519. * If the behavior is currently in a dragging state
  39520. */
  39521. dragging: boolean;
  39522. /**
  39523. * 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)
  39524. */
  39525. dragDeltaRatio: number;
  39526. /**
  39527. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39528. */
  39529. currentDraggingPointerID: number;
  39530. /**
  39531. * If camera controls should be detached during the drag
  39532. */
  39533. detachCameraControls: boolean;
  39534. /**
  39535. * Fires each time a drag starts
  39536. */
  39537. onDragStartObservable: Observable<{}>;
  39538. /**
  39539. * Fires each time a drag ends (eg. mouse release after drag)
  39540. */
  39541. onDragEndObservable: Observable<{}>;
  39542. /**
  39543. * 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
  39544. */
  39545. constructor();
  39546. /**
  39547. * The name of the behavior
  39548. */
  39549. get name(): string;
  39550. /**
  39551. * Initializes the behavior
  39552. */
  39553. init(): void;
  39554. /**
  39555. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39556. */
  39557. private get _pointerCamera();
  39558. /**
  39559. * Attaches the scale behavior the passed in mesh
  39560. * @param ownerNode The mesh that will be scaled around once attached
  39561. */
  39562. attach(ownerNode: Mesh): void;
  39563. /**
  39564. * Detaches the behavior from the mesh
  39565. */
  39566. detach(): void;
  39567. }
  39568. }
  39569. declare module BABYLON {
  39570. /**
  39571. * Class used to apply inverse kinematics to bones
  39572. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39573. */
  39574. export class BoneIKController {
  39575. private static _tmpVecs;
  39576. private static _tmpQuat;
  39577. private static _tmpMats;
  39578. /**
  39579. * Gets or sets the target mesh
  39580. */
  39581. targetMesh: AbstractMesh;
  39582. /** Gets or sets the mesh used as pole */
  39583. poleTargetMesh: AbstractMesh;
  39584. /**
  39585. * Gets or sets the bone used as pole
  39586. */
  39587. poleTargetBone: Nullable<Bone>;
  39588. /**
  39589. * Gets or sets the target position
  39590. */
  39591. targetPosition: Vector3;
  39592. /**
  39593. * Gets or sets the pole target position
  39594. */
  39595. poleTargetPosition: Vector3;
  39596. /**
  39597. * Gets or sets the pole target local offset
  39598. */
  39599. poleTargetLocalOffset: Vector3;
  39600. /**
  39601. * Gets or sets the pole angle
  39602. */
  39603. poleAngle: number;
  39604. /**
  39605. * Gets or sets the mesh associated with the controller
  39606. */
  39607. mesh: AbstractMesh;
  39608. /**
  39609. * 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)
  39610. */
  39611. slerpAmount: number;
  39612. private _bone1Quat;
  39613. private _bone1Mat;
  39614. private _bone2Ang;
  39615. private _bone1;
  39616. private _bone2;
  39617. private _bone1Length;
  39618. private _bone2Length;
  39619. private _maxAngle;
  39620. private _maxReach;
  39621. private _rightHandedSystem;
  39622. private _bendAxis;
  39623. private _slerping;
  39624. private _adjustRoll;
  39625. /**
  39626. * Gets or sets maximum allowed angle
  39627. */
  39628. get maxAngle(): number;
  39629. set maxAngle(value: number);
  39630. /**
  39631. * Creates a new BoneIKController
  39632. * @param mesh defines the mesh to control
  39633. * @param bone defines the bone to control
  39634. * @param options defines options to set up the controller
  39635. */
  39636. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39637. targetMesh?: AbstractMesh;
  39638. poleTargetMesh?: AbstractMesh;
  39639. poleTargetBone?: Bone;
  39640. poleTargetLocalOffset?: Vector3;
  39641. poleAngle?: number;
  39642. bendAxis?: Vector3;
  39643. maxAngle?: number;
  39644. slerpAmount?: number;
  39645. });
  39646. private _setMaxAngle;
  39647. /**
  39648. * Force the controller to update the bones
  39649. */
  39650. update(): void;
  39651. }
  39652. }
  39653. declare module BABYLON {
  39654. /**
  39655. * Class used to make a bone look toward a point in space
  39656. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39657. */
  39658. export class BoneLookController {
  39659. private static _tmpVecs;
  39660. private static _tmpQuat;
  39661. private static _tmpMats;
  39662. /**
  39663. * The target Vector3 that the bone will look at
  39664. */
  39665. target: Vector3;
  39666. /**
  39667. * The mesh that the bone is attached to
  39668. */
  39669. mesh: AbstractMesh;
  39670. /**
  39671. * The bone that will be looking to the target
  39672. */
  39673. bone: Bone;
  39674. /**
  39675. * The up axis of the coordinate system that is used when the bone is rotated
  39676. */
  39677. upAxis: Vector3;
  39678. /**
  39679. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39680. */
  39681. upAxisSpace: Space;
  39682. /**
  39683. * Used to make an adjustment to the yaw of the bone
  39684. */
  39685. adjustYaw: number;
  39686. /**
  39687. * Used to make an adjustment to the pitch of the bone
  39688. */
  39689. adjustPitch: number;
  39690. /**
  39691. * Used to make an adjustment to the roll of the bone
  39692. */
  39693. adjustRoll: number;
  39694. /**
  39695. * 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)
  39696. */
  39697. slerpAmount: number;
  39698. private _minYaw;
  39699. private _maxYaw;
  39700. private _minPitch;
  39701. private _maxPitch;
  39702. private _minYawSin;
  39703. private _minYawCos;
  39704. private _maxYawSin;
  39705. private _maxYawCos;
  39706. private _midYawConstraint;
  39707. private _minPitchTan;
  39708. private _maxPitchTan;
  39709. private _boneQuat;
  39710. private _slerping;
  39711. private _transformYawPitch;
  39712. private _transformYawPitchInv;
  39713. private _firstFrameSkipped;
  39714. private _yawRange;
  39715. private _fowardAxis;
  39716. /**
  39717. * Gets or sets the minimum yaw angle that the bone can look to
  39718. */
  39719. get minYaw(): number;
  39720. set minYaw(value: number);
  39721. /**
  39722. * Gets or sets the maximum yaw angle that the bone can look to
  39723. */
  39724. get maxYaw(): number;
  39725. set maxYaw(value: number);
  39726. /**
  39727. * Gets or sets the minimum pitch angle that the bone can look to
  39728. */
  39729. get minPitch(): number;
  39730. set minPitch(value: number);
  39731. /**
  39732. * Gets or sets the maximum pitch angle that the bone can look to
  39733. */
  39734. get maxPitch(): number;
  39735. set maxPitch(value: number);
  39736. /**
  39737. * Create a BoneLookController
  39738. * @param mesh the mesh that the bone belongs to
  39739. * @param bone the bone that will be looking to the target
  39740. * @param target the target Vector3 to look at
  39741. * @param options optional settings:
  39742. * * maxYaw: the maximum angle the bone will yaw to
  39743. * * minYaw: the minimum angle the bone will yaw to
  39744. * * maxPitch: the maximum angle the bone will pitch to
  39745. * * minPitch: the minimum angle the bone will yaw to
  39746. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39747. * * upAxis: the up axis of the coordinate system
  39748. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39749. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39750. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39751. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39752. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39753. * * adjustRoll: used to make an adjustment to the roll of the bone
  39754. **/
  39755. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39756. maxYaw?: number;
  39757. minYaw?: number;
  39758. maxPitch?: number;
  39759. minPitch?: number;
  39760. slerpAmount?: number;
  39761. upAxis?: Vector3;
  39762. upAxisSpace?: Space;
  39763. yawAxis?: Vector3;
  39764. pitchAxis?: Vector3;
  39765. adjustYaw?: number;
  39766. adjustPitch?: number;
  39767. adjustRoll?: number;
  39768. });
  39769. /**
  39770. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39771. */
  39772. update(): void;
  39773. private _getAngleDiff;
  39774. private _getAngleBetween;
  39775. private _isAngleBetween;
  39776. }
  39777. }
  39778. declare module BABYLON {
  39779. /**
  39780. * Manage the gamepad inputs to control an arc rotate camera.
  39781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39782. */
  39783. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39784. /**
  39785. * Defines the camera the input is attached to.
  39786. */
  39787. camera: ArcRotateCamera;
  39788. /**
  39789. * Defines the gamepad the input is gathering event from.
  39790. */
  39791. gamepad: Nullable<Gamepad>;
  39792. /**
  39793. * Defines the gamepad rotation sensiblity.
  39794. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39795. */
  39796. gamepadRotationSensibility: number;
  39797. /**
  39798. * Defines the gamepad move sensiblity.
  39799. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39800. */
  39801. gamepadMoveSensibility: number;
  39802. private _yAxisScale;
  39803. /**
  39804. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39805. */
  39806. get invertYAxis(): boolean;
  39807. set invertYAxis(value: boolean);
  39808. private _onGamepadConnectedObserver;
  39809. private _onGamepadDisconnectedObserver;
  39810. /**
  39811. * Attach the input controls to a specific dom element to get the input from.
  39812. * @param element Defines the element the controls should be listened from
  39813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39814. */
  39815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39816. /**
  39817. * Detach the current controls from the specified dom element.
  39818. * @param element Defines the element to stop listening the inputs from
  39819. */
  39820. detachControl(element: Nullable<HTMLElement>): void;
  39821. /**
  39822. * Update the current camera state depending on the inputs that have been used this frame.
  39823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39824. */
  39825. checkInputs(): void;
  39826. /**
  39827. * Gets the class name of the current intput.
  39828. * @returns the class name
  39829. */
  39830. getClassName(): string;
  39831. /**
  39832. * Get the friendly name associated with the input class.
  39833. * @returns the input friendly name
  39834. */
  39835. getSimpleName(): string;
  39836. }
  39837. }
  39838. declare module BABYLON {
  39839. interface ArcRotateCameraInputsManager {
  39840. /**
  39841. * Add orientation input support to the input manager.
  39842. * @returns the current input manager
  39843. */
  39844. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39845. }
  39846. /**
  39847. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39849. */
  39850. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39851. /**
  39852. * Defines the camera the input is attached to.
  39853. */
  39854. camera: ArcRotateCamera;
  39855. /**
  39856. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39857. */
  39858. alphaCorrection: number;
  39859. /**
  39860. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39861. */
  39862. gammaCorrection: number;
  39863. private _alpha;
  39864. private _gamma;
  39865. private _dirty;
  39866. private _deviceOrientationHandler;
  39867. /**
  39868. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39869. */
  39870. constructor();
  39871. /**
  39872. * Attach the input controls to a specific dom element to get the input from.
  39873. * @param element Defines the element the controls should be listened from
  39874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39875. */
  39876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39877. /** @hidden */
  39878. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39879. /**
  39880. * Update the current camera state depending on the inputs that have been used this frame.
  39881. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39882. */
  39883. checkInputs(): void;
  39884. /**
  39885. * Detach the current controls from the specified dom element.
  39886. * @param element Defines the element to stop listening the inputs from
  39887. */
  39888. detachControl(element: Nullable<HTMLElement>): void;
  39889. /**
  39890. * Gets the class name of the current intput.
  39891. * @returns the class name
  39892. */
  39893. getClassName(): string;
  39894. /**
  39895. * Get the friendly name associated with the input class.
  39896. * @returns the input friendly name
  39897. */
  39898. getSimpleName(): string;
  39899. }
  39900. }
  39901. declare module BABYLON {
  39902. /**
  39903. * Listen to mouse events to control the camera.
  39904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39905. */
  39906. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39907. /**
  39908. * Defines the camera the input is attached to.
  39909. */
  39910. camera: FlyCamera;
  39911. /**
  39912. * Defines if touch is enabled. (Default is true.)
  39913. */
  39914. touchEnabled: boolean;
  39915. /**
  39916. * Defines the buttons associated with the input to handle camera rotation.
  39917. */
  39918. buttons: number[];
  39919. /**
  39920. * Assign buttons for Yaw control.
  39921. */
  39922. buttonsYaw: number[];
  39923. /**
  39924. * Assign buttons for Pitch control.
  39925. */
  39926. buttonsPitch: number[];
  39927. /**
  39928. * Assign buttons for Roll control.
  39929. */
  39930. buttonsRoll: number[];
  39931. /**
  39932. * Detect if any button is being pressed while mouse is moved.
  39933. * -1 = Mouse locked.
  39934. * 0 = Left button.
  39935. * 1 = Middle Button.
  39936. * 2 = Right Button.
  39937. */
  39938. activeButton: number;
  39939. /**
  39940. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39941. * Higher values reduce its sensitivity.
  39942. */
  39943. angularSensibility: number;
  39944. private _mousemoveCallback;
  39945. private _observer;
  39946. private _rollObserver;
  39947. private previousPosition;
  39948. private noPreventDefault;
  39949. private element;
  39950. /**
  39951. * Listen to mouse events to control the camera.
  39952. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39954. */
  39955. constructor(touchEnabled?: boolean);
  39956. /**
  39957. * Attach the mouse control to the HTML DOM element.
  39958. * @param element Defines the element that listens to the input events.
  39959. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39960. */
  39961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39962. /**
  39963. * Detach the current controls from the specified dom element.
  39964. * @param element Defines the element to stop listening the inputs from
  39965. */
  39966. detachControl(element: Nullable<HTMLElement>): void;
  39967. /**
  39968. * Gets the class name of the current input.
  39969. * @returns the class name.
  39970. */
  39971. getClassName(): string;
  39972. /**
  39973. * Get the friendly name associated with the input class.
  39974. * @returns the input's friendly name.
  39975. */
  39976. getSimpleName(): string;
  39977. private _pointerInput;
  39978. private _onMouseMove;
  39979. /**
  39980. * Rotate camera by mouse offset.
  39981. */
  39982. private rotateCamera;
  39983. }
  39984. }
  39985. declare module BABYLON {
  39986. /**
  39987. * Default Inputs manager for the FlyCamera.
  39988. * It groups all the default supported inputs for ease of use.
  39989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39990. */
  39991. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39992. /**
  39993. * Instantiates a new FlyCameraInputsManager.
  39994. * @param camera Defines the camera the inputs belong to.
  39995. */
  39996. constructor(camera: FlyCamera);
  39997. /**
  39998. * Add keyboard input support to the input manager.
  39999. * @returns the new FlyCameraKeyboardMoveInput().
  40000. */
  40001. addKeyboard(): FlyCameraInputsManager;
  40002. /**
  40003. * Add mouse input support to the input manager.
  40004. * @param touchEnabled Enable touch screen support.
  40005. * @returns the new FlyCameraMouseInput().
  40006. */
  40007. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40008. }
  40009. }
  40010. declare module BABYLON {
  40011. /**
  40012. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40013. * such as in a 3D Space Shooter or a Flight Simulator.
  40014. */
  40015. export class FlyCamera extends TargetCamera {
  40016. /**
  40017. * Define the collision ellipsoid of the camera.
  40018. * This is helpful for simulating a camera body, like a player's body.
  40019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40020. */
  40021. ellipsoid: Vector3;
  40022. /**
  40023. * Define an offset for the position of the ellipsoid around the camera.
  40024. * This can be helpful if the camera is attached away from the player's body center,
  40025. * such as at its head.
  40026. */
  40027. ellipsoidOffset: Vector3;
  40028. /**
  40029. * Enable or disable collisions of the camera with the rest of the scene objects.
  40030. */
  40031. checkCollisions: boolean;
  40032. /**
  40033. * Enable or disable gravity on the camera.
  40034. */
  40035. applyGravity: boolean;
  40036. /**
  40037. * Define the current direction the camera is moving to.
  40038. */
  40039. cameraDirection: Vector3;
  40040. /**
  40041. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40042. * This overrides and empties cameraRotation.
  40043. */
  40044. rotationQuaternion: Quaternion;
  40045. /**
  40046. * Track Roll to maintain the wanted Rolling when looking around.
  40047. */
  40048. _trackRoll: number;
  40049. /**
  40050. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40051. */
  40052. rollCorrect: number;
  40053. /**
  40054. * Mimic a banked turn, Rolling the camera when Yawing.
  40055. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40056. */
  40057. bankedTurn: boolean;
  40058. /**
  40059. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40060. */
  40061. bankedTurnLimit: number;
  40062. /**
  40063. * Value of 0 disables the banked Roll.
  40064. * Value of 1 is equal to the Yaw angle in radians.
  40065. */
  40066. bankedTurnMultiplier: number;
  40067. /**
  40068. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40069. */
  40070. inputs: FlyCameraInputsManager;
  40071. /**
  40072. * Gets the input sensibility for mouse input.
  40073. * Higher values reduce sensitivity.
  40074. */
  40075. get angularSensibility(): number;
  40076. /**
  40077. * Sets the input sensibility for a mouse input.
  40078. * Higher values reduce sensitivity.
  40079. */
  40080. set angularSensibility(value: number);
  40081. /**
  40082. * Get the keys for camera movement forward.
  40083. */
  40084. get keysForward(): number[];
  40085. /**
  40086. * Set the keys for camera movement forward.
  40087. */
  40088. set keysForward(value: number[]);
  40089. /**
  40090. * Get the keys for camera movement backward.
  40091. */
  40092. get keysBackward(): number[];
  40093. set keysBackward(value: number[]);
  40094. /**
  40095. * Get the keys for camera movement up.
  40096. */
  40097. get keysUp(): number[];
  40098. /**
  40099. * Set the keys for camera movement up.
  40100. */
  40101. set keysUp(value: number[]);
  40102. /**
  40103. * Get the keys for camera movement down.
  40104. */
  40105. get keysDown(): number[];
  40106. /**
  40107. * Set the keys for camera movement down.
  40108. */
  40109. set keysDown(value: number[]);
  40110. /**
  40111. * Get the keys for camera movement left.
  40112. */
  40113. get keysLeft(): number[];
  40114. /**
  40115. * Set the keys for camera movement left.
  40116. */
  40117. set keysLeft(value: number[]);
  40118. /**
  40119. * Set the keys for camera movement right.
  40120. */
  40121. get keysRight(): number[];
  40122. /**
  40123. * Set the keys for camera movement right.
  40124. */
  40125. set keysRight(value: number[]);
  40126. /**
  40127. * Event raised when the camera collides with a mesh in the scene.
  40128. */
  40129. onCollide: (collidedMesh: AbstractMesh) => void;
  40130. private _collider;
  40131. private _needMoveForGravity;
  40132. private _oldPosition;
  40133. private _diffPosition;
  40134. private _newPosition;
  40135. /** @hidden */
  40136. _localDirection: Vector3;
  40137. /** @hidden */
  40138. _transformedDirection: Vector3;
  40139. /**
  40140. * Instantiates a FlyCamera.
  40141. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40142. * such as in a 3D Space Shooter or a Flight Simulator.
  40143. * @param name Define the name of the camera in the scene.
  40144. * @param position Define the starting position of the camera in the scene.
  40145. * @param scene Define the scene the camera belongs to.
  40146. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40147. */
  40148. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40149. /**
  40150. * Attach a control to the HTML DOM element.
  40151. * @param element Defines the element that listens to the input events.
  40152. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40153. */
  40154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40155. /**
  40156. * Detach a control from the HTML DOM element.
  40157. * The camera will stop reacting to that input.
  40158. * @param element Defines the element that listens to the input events.
  40159. */
  40160. detachControl(element: HTMLElement): void;
  40161. private _collisionMask;
  40162. /**
  40163. * Get the mask that the camera ignores in collision events.
  40164. */
  40165. get collisionMask(): number;
  40166. /**
  40167. * Set the mask that the camera ignores in collision events.
  40168. */
  40169. set collisionMask(mask: number);
  40170. /** @hidden */
  40171. _collideWithWorld(displacement: Vector3): void;
  40172. /** @hidden */
  40173. private _onCollisionPositionChange;
  40174. /** @hidden */
  40175. _checkInputs(): void;
  40176. /** @hidden */
  40177. _decideIfNeedsToMove(): boolean;
  40178. /** @hidden */
  40179. _updatePosition(): void;
  40180. /**
  40181. * Restore the Roll to its target value at the rate specified.
  40182. * @param rate - Higher means slower restoring.
  40183. * @hidden
  40184. */
  40185. restoreRoll(rate: number): void;
  40186. /**
  40187. * Destroy the camera and release the current resources held by it.
  40188. */
  40189. dispose(): void;
  40190. /**
  40191. * Get the current object class name.
  40192. * @returns the class name.
  40193. */
  40194. getClassName(): string;
  40195. }
  40196. }
  40197. declare module BABYLON {
  40198. /**
  40199. * Listen to keyboard events to control the camera.
  40200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40201. */
  40202. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40203. /**
  40204. * Defines the camera the input is attached to.
  40205. */
  40206. camera: FlyCamera;
  40207. /**
  40208. * The list of keyboard keys used to control the forward move of the camera.
  40209. */
  40210. keysForward: number[];
  40211. /**
  40212. * The list of keyboard keys used to control the backward move of the camera.
  40213. */
  40214. keysBackward: number[];
  40215. /**
  40216. * The list of keyboard keys used to control the forward move of the camera.
  40217. */
  40218. keysUp: number[];
  40219. /**
  40220. * The list of keyboard keys used to control the backward move of the camera.
  40221. */
  40222. keysDown: number[];
  40223. /**
  40224. * The list of keyboard keys used to control the right strafe move of the camera.
  40225. */
  40226. keysRight: number[];
  40227. /**
  40228. * The list of keyboard keys used to control the left strafe move of the camera.
  40229. */
  40230. keysLeft: number[];
  40231. private _keys;
  40232. private _onCanvasBlurObserver;
  40233. private _onKeyboardObserver;
  40234. private _engine;
  40235. private _scene;
  40236. /**
  40237. * Attach the input controls to a specific dom element to get the input from.
  40238. * @param element Defines the element the controls should be listened from
  40239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40240. */
  40241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40242. /**
  40243. * Detach the current controls from the specified dom element.
  40244. * @param element Defines the element to stop listening the inputs from
  40245. */
  40246. detachControl(element: Nullable<HTMLElement>): void;
  40247. /**
  40248. * Gets the class name of the current intput.
  40249. * @returns the class name
  40250. */
  40251. getClassName(): string;
  40252. /** @hidden */
  40253. _onLostFocus(e: FocusEvent): void;
  40254. /**
  40255. * Get the friendly name associated with the input class.
  40256. * @returns the input friendly name
  40257. */
  40258. getSimpleName(): string;
  40259. /**
  40260. * Update the current camera state depending on the inputs that have been used this frame.
  40261. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40262. */
  40263. checkInputs(): void;
  40264. }
  40265. }
  40266. declare module BABYLON {
  40267. /**
  40268. * Manage the mouse wheel inputs to control a follow camera.
  40269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40270. */
  40271. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40272. /**
  40273. * Defines the camera the input is attached to.
  40274. */
  40275. camera: FollowCamera;
  40276. /**
  40277. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40278. */
  40279. axisControlRadius: boolean;
  40280. /**
  40281. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40282. */
  40283. axisControlHeight: boolean;
  40284. /**
  40285. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40286. */
  40287. axisControlRotation: boolean;
  40288. /**
  40289. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40290. * relation to mouseWheel events.
  40291. */
  40292. wheelPrecision: number;
  40293. /**
  40294. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40295. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40296. */
  40297. wheelDeltaPercentage: number;
  40298. private _wheel;
  40299. private _observer;
  40300. /**
  40301. * Attach the input controls to a specific dom element to get the input from.
  40302. * @param element Defines the element the controls should be listened from
  40303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40304. */
  40305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40306. /**
  40307. * Detach the current controls from the specified dom element.
  40308. * @param element Defines the element to stop listening the inputs from
  40309. */
  40310. detachControl(element: Nullable<HTMLElement>): void;
  40311. /**
  40312. * Gets the class name of the current intput.
  40313. * @returns the class name
  40314. */
  40315. getClassName(): string;
  40316. /**
  40317. * Get the friendly name associated with the input class.
  40318. * @returns the input friendly name
  40319. */
  40320. getSimpleName(): string;
  40321. }
  40322. }
  40323. declare module BABYLON {
  40324. /**
  40325. * Manage the pointers inputs to control an follow camera.
  40326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40327. */
  40328. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40329. /**
  40330. * Defines the camera the input is attached to.
  40331. */
  40332. camera: FollowCamera;
  40333. /**
  40334. * Gets the class name of the current input.
  40335. * @returns the class name
  40336. */
  40337. getClassName(): string;
  40338. /**
  40339. * Defines the pointer angular sensibility along the X axis or how fast is
  40340. * the camera rotating.
  40341. * A negative number will reverse the axis direction.
  40342. */
  40343. angularSensibilityX: number;
  40344. /**
  40345. * Defines the pointer angular sensibility along the Y axis or how fast is
  40346. * the camera rotating.
  40347. * A negative number will reverse the axis direction.
  40348. */
  40349. angularSensibilityY: number;
  40350. /**
  40351. * Defines the pointer pinch precision or how fast is the camera zooming.
  40352. * A negative number will reverse the axis direction.
  40353. */
  40354. pinchPrecision: number;
  40355. /**
  40356. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40357. * from 0.
  40358. * It defines the percentage of current camera.radius to use as delta when
  40359. * pinch zoom is used.
  40360. */
  40361. pinchDeltaPercentage: number;
  40362. /**
  40363. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40364. */
  40365. axisXControlRadius: boolean;
  40366. /**
  40367. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40368. */
  40369. axisXControlHeight: boolean;
  40370. /**
  40371. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40372. */
  40373. axisXControlRotation: boolean;
  40374. /**
  40375. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40376. */
  40377. axisYControlRadius: boolean;
  40378. /**
  40379. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40380. */
  40381. axisYControlHeight: boolean;
  40382. /**
  40383. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40384. */
  40385. axisYControlRotation: boolean;
  40386. /**
  40387. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40388. */
  40389. axisPinchControlRadius: boolean;
  40390. /**
  40391. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40392. */
  40393. axisPinchControlHeight: boolean;
  40394. /**
  40395. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40396. */
  40397. axisPinchControlRotation: boolean;
  40398. /**
  40399. * Log error messages if basic misconfiguration has occurred.
  40400. */
  40401. warningEnable: boolean;
  40402. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40403. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40404. private _warningCounter;
  40405. private _warning;
  40406. }
  40407. }
  40408. declare module BABYLON {
  40409. /**
  40410. * Default Inputs manager for the FollowCamera.
  40411. * It groups all the default supported inputs for ease of use.
  40412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40413. */
  40414. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40415. /**
  40416. * Instantiates a new FollowCameraInputsManager.
  40417. * @param camera Defines the camera the inputs belong to
  40418. */
  40419. constructor(camera: FollowCamera);
  40420. /**
  40421. * Add keyboard input support to the input manager.
  40422. * @returns the current input manager
  40423. */
  40424. addKeyboard(): FollowCameraInputsManager;
  40425. /**
  40426. * Add mouse wheel input support to the input manager.
  40427. * @returns the current input manager
  40428. */
  40429. addMouseWheel(): FollowCameraInputsManager;
  40430. /**
  40431. * Add pointers input support to the input manager.
  40432. * @returns the current input manager
  40433. */
  40434. addPointers(): FollowCameraInputsManager;
  40435. /**
  40436. * Add orientation input support to the input manager.
  40437. * @returns the current input manager
  40438. */
  40439. addVRDeviceOrientation(): FollowCameraInputsManager;
  40440. }
  40441. }
  40442. declare module BABYLON {
  40443. /**
  40444. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40445. * an arc rotate version arcFollowCamera are available.
  40446. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40447. */
  40448. export class FollowCamera extends TargetCamera {
  40449. /**
  40450. * Distance the follow camera should follow an object at
  40451. */
  40452. radius: number;
  40453. /**
  40454. * Minimum allowed distance of the camera to the axis of rotation
  40455. * (The camera can not get closer).
  40456. * This can help limiting how the Camera is able to move in the scene.
  40457. */
  40458. lowerRadiusLimit: Nullable<number>;
  40459. /**
  40460. * Maximum allowed distance of the camera to the axis of rotation
  40461. * (The camera can not get further).
  40462. * This can help limiting how the Camera is able to move in the scene.
  40463. */
  40464. upperRadiusLimit: Nullable<number>;
  40465. /**
  40466. * Define a rotation offset between the camera and the object it follows
  40467. */
  40468. rotationOffset: number;
  40469. /**
  40470. * Minimum allowed angle to camera position relative to target object.
  40471. * This can help limiting how the Camera is able to move in the scene.
  40472. */
  40473. lowerRotationOffsetLimit: Nullable<number>;
  40474. /**
  40475. * Maximum allowed angle to camera position relative to target object.
  40476. * This can help limiting how the Camera is able to move in the scene.
  40477. */
  40478. upperRotationOffsetLimit: Nullable<number>;
  40479. /**
  40480. * Define a height offset between the camera and the object it follows.
  40481. * It can help following an object from the top (like a car chaing a plane)
  40482. */
  40483. heightOffset: number;
  40484. /**
  40485. * Minimum allowed height of camera position relative to target object.
  40486. * This can help limiting how the Camera is able to move in the scene.
  40487. */
  40488. lowerHeightOffsetLimit: Nullable<number>;
  40489. /**
  40490. * Maximum allowed height of camera position relative to target object.
  40491. * This can help limiting how the Camera is able to move in the scene.
  40492. */
  40493. upperHeightOffsetLimit: Nullable<number>;
  40494. /**
  40495. * Define how fast the camera can accelerate to follow it s target.
  40496. */
  40497. cameraAcceleration: number;
  40498. /**
  40499. * Define the speed limit of the camera following an object.
  40500. */
  40501. maxCameraSpeed: number;
  40502. /**
  40503. * Define the target of the camera.
  40504. */
  40505. lockedTarget: Nullable<AbstractMesh>;
  40506. /**
  40507. * Defines the input associated with the camera.
  40508. */
  40509. inputs: FollowCameraInputsManager;
  40510. /**
  40511. * Instantiates the follow camera.
  40512. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40513. * @param name Define the name of the camera in the scene
  40514. * @param position Define the position of the camera
  40515. * @param scene Define the scene the camera belong to
  40516. * @param lockedTarget Define the target of the camera
  40517. */
  40518. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40519. private _follow;
  40520. /**
  40521. * Attached controls to the current camera.
  40522. * @param element Defines the element the controls should be listened from
  40523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40524. */
  40525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40526. /**
  40527. * Detach the current controls from the camera.
  40528. * The camera will stop reacting to inputs.
  40529. * @param element Defines the element to stop listening the inputs from
  40530. */
  40531. detachControl(element: HTMLElement): void;
  40532. /** @hidden */
  40533. _checkInputs(): void;
  40534. private _checkLimits;
  40535. /**
  40536. * Gets the camera class name.
  40537. * @returns the class name
  40538. */
  40539. getClassName(): string;
  40540. }
  40541. /**
  40542. * Arc Rotate version of the follow camera.
  40543. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40544. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40545. */
  40546. export class ArcFollowCamera extends TargetCamera {
  40547. /** The longitudinal angle of the camera */
  40548. alpha: number;
  40549. /** The latitudinal angle of the camera */
  40550. beta: number;
  40551. /** The radius of the camera from its target */
  40552. radius: number;
  40553. /** Define the camera target (the messh it should follow) */
  40554. target: Nullable<AbstractMesh>;
  40555. private _cartesianCoordinates;
  40556. /**
  40557. * Instantiates a new ArcFollowCamera
  40558. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40559. * @param name Define the name of the camera
  40560. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40561. * @param beta Define the rotation angle of the camera around the elevation axis
  40562. * @param radius Define the radius of the camera from its target point
  40563. * @param target Define the target of the camera
  40564. * @param scene Define the scene the camera belongs to
  40565. */
  40566. constructor(name: string,
  40567. /** The longitudinal angle of the camera */
  40568. alpha: number,
  40569. /** The latitudinal angle of the camera */
  40570. beta: number,
  40571. /** The radius of the camera from its target */
  40572. radius: number,
  40573. /** Define the camera target (the messh it should follow) */
  40574. target: Nullable<AbstractMesh>, scene: Scene);
  40575. private _follow;
  40576. /** @hidden */
  40577. _checkInputs(): void;
  40578. /**
  40579. * Returns the class name of the object.
  40580. * It is mostly used internally for serialization purposes.
  40581. */
  40582. getClassName(): string;
  40583. }
  40584. }
  40585. declare module BABYLON {
  40586. /**
  40587. * Manage the keyboard inputs to control the movement of a follow camera.
  40588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40589. */
  40590. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40591. /**
  40592. * Defines the camera the input is attached to.
  40593. */
  40594. camera: FollowCamera;
  40595. /**
  40596. * Defines the list of key codes associated with the up action (increase heightOffset)
  40597. */
  40598. keysHeightOffsetIncr: number[];
  40599. /**
  40600. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40601. */
  40602. keysHeightOffsetDecr: number[];
  40603. /**
  40604. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40605. */
  40606. keysHeightOffsetModifierAlt: boolean;
  40607. /**
  40608. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40609. */
  40610. keysHeightOffsetModifierCtrl: boolean;
  40611. /**
  40612. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40613. */
  40614. keysHeightOffsetModifierShift: boolean;
  40615. /**
  40616. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40617. */
  40618. keysRotationOffsetIncr: number[];
  40619. /**
  40620. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40621. */
  40622. keysRotationOffsetDecr: number[];
  40623. /**
  40624. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40625. */
  40626. keysRotationOffsetModifierAlt: boolean;
  40627. /**
  40628. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40629. */
  40630. keysRotationOffsetModifierCtrl: boolean;
  40631. /**
  40632. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40633. */
  40634. keysRotationOffsetModifierShift: boolean;
  40635. /**
  40636. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40637. */
  40638. keysRadiusIncr: number[];
  40639. /**
  40640. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40641. */
  40642. keysRadiusDecr: number[];
  40643. /**
  40644. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40645. */
  40646. keysRadiusModifierAlt: boolean;
  40647. /**
  40648. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40649. */
  40650. keysRadiusModifierCtrl: boolean;
  40651. /**
  40652. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40653. */
  40654. keysRadiusModifierShift: boolean;
  40655. /**
  40656. * Defines the rate of change of heightOffset.
  40657. */
  40658. heightSensibility: number;
  40659. /**
  40660. * Defines the rate of change of rotationOffset.
  40661. */
  40662. rotationSensibility: number;
  40663. /**
  40664. * Defines the rate of change of radius.
  40665. */
  40666. radiusSensibility: number;
  40667. private _keys;
  40668. private _ctrlPressed;
  40669. private _altPressed;
  40670. private _shiftPressed;
  40671. private _onCanvasBlurObserver;
  40672. private _onKeyboardObserver;
  40673. private _engine;
  40674. private _scene;
  40675. /**
  40676. * Attach the input controls to a specific dom element to get the input from.
  40677. * @param element Defines the element the controls should be listened from
  40678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40679. */
  40680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40681. /**
  40682. * Detach the current controls from the specified dom element.
  40683. * @param element Defines the element to stop listening the inputs from
  40684. */
  40685. detachControl(element: Nullable<HTMLElement>): void;
  40686. /**
  40687. * Update the current camera state depending on the inputs that have been used this frame.
  40688. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40689. */
  40690. checkInputs(): void;
  40691. /**
  40692. * Gets the class name of the current input.
  40693. * @returns the class name
  40694. */
  40695. getClassName(): string;
  40696. /**
  40697. * Get the friendly name associated with the input class.
  40698. * @returns the input friendly name
  40699. */
  40700. getSimpleName(): string;
  40701. /**
  40702. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40703. * allow modification of the heightOffset value.
  40704. */
  40705. private _modifierHeightOffset;
  40706. /**
  40707. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40708. * allow modification of the rotationOffset value.
  40709. */
  40710. private _modifierRotationOffset;
  40711. /**
  40712. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40713. * allow modification of the radius value.
  40714. */
  40715. private _modifierRadius;
  40716. }
  40717. }
  40718. declare module BABYLON {
  40719. interface FreeCameraInputsManager {
  40720. /**
  40721. * @hidden
  40722. */
  40723. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40724. /**
  40725. * Add orientation input support to the input manager.
  40726. * @returns the current input manager
  40727. */
  40728. addDeviceOrientation(): FreeCameraInputsManager;
  40729. }
  40730. /**
  40731. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40732. * Screen rotation is taken into account.
  40733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40734. */
  40735. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40736. private _camera;
  40737. private _screenOrientationAngle;
  40738. private _constantTranform;
  40739. private _screenQuaternion;
  40740. private _alpha;
  40741. private _beta;
  40742. private _gamma;
  40743. /**
  40744. * Can be used to detect if a device orientation sensor is available on a device
  40745. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40746. * @returns a promise that will resolve on orientation change
  40747. */
  40748. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40749. /**
  40750. * @hidden
  40751. */
  40752. _onDeviceOrientationChangedObservable: Observable<void>;
  40753. /**
  40754. * Instantiates a new input
  40755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40756. */
  40757. constructor();
  40758. /**
  40759. * Define the camera controlled by the input.
  40760. */
  40761. get camera(): FreeCamera;
  40762. set camera(camera: FreeCamera);
  40763. /**
  40764. * Attach the input controls to a specific dom element to get the input from.
  40765. * @param element Defines the element the controls should be listened from
  40766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40767. */
  40768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40769. private _orientationChanged;
  40770. private _deviceOrientation;
  40771. /**
  40772. * Detach the current controls from the specified dom element.
  40773. * @param element Defines the element to stop listening the inputs from
  40774. */
  40775. detachControl(element: Nullable<HTMLElement>): void;
  40776. /**
  40777. * Update the current camera state depending on the inputs that have been used this frame.
  40778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40779. */
  40780. checkInputs(): void;
  40781. /**
  40782. * Gets the class name of the current intput.
  40783. * @returns the class name
  40784. */
  40785. getClassName(): string;
  40786. /**
  40787. * Get the friendly name associated with the input class.
  40788. * @returns the input friendly name
  40789. */
  40790. getSimpleName(): string;
  40791. }
  40792. }
  40793. declare module BABYLON {
  40794. /**
  40795. * Manage the gamepad inputs to control a free camera.
  40796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40797. */
  40798. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40799. /**
  40800. * Define the camera the input is attached to.
  40801. */
  40802. camera: FreeCamera;
  40803. /**
  40804. * Define the Gamepad controlling the input
  40805. */
  40806. gamepad: Nullable<Gamepad>;
  40807. /**
  40808. * Defines the gamepad rotation sensiblity.
  40809. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40810. */
  40811. gamepadAngularSensibility: number;
  40812. /**
  40813. * Defines the gamepad move sensiblity.
  40814. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40815. */
  40816. gamepadMoveSensibility: number;
  40817. private _yAxisScale;
  40818. /**
  40819. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40820. */
  40821. get invertYAxis(): boolean;
  40822. set invertYAxis(value: boolean);
  40823. private _onGamepadConnectedObserver;
  40824. private _onGamepadDisconnectedObserver;
  40825. private _cameraTransform;
  40826. private _deltaTransform;
  40827. private _vector3;
  40828. private _vector2;
  40829. /**
  40830. * Attach the input controls to a specific dom element to get the input from.
  40831. * @param element Defines the element the controls should be listened from
  40832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40833. */
  40834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40835. /**
  40836. * Detach the current controls from the specified dom element.
  40837. * @param element Defines the element to stop listening the inputs from
  40838. */
  40839. detachControl(element: Nullable<HTMLElement>): void;
  40840. /**
  40841. * Update the current camera state depending on the inputs that have been used this frame.
  40842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40843. */
  40844. checkInputs(): void;
  40845. /**
  40846. * Gets the class name of the current intput.
  40847. * @returns the class name
  40848. */
  40849. getClassName(): string;
  40850. /**
  40851. * Get the friendly name associated with the input class.
  40852. * @returns the input friendly name
  40853. */
  40854. getSimpleName(): string;
  40855. }
  40856. }
  40857. declare module BABYLON {
  40858. /**
  40859. * Defines the potential axis of a Joystick
  40860. */
  40861. export enum JoystickAxis {
  40862. /** X axis */
  40863. X = 0,
  40864. /** Y axis */
  40865. Y = 1,
  40866. /** Z axis */
  40867. Z = 2
  40868. }
  40869. /**
  40870. * Class used to define virtual joystick (used in touch mode)
  40871. */
  40872. export class VirtualJoystick {
  40873. /**
  40874. * Gets or sets a boolean indicating that left and right values must be inverted
  40875. */
  40876. reverseLeftRight: boolean;
  40877. /**
  40878. * Gets or sets a boolean indicating that up and down values must be inverted
  40879. */
  40880. reverseUpDown: boolean;
  40881. /**
  40882. * Gets the offset value for the position (ie. the change of the position value)
  40883. */
  40884. deltaPosition: Vector3;
  40885. /**
  40886. * Gets a boolean indicating if the virtual joystick was pressed
  40887. */
  40888. pressed: boolean;
  40889. /**
  40890. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40891. */
  40892. static Canvas: Nullable<HTMLCanvasElement>;
  40893. private static _globalJoystickIndex;
  40894. private static vjCanvasContext;
  40895. private static vjCanvasWidth;
  40896. private static vjCanvasHeight;
  40897. private static halfWidth;
  40898. private _action;
  40899. private _axisTargetedByLeftAndRight;
  40900. private _axisTargetedByUpAndDown;
  40901. private _joystickSensibility;
  40902. private _inversedSensibility;
  40903. private _joystickPointerID;
  40904. private _joystickColor;
  40905. private _joystickPointerPos;
  40906. private _joystickPreviousPointerPos;
  40907. private _joystickPointerStartPos;
  40908. private _deltaJoystickVector;
  40909. private _leftJoystick;
  40910. private _touches;
  40911. private _onPointerDownHandlerRef;
  40912. private _onPointerMoveHandlerRef;
  40913. private _onPointerUpHandlerRef;
  40914. private _onResize;
  40915. /**
  40916. * Creates a new virtual joystick
  40917. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40918. */
  40919. constructor(leftJoystick?: boolean);
  40920. /**
  40921. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40922. * @param newJoystickSensibility defines the new sensibility
  40923. */
  40924. setJoystickSensibility(newJoystickSensibility: number): void;
  40925. private _onPointerDown;
  40926. private _onPointerMove;
  40927. private _onPointerUp;
  40928. /**
  40929. * Change the color of the virtual joystick
  40930. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40931. */
  40932. setJoystickColor(newColor: string): void;
  40933. /**
  40934. * Defines a callback to call when the joystick is touched
  40935. * @param action defines the callback
  40936. */
  40937. setActionOnTouch(action: () => any): void;
  40938. /**
  40939. * Defines which axis you'd like to control for left & right
  40940. * @param axis defines the axis to use
  40941. */
  40942. setAxisForLeftRight(axis: JoystickAxis): void;
  40943. /**
  40944. * Defines which axis you'd like to control for up & down
  40945. * @param axis defines the axis to use
  40946. */
  40947. setAxisForUpDown(axis: JoystickAxis): void;
  40948. private _drawVirtualJoystick;
  40949. /**
  40950. * Release internal HTML canvas
  40951. */
  40952. releaseCanvas(): void;
  40953. }
  40954. }
  40955. declare module BABYLON {
  40956. interface FreeCameraInputsManager {
  40957. /**
  40958. * Add virtual joystick input support to the input manager.
  40959. * @returns the current input manager
  40960. */
  40961. addVirtualJoystick(): FreeCameraInputsManager;
  40962. }
  40963. /**
  40964. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40966. */
  40967. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40968. /**
  40969. * Defines the camera the input is attached to.
  40970. */
  40971. camera: FreeCamera;
  40972. private _leftjoystick;
  40973. private _rightjoystick;
  40974. /**
  40975. * Gets the left stick of the virtual joystick.
  40976. * @returns The virtual Joystick
  40977. */
  40978. getLeftJoystick(): VirtualJoystick;
  40979. /**
  40980. * Gets the right stick of the virtual joystick.
  40981. * @returns The virtual Joystick
  40982. */
  40983. getRightJoystick(): VirtualJoystick;
  40984. /**
  40985. * Update the current camera state depending on the inputs that have been used this frame.
  40986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40987. */
  40988. checkInputs(): void;
  40989. /**
  40990. * Attach the input controls to a specific dom element to get the input from.
  40991. * @param element Defines the element the controls should be listened from
  40992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40993. */
  40994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40995. /**
  40996. * Detach the current controls from the specified dom element.
  40997. * @param element Defines the element to stop listening the inputs from
  40998. */
  40999. detachControl(element: Nullable<HTMLElement>): void;
  41000. /**
  41001. * Gets the class name of the current intput.
  41002. * @returns the class name
  41003. */
  41004. getClassName(): string;
  41005. /**
  41006. * Get the friendly name associated with the input class.
  41007. * @returns the input friendly name
  41008. */
  41009. getSimpleName(): string;
  41010. }
  41011. }
  41012. declare module BABYLON {
  41013. /**
  41014. * This represents a FPS type of camera controlled by touch.
  41015. * This is like a universal camera minus the Gamepad controls.
  41016. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41017. */
  41018. export class TouchCamera extends FreeCamera {
  41019. /**
  41020. * Defines the touch sensibility for rotation.
  41021. * The higher the faster.
  41022. */
  41023. get touchAngularSensibility(): number;
  41024. set touchAngularSensibility(value: number);
  41025. /**
  41026. * Defines the touch sensibility for move.
  41027. * The higher the faster.
  41028. */
  41029. get touchMoveSensibility(): number;
  41030. set touchMoveSensibility(value: number);
  41031. /**
  41032. * Instantiates a new touch camera.
  41033. * This represents a FPS type of camera controlled by touch.
  41034. * This is like a universal camera minus the Gamepad controls.
  41035. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41036. * @param name Define the name of the camera in the scene
  41037. * @param position Define the start position of the camera in the scene
  41038. * @param scene Define the scene the camera belongs to
  41039. */
  41040. constructor(name: string, position: Vector3, scene: Scene);
  41041. /**
  41042. * Gets the current object class name.
  41043. * @return the class name
  41044. */
  41045. getClassName(): string;
  41046. /** @hidden */
  41047. _setupInputs(): void;
  41048. }
  41049. }
  41050. declare module BABYLON {
  41051. /**
  41052. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41053. * being tilted forward or back and left or right.
  41054. */
  41055. export class DeviceOrientationCamera extends FreeCamera {
  41056. private _initialQuaternion;
  41057. private _quaternionCache;
  41058. private _tmpDragQuaternion;
  41059. private _disablePointerInputWhenUsingDeviceOrientation;
  41060. /**
  41061. * Creates a new device orientation camera
  41062. * @param name The name of the camera
  41063. * @param position The start position camera
  41064. * @param scene The scene the camera belongs to
  41065. */
  41066. constructor(name: string, position: Vector3, scene: Scene);
  41067. /**
  41068. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41069. */
  41070. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41071. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41072. private _dragFactor;
  41073. /**
  41074. * Enabled turning on the y axis when the orientation sensor is active
  41075. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41076. */
  41077. enableHorizontalDragging(dragFactor?: number): void;
  41078. /**
  41079. * Gets the current instance class name ("DeviceOrientationCamera").
  41080. * This helps avoiding instanceof at run time.
  41081. * @returns the class name
  41082. */
  41083. getClassName(): string;
  41084. /**
  41085. * @hidden
  41086. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41087. */
  41088. _checkInputs(): void;
  41089. /**
  41090. * Reset the camera to its default orientation on the specified axis only.
  41091. * @param axis The axis to reset
  41092. */
  41093. resetToCurrentRotation(axis?: Axis): void;
  41094. }
  41095. }
  41096. declare module BABYLON {
  41097. /**
  41098. * Defines supported buttons for XBox360 compatible gamepads
  41099. */
  41100. export enum Xbox360Button {
  41101. /** A */
  41102. A = 0,
  41103. /** B */
  41104. B = 1,
  41105. /** X */
  41106. X = 2,
  41107. /** Y */
  41108. Y = 3,
  41109. /** Left button */
  41110. LB = 4,
  41111. /** Right button */
  41112. RB = 5,
  41113. /** Back */
  41114. Back = 8,
  41115. /** Start */
  41116. Start = 9,
  41117. /** Left stick */
  41118. LeftStick = 10,
  41119. /** Right stick */
  41120. RightStick = 11
  41121. }
  41122. /** Defines values for XBox360 DPad */
  41123. export enum Xbox360Dpad {
  41124. /** Up */
  41125. Up = 12,
  41126. /** Down */
  41127. Down = 13,
  41128. /** Left */
  41129. Left = 14,
  41130. /** Right */
  41131. Right = 15
  41132. }
  41133. /**
  41134. * Defines a XBox360 gamepad
  41135. */
  41136. export class Xbox360Pad extends Gamepad {
  41137. private _leftTrigger;
  41138. private _rightTrigger;
  41139. private _onlefttriggerchanged;
  41140. private _onrighttriggerchanged;
  41141. private _onbuttondown;
  41142. private _onbuttonup;
  41143. private _ondpaddown;
  41144. private _ondpadup;
  41145. /** Observable raised when a button is pressed */
  41146. onButtonDownObservable: Observable<Xbox360Button>;
  41147. /** Observable raised when a button is released */
  41148. onButtonUpObservable: Observable<Xbox360Button>;
  41149. /** Observable raised when a pad is pressed */
  41150. onPadDownObservable: Observable<Xbox360Dpad>;
  41151. /** Observable raised when a pad is released */
  41152. onPadUpObservable: Observable<Xbox360Dpad>;
  41153. private _buttonA;
  41154. private _buttonB;
  41155. private _buttonX;
  41156. private _buttonY;
  41157. private _buttonBack;
  41158. private _buttonStart;
  41159. private _buttonLB;
  41160. private _buttonRB;
  41161. private _buttonLeftStick;
  41162. private _buttonRightStick;
  41163. private _dPadUp;
  41164. private _dPadDown;
  41165. private _dPadLeft;
  41166. private _dPadRight;
  41167. private _isXboxOnePad;
  41168. /**
  41169. * Creates a new XBox360 gamepad object
  41170. * @param id defines the id of this gamepad
  41171. * @param index defines its index
  41172. * @param gamepad defines the internal HTML gamepad object
  41173. * @param xboxOne defines if it is a XBox One gamepad
  41174. */
  41175. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41176. /**
  41177. * Defines the callback to call when left trigger is pressed
  41178. * @param callback defines the callback to use
  41179. */
  41180. onlefttriggerchanged(callback: (value: number) => void): void;
  41181. /**
  41182. * Defines the callback to call when right trigger is pressed
  41183. * @param callback defines the callback to use
  41184. */
  41185. onrighttriggerchanged(callback: (value: number) => void): void;
  41186. /**
  41187. * Gets the left trigger value
  41188. */
  41189. get leftTrigger(): number;
  41190. /**
  41191. * Sets the left trigger value
  41192. */
  41193. set leftTrigger(newValue: number);
  41194. /**
  41195. * Gets the right trigger value
  41196. */
  41197. get rightTrigger(): number;
  41198. /**
  41199. * Sets the right trigger value
  41200. */
  41201. set rightTrigger(newValue: number);
  41202. /**
  41203. * Defines the callback to call when a button is pressed
  41204. * @param callback defines the callback to use
  41205. */
  41206. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41207. /**
  41208. * Defines the callback to call when a button is released
  41209. * @param callback defines the callback to use
  41210. */
  41211. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41212. /**
  41213. * Defines the callback to call when a pad is pressed
  41214. * @param callback defines the callback to use
  41215. */
  41216. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41217. /**
  41218. * Defines the callback to call when a pad is released
  41219. * @param callback defines the callback to use
  41220. */
  41221. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41222. private _setButtonValue;
  41223. private _setDPadValue;
  41224. /**
  41225. * Gets the value of the `A` button
  41226. */
  41227. get buttonA(): number;
  41228. /**
  41229. * Sets the value of the `A` button
  41230. */
  41231. set buttonA(value: number);
  41232. /**
  41233. * Gets the value of the `B` button
  41234. */
  41235. get buttonB(): number;
  41236. /**
  41237. * Sets the value of the `B` button
  41238. */
  41239. set buttonB(value: number);
  41240. /**
  41241. * Gets the value of the `X` button
  41242. */
  41243. get buttonX(): number;
  41244. /**
  41245. * Sets the value of the `X` button
  41246. */
  41247. set buttonX(value: number);
  41248. /**
  41249. * Gets the value of the `Y` button
  41250. */
  41251. get buttonY(): number;
  41252. /**
  41253. * Sets the value of the `Y` button
  41254. */
  41255. set buttonY(value: number);
  41256. /**
  41257. * Gets the value of the `Start` button
  41258. */
  41259. get buttonStart(): number;
  41260. /**
  41261. * Sets the value of the `Start` button
  41262. */
  41263. set buttonStart(value: number);
  41264. /**
  41265. * Gets the value of the `Back` button
  41266. */
  41267. get buttonBack(): number;
  41268. /**
  41269. * Sets the value of the `Back` button
  41270. */
  41271. set buttonBack(value: number);
  41272. /**
  41273. * Gets the value of the `Left` button
  41274. */
  41275. get buttonLB(): number;
  41276. /**
  41277. * Sets the value of the `Left` button
  41278. */
  41279. set buttonLB(value: number);
  41280. /**
  41281. * Gets the value of the `Right` button
  41282. */
  41283. get buttonRB(): number;
  41284. /**
  41285. * Sets the value of the `Right` button
  41286. */
  41287. set buttonRB(value: number);
  41288. /**
  41289. * Gets the value of the Left joystick
  41290. */
  41291. get buttonLeftStick(): number;
  41292. /**
  41293. * Sets the value of the Left joystick
  41294. */
  41295. set buttonLeftStick(value: number);
  41296. /**
  41297. * Gets the value of the Right joystick
  41298. */
  41299. get buttonRightStick(): number;
  41300. /**
  41301. * Sets the value of the Right joystick
  41302. */
  41303. set buttonRightStick(value: number);
  41304. /**
  41305. * Gets the value of D-pad up
  41306. */
  41307. get dPadUp(): number;
  41308. /**
  41309. * Sets the value of D-pad up
  41310. */
  41311. set dPadUp(value: number);
  41312. /**
  41313. * Gets the value of D-pad down
  41314. */
  41315. get dPadDown(): number;
  41316. /**
  41317. * Sets the value of D-pad down
  41318. */
  41319. set dPadDown(value: number);
  41320. /**
  41321. * Gets the value of D-pad left
  41322. */
  41323. get dPadLeft(): number;
  41324. /**
  41325. * Sets the value of D-pad left
  41326. */
  41327. set dPadLeft(value: number);
  41328. /**
  41329. * Gets the value of D-pad right
  41330. */
  41331. get dPadRight(): number;
  41332. /**
  41333. * Sets the value of D-pad right
  41334. */
  41335. set dPadRight(value: number);
  41336. /**
  41337. * Force the gamepad to synchronize with device values
  41338. */
  41339. update(): void;
  41340. /**
  41341. * Disposes the gamepad
  41342. */
  41343. dispose(): void;
  41344. }
  41345. }
  41346. declare module BABYLON {
  41347. /**
  41348. * Defines supported buttons for DualShock compatible gamepads
  41349. */
  41350. export enum DualShockButton {
  41351. /** Cross */
  41352. Cross = 0,
  41353. /** Circle */
  41354. Circle = 1,
  41355. /** Square */
  41356. Square = 2,
  41357. /** Triangle */
  41358. Triangle = 3,
  41359. /** L1 */
  41360. L1 = 4,
  41361. /** R1 */
  41362. R1 = 5,
  41363. /** Share */
  41364. Share = 8,
  41365. /** Options */
  41366. Options = 9,
  41367. /** Left stick */
  41368. LeftStick = 10,
  41369. /** Right stick */
  41370. RightStick = 11
  41371. }
  41372. /** Defines values for DualShock DPad */
  41373. export enum DualShockDpad {
  41374. /** Up */
  41375. Up = 12,
  41376. /** Down */
  41377. Down = 13,
  41378. /** Left */
  41379. Left = 14,
  41380. /** Right */
  41381. Right = 15
  41382. }
  41383. /**
  41384. * Defines a DualShock gamepad
  41385. */
  41386. export class DualShockPad extends Gamepad {
  41387. private _leftTrigger;
  41388. private _rightTrigger;
  41389. private _onlefttriggerchanged;
  41390. private _onrighttriggerchanged;
  41391. private _onbuttondown;
  41392. private _onbuttonup;
  41393. private _ondpaddown;
  41394. private _ondpadup;
  41395. /** Observable raised when a button is pressed */
  41396. onButtonDownObservable: Observable<DualShockButton>;
  41397. /** Observable raised when a button is released */
  41398. onButtonUpObservable: Observable<DualShockButton>;
  41399. /** Observable raised when a pad is pressed */
  41400. onPadDownObservable: Observable<DualShockDpad>;
  41401. /** Observable raised when a pad is released */
  41402. onPadUpObservable: Observable<DualShockDpad>;
  41403. private _buttonCross;
  41404. private _buttonCircle;
  41405. private _buttonSquare;
  41406. private _buttonTriangle;
  41407. private _buttonShare;
  41408. private _buttonOptions;
  41409. private _buttonL1;
  41410. private _buttonR1;
  41411. private _buttonLeftStick;
  41412. private _buttonRightStick;
  41413. private _dPadUp;
  41414. private _dPadDown;
  41415. private _dPadLeft;
  41416. private _dPadRight;
  41417. /**
  41418. * Creates a new DualShock gamepad object
  41419. * @param id defines the id of this gamepad
  41420. * @param index defines its index
  41421. * @param gamepad defines the internal HTML gamepad object
  41422. */
  41423. constructor(id: string, index: number, gamepad: any);
  41424. /**
  41425. * Defines the callback to call when left trigger is pressed
  41426. * @param callback defines the callback to use
  41427. */
  41428. onlefttriggerchanged(callback: (value: number) => void): void;
  41429. /**
  41430. * Defines the callback to call when right trigger is pressed
  41431. * @param callback defines the callback to use
  41432. */
  41433. onrighttriggerchanged(callback: (value: number) => void): void;
  41434. /**
  41435. * Gets the left trigger value
  41436. */
  41437. get leftTrigger(): number;
  41438. /**
  41439. * Sets the left trigger value
  41440. */
  41441. set leftTrigger(newValue: number);
  41442. /**
  41443. * Gets the right trigger value
  41444. */
  41445. get rightTrigger(): number;
  41446. /**
  41447. * Sets the right trigger value
  41448. */
  41449. set rightTrigger(newValue: number);
  41450. /**
  41451. * Defines the callback to call when a button is pressed
  41452. * @param callback defines the callback to use
  41453. */
  41454. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41455. /**
  41456. * Defines the callback to call when a button is released
  41457. * @param callback defines the callback to use
  41458. */
  41459. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41460. /**
  41461. * Defines the callback to call when a pad is pressed
  41462. * @param callback defines the callback to use
  41463. */
  41464. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41465. /**
  41466. * Defines the callback to call when a pad is released
  41467. * @param callback defines the callback to use
  41468. */
  41469. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41470. private _setButtonValue;
  41471. private _setDPadValue;
  41472. /**
  41473. * Gets the value of the `Cross` button
  41474. */
  41475. get buttonCross(): number;
  41476. /**
  41477. * Sets the value of the `Cross` button
  41478. */
  41479. set buttonCross(value: number);
  41480. /**
  41481. * Gets the value of the `Circle` button
  41482. */
  41483. get buttonCircle(): number;
  41484. /**
  41485. * Sets the value of the `Circle` button
  41486. */
  41487. set buttonCircle(value: number);
  41488. /**
  41489. * Gets the value of the `Square` button
  41490. */
  41491. get buttonSquare(): number;
  41492. /**
  41493. * Sets the value of the `Square` button
  41494. */
  41495. set buttonSquare(value: number);
  41496. /**
  41497. * Gets the value of the `Triangle` button
  41498. */
  41499. get buttonTriangle(): number;
  41500. /**
  41501. * Sets the value of the `Triangle` button
  41502. */
  41503. set buttonTriangle(value: number);
  41504. /**
  41505. * Gets the value of the `Options` button
  41506. */
  41507. get buttonOptions(): number;
  41508. /**
  41509. * Sets the value of the `Options` button
  41510. */
  41511. set buttonOptions(value: number);
  41512. /**
  41513. * Gets the value of the `Share` button
  41514. */
  41515. get buttonShare(): number;
  41516. /**
  41517. * Sets the value of the `Share` button
  41518. */
  41519. set buttonShare(value: number);
  41520. /**
  41521. * Gets the value of the `L1` button
  41522. */
  41523. get buttonL1(): number;
  41524. /**
  41525. * Sets the value of the `L1` button
  41526. */
  41527. set buttonL1(value: number);
  41528. /**
  41529. * Gets the value of the `R1` button
  41530. */
  41531. get buttonR1(): number;
  41532. /**
  41533. * Sets the value of the `R1` button
  41534. */
  41535. set buttonR1(value: number);
  41536. /**
  41537. * Gets the value of the Left joystick
  41538. */
  41539. get buttonLeftStick(): number;
  41540. /**
  41541. * Sets the value of the Left joystick
  41542. */
  41543. set buttonLeftStick(value: number);
  41544. /**
  41545. * Gets the value of the Right joystick
  41546. */
  41547. get buttonRightStick(): number;
  41548. /**
  41549. * Sets the value of the Right joystick
  41550. */
  41551. set buttonRightStick(value: number);
  41552. /**
  41553. * Gets the value of D-pad up
  41554. */
  41555. get dPadUp(): number;
  41556. /**
  41557. * Sets the value of D-pad up
  41558. */
  41559. set dPadUp(value: number);
  41560. /**
  41561. * Gets the value of D-pad down
  41562. */
  41563. get dPadDown(): number;
  41564. /**
  41565. * Sets the value of D-pad down
  41566. */
  41567. set dPadDown(value: number);
  41568. /**
  41569. * Gets the value of D-pad left
  41570. */
  41571. get dPadLeft(): number;
  41572. /**
  41573. * Sets the value of D-pad left
  41574. */
  41575. set dPadLeft(value: number);
  41576. /**
  41577. * Gets the value of D-pad right
  41578. */
  41579. get dPadRight(): number;
  41580. /**
  41581. * Sets the value of D-pad right
  41582. */
  41583. set dPadRight(value: number);
  41584. /**
  41585. * Force the gamepad to synchronize with device values
  41586. */
  41587. update(): void;
  41588. /**
  41589. * Disposes the gamepad
  41590. */
  41591. dispose(): void;
  41592. }
  41593. }
  41594. declare module BABYLON {
  41595. /**
  41596. * Manager for handling gamepads
  41597. */
  41598. export class GamepadManager {
  41599. private _scene?;
  41600. private _babylonGamepads;
  41601. private _oneGamepadConnected;
  41602. /** @hidden */
  41603. _isMonitoring: boolean;
  41604. private _gamepadEventSupported;
  41605. private _gamepadSupport?;
  41606. /**
  41607. * observable to be triggered when the gamepad controller has been connected
  41608. */
  41609. onGamepadConnectedObservable: Observable<Gamepad>;
  41610. /**
  41611. * observable to be triggered when the gamepad controller has been disconnected
  41612. */
  41613. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41614. private _onGamepadConnectedEvent;
  41615. private _onGamepadDisconnectedEvent;
  41616. /**
  41617. * Initializes the gamepad manager
  41618. * @param _scene BabylonJS scene
  41619. */
  41620. constructor(_scene?: Scene | undefined);
  41621. /**
  41622. * The gamepads in the game pad manager
  41623. */
  41624. get gamepads(): Gamepad[];
  41625. /**
  41626. * Get the gamepad controllers based on type
  41627. * @param type The type of gamepad controller
  41628. * @returns Nullable gamepad
  41629. */
  41630. getGamepadByType(type?: number): Nullable<Gamepad>;
  41631. /**
  41632. * Disposes the gamepad manager
  41633. */
  41634. dispose(): void;
  41635. private _addNewGamepad;
  41636. private _startMonitoringGamepads;
  41637. private _stopMonitoringGamepads;
  41638. /** @hidden */
  41639. _checkGamepadsStatus(): void;
  41640. private _updateGamepadObjects;
  41641. }
  41642. }
  41643. declare module BABYLON {
  41644. interface Scene {
  41645. /** @hidden */
  41646. _gamepadManager: Nullable<GamepadManager>;
  41647. /**
  41648. * Gets the gamepad manager associated with the scene
  41649. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41650. */
  41651. gamepadManager: GamepadManager;
  41652. }
  41653. /**
  41654. * Interface representing a free camera inputs manager
  41655. */
  41656. interface FreeCameraInputsManager {
  41657. /**
  41658. * Adds gamepad input support to the FreeCameraInputsManager.
  41659. * @returns the FreeCameraInputsManager
  41660. */
  41661. addGamepad(): FreeCameraInputsManager;
  41662. }
  41663. /**
  41664. * Interface representing an arc rotate camera inputs manager
  41665. */
  41666. interface ArcRotateCameraInputsManager {
  41667. /**
  41668. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41669. * @returns the camera inputs manager
  41670. */
  41671. addGamepad(): ArcRotateCameraInputsManager;
  41672. }
  41673. /**
  41674. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41675. */
  41676. export class GamepadSystemSceneComponent implements ISceneComponent {
  41677. /**
  41678. * The component name helpfull to identify the component in the list of scene components.
  41679. */
  41680. readonly name: string;
  41681. /**
  41682. * The scene the component belongs to.
  41683. */
  41684. scene: Scene;
  41685. /**
  41686. * Creates a new instance of the component for the given scene
  41687. * @param scene Defines the scene to register the component in
  41688. */
  41689. constructor(scene: Scene);
  41690. /**
  41691. * Registers the component in a given scene
  41692. */
  41693. register(): void;
  41694. /**
  41695. * Rebuilds the elements related to this component in case of
  41696. * context lost for instance.
  41697. */
  41698. rebuild(): void;
  41699. /**
  41700. * Disposes the component and the associated ressources
  41701. */
  41702. dispose(): void;
  41703. private _beforeCameraUpdate;
  41704. }
  41705. }
  41706. declare module BABYLON {
  41707. /**
  41708. * 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,
  41709. * which still works and will still be found in many Playgrounds.
  41710. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41711. */
  41712. export class UniversalCamera extends TouchCamera {
  41713. /**
  41714. * Defines the gamepad rotation sensiblity.
  41715. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41716. */
  41717. get gamepadAngularSensibility(): number;
  41718. set gamepadAngularSensibility(value: number);
  41719. /**
  41720. * Defines the gamepad move sensiblity.
  41721. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41722. */
  41723. get gamepadMoveSensibility(): number;
  41724. set gamepadMoveSensibility(value: number);
  41725. /**
  41726. * 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,
  41727. * which still works and will still be found in many Playgrounds.
  41728. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41729. * @param name Define the name of the camera in the scene
  41730. * @param position Define the start position of the camera in the scene
  41731. * @param scene Define the scene the camera belongs to
  41732. */
  41733. constructor(name: string, position: Vector3, scene: Scene);
  41734. /**
  41735. * Gets the current object class name.
  41736. * @return the class name
  41737. */
  41738. getClassName(): string;
  41739. }
  41740. }
  41741. declare module BABYLON {
  41742. /**
  41743. * This represents a FPS type of camera. This is only here for back compat purpose.
  41744. * Please use the UniversalCamera instead as both are identical.
  41745. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41746. */
  41747. export class GamepadCamera extends UniversalCamera {
  41748. /**
  41749. * Instantiates a new Gamepad Camera
  41750. * This represents a FPS type of camera. This is only here for back compat purpose.
  41751. * Please use the UniversalCamera instead as both are identical.
  41752. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41753. * @param name Define the name of the camera in the scene
  41754. * @param position Define the start position of the camera in the scene
  41755. * @param scene Define the scene the camera belongs to
  41756. */
  41757. constructor(name: string, position: Vector3, scene: Scene);
  41758. /**
  41759. * Gets the current object class name.
  41760. * @return the class name
  41761. */
  41762. getClassName(): string;
  41763. }
  41764. }
  41765. declare module BABYLON {
  41766. /** @hidden */
  41767. export var passPixelShader: {
  41768. name: string;
  41769. shader: string;
  41770. };
  41771. }
  41772. declare module BABYLON {
  41773. /** @hidden */
  41774. export var passCubePixelShader: {
  41775. name: string;
  41776. shader: string;
  41777. };
  41778. }
  41779. declare module BABYLON {
  41780. /**
  41781. * PassPostProcess which produces an output the same as it's input
  41782. */
  41783. export class PassPostProcess extends PostProcess {
  41784. /**
  41785. * Creates the PassPostProcess
  41786. * @param name The name of the effect.
  41787. * @param options The required width/height ratio to downsize to before computing the render pass.
  41788. * @param camera The camera to apply the render pass to.
  41789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41790. * @param engine The engine which the post process will be applied. (default: current engine)
  41791. * @param reusable If the post process can be reused on the same frame. (default: false)
  41792. * @param textureType The type of texture to be used when performing the post processing.
  41793. * @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)
  41794. */
  41795. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41796. }
  41797. /**
  41798. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41799. */
  41800. export class PassCubePostProcess extends PostProcess {
  41801. private _face;
  41802. /**
  41803. * Gets or sets the cube face to display.
  41804. * * 0 is +X
  41805. * * 1 is -X
  41806. * * 2 is +Y
  41807. * * 3 is -Y
  41808. * * 4 is +Z
  41809. * * 5 is -Z
  41810. */
  41811. get face(): number;
  41812. set face(value: number);
  41813. /**
  41814. * Creates the PassCubePostProcess
  41815. * @param name The name of the effect.
  41816. * @param options The required width/height ratio to downsize to before computing the render pass.
  41817. * @param camera The camera to apply the render pass to.
  41818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41819. * @param engine The engine which the post process will be applied. (default: current engine)
  41820. * @param reusable If the post process can be reused on the same frame. (default: false)
  41821. * @param textureType The type of texture to be used when performing the post processing.
  41822. * @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)
  41823. */
  41824. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41825. }
  41826. }
  41827. declare module BABYLON {
  41828. /** @hidden */
  41829. export var anaglyphPixelShader: {
  41830. name: string;
  41831. shader: string;
  41832. };
  41833. }
  41834. declare module BABYLON {
  41835. /**
  41836. * Postprocess used to generate anaglyphic rendering
  41837. */
  41838. export class AnaglyphPostProcess extends PostProcess {
  41839. private _passedProcess;
  41840. /**
  41841. * Creates a new AnaglyphPostProcess
  41842. * @param name defines postprocess name
  41843. * @param options defines creation options or target ratio scale
  41844. * @param rigCameras defines cameras using this postprocess
  41845. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41846. * @param engine defines hosting engine
  41847. * @param reusable defines if the postprocess will be reused multiple times per frame
  41848. */
  41849. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41850. }
  41851. }
  41852. declare module BABYLON {
  41853. /**
  41854. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41855. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41856. */
  41857. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41858. /**
  41859. * Creates a new AnaglyphArcRotateCamera
  41860. * @param name defines camera name
  41861. * @param alpha defines alpha angle (in radians)
  41862. * @param beta defines beta angle (in radians)
  41863. * @param radius defines radius
  41864. * @param target defines camera target
  41865. * @param interaxialDistance defines distance between each color axis
  41866. * @param scene defines the hosting scene
  41867. */
  41868. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41869. /**
  41870. * Gets camera class name
  41871. * @returns AnaglyphArcRotateCamera
  41872. */
  41873. getClassName(): string;
  41874. }
  41875. }
  41876. declare module BABYLON {
  41877. /**
  41878. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41879. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41880. */
  41881. export class AnaglyphFreeCamera extends FreeCamera {
  41882. /**
  41883. * Creates a new AnaglyphFreeCamera
  41884. * @param name defines camera name
  41885. * @param position defines initial position
  41886. * @param interaxialDistance defines distance between each color axis
  41887. * @param scene defines the hosting scene
  41888. */
  41889. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41890. /**
  41891. * Gets camera class name
  41892. * @returns AnaglyphFreeCamera
  41893. */
  41894. getClassName(): string;
  41895. }
  41896. }
  41897. declare module BABYLON {
  41898. /**
  41899. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41900. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41901. */
  41902. export class AnaglyphGamepadCamera extends GamepadCamera {
  41903. /**
  41904. * Creates a new AnaglyphGamepadCamera
  41905. * @param name defines camera name
  41906. * @param position defines initial position
  41907. * @param interaxialDistance defines distance between each color axis
  41908. * @param scene defines the hosting scene
  41909. */
  41910. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41911. /**
  41912. * Gets camera class name
  41913. * @returns AnaglyphGamepadCamera
  41914. */
  41915. getClassName(): string;
  41916. }
  41917. }
  41918. declare module BABYLON {
  41919. /**
  41920. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41921. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41922. */
  41923. export class AnaglyphUniversalCamera extends UniversalCamera {
  41924. /**
  41925. * Creates a new AnaglyphUniversalCamera
  41926. * @param name defines camera name
  41927. * @param position defines initial position
  41928. * @param interaxialDistance defines distance between each color axis
  41929. * @param scene defines the hosting scene
  41930. */
  41931. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41932. /**
  41933. * Gets camera class name
  41934. * @returns AnaglyphUniversalCamera
  41935. */
  41936. getClassName(): string;
  41937. }
  41938. }
  41939. declare module BABYLON {
  41940. /** @hidden */
  41941. export var stereoscopicInterlacePixelShader: {
  41942. name: string;
  41943. shader: string;
  41944. };
  41945. }
  41946. declare module BABYLON {
  41947. /**
  41948. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41949. */
  41950. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41951. private _stepSize;
  41952. private _passedProcess;
  41953. /**
  41954. * Initializes a StereoscopicInterlacePostProcessI
  41955. * @param name The name of the effect.
  41956. * @param rigCameras The rig cameras to be appled to the post process
  41957. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41958. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41960. * @param engine The engine which the post process will be applied. (default: current engine)
  41961. * @param reusable If the post process can be reused on the same frame. (default: false)
  41962. */
  41963. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41964. }
  41965. /**
  41966. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41967. */
  41968. export class StereoscopicInterlacePostProcess extends PostProcess {
  41969. private _stepSize;
  41970. private _passedProcess;
  41971. /**
  41972. * Initializes a StereoscopicInterlacePostProcess
  41973. * @param name The name of the effect.
  41974. * @param rigCameras The rig cameras to be appled to the post process
  41975. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41977. * @param engine The engine which the post process will be applied. (default: current engine)
  41978. * @param reusable If the post process can be reused on the same frame. (default: false)
  41979. */
  41980. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41981. }
  41982. }
  41983. declare module BABYLON {
  41984. /**
  41985. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41986. * @see http://doc.babylonjs.com/features/cameras
  41987. */
  41988. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41989. /**
  41990. * Creates a new StereoscopicArcRotateCamera
  41991. * @param name defines camera name
  41992. * @param alpha defines alpha angle (in radians)
  41993. * @param beta defines beta angle (in radians)
  41994. * @param radius defines radius
  41995. * @param target defines camera target
  41996. * @param interaxialDistance defines distance between each color axis
  41997. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41998. * @param scene defines the hosting scene
  41999. */
  42000. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42001. /**
  42002. * Gets camera class name
  42003. * @returns StereoscopicArcRotateCamera
  42004. */
  42005. getClassName(): string;
  42006. }
  42007. }
  42008. declare module BABYLON {
  42009. /**
  42010. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42011. * @see http://doc.babylonjs.com/features/cameras
  42012. */
  42013. export class StereoscopicFreeCamera extends FreeCamera {
  42014. /**
  42015. * Creates a new StereoscopicFreeCamera
  42016. * @param name defines camera name
  42017. * @param position defines initial position
  42018. * @param interaxialDistance defines distance between each color axis
  42019. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42020. * @param scene defines the hosting scene
  42021. */
  42022. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42023. /**
  42024. * Gets camera class name
  42025. * @returns StereoscopicFreeCamera
  42026. */
  42027. getClassName(): string;
  42028. }
  42029. }
  42030. declare module BABYLON {
  42031. /**
  42032. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42033. * @see http://doc.babylonjs.com/features/cameras
  42034. */
  42035. export class StereoscopicGamepadCamera extends GamepadCamera {
  42036. /**
  42037. * Creates a new StereoscopicGamepadCamera
  42038. * @param name defines camera name
  42039. * @param position defines initial position
  42040. * @param interaxialDistance defines distance between each color axis
  42041. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42042. * @param scene defines the hosting scene
  42043. */
  42044. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42045. /**
  42046. * Gets camera class name
  42047. * @returns StereoscopicGamepadCamera
  42048. */
  42049. getClassName(): string;
  42050. }
  42051. }
  42052. declare module BABYLON {
  42053. /**
  42054. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42055. * @see http://doc.babylonjs.com/features/cameras
  42056. */
  42057. export class StereoscopicUniversalCamera extends UniversalCamera {
  42058. /**
  42059. * Creates a new StereoscopicUniversalCamera
  42060. * @param name defines camera name
  42061. * @param position defines initial position
  42062. * @param interaxialDistance defines distance between each color axis
  42063. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42064. * @param scene defines the hosting scene
  42065. */
  42066. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42067. /**
  42068. * Gets camera class name
  42069. * @returns StereoscopicUniversalCamera
  42070. */
  42071. getClassName(): string;
  42072. }
  42073. }
  42074. declare module BABYLON {
  42075. /**
  42076. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42077. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42078. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42079. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42080. */
  42081. export class VirtualJoysticksCamera extends FreeCamera {
  42082. /**
  42083. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42084. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42085. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42086. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42087. * @param name Define the name of the camera in the scene
  42088. * @param position Define the start position of the camera in the scene
  42089. * @param scene Define the scene the camera belongs to
  42090. */
  42091. constructor(name: string, position: Vector3, scene: Scene);
  42092. /**
  42093. * Gets the current object class name.
  42094. * @return the class name
  42095. */
  42096. getClassName(): string;
  42097. }
  42098. }
  42099. declare module BABYLON {
  42100. /**
  42101. * This represents all the required metrics to create a VR camera.
  42102. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42103. */
  42104. export class VRCameraMetrics {
  42105. /**
  42106. * Define the horizontal resolution off the screen.
  42107. */
  42108. hResolution: number;
  42109. /**
  42110. * Define the vertical resolution off the screen.
  42111. */
  42112. vResolution: number;
  42113. /**
  42114. * Define the horizontal screen size.
  42115. */
  42116. hScreenSize: number;
  42117. /**
  42118. * Define the vertical screen size.
  42119. */
  42120. vScreenSize: number;
  42121. /**
  42122. * Define the vertical screen center position.
  42123. */
  42124. vScreenCenter: number;
  42125. /**
  42126. * Define the distance of the eyes to the screen.
  42127. */
  42128. eyeToScreenDistance: number;
  42129. /**
  42130. * Define the distance between both lenses
  42131. */
  42132. lensSeparationDistance: number;
  42133. /**
  42134. * Define the distance between both viewer's eyes.
  42135. */
  42136. interpupillaryDistance: number;
  42137. /**
  42138. * Define the distortion factor of the VR postprocess.
  42139. * Please, touch with care.
  42140. */
  42141. distortionK: number[];
  42142. /**
  42143. * Define the chromatic aberration correction factors for the VR post process.
  42144. */
  42145. chromaAbCorrection: number[];
  42146. /**
  42147. * Define the scale factor of the post process.
  42148. * The smaller the better but the slower.
  42149. */
  42150. postProcessScaleFactor: number;
  42151. /**
  42152. * Define an offset for the lens center.
  42153. */
  42154. lensCenterOffset: number;
  42155. /**
  42156. * Define if the current vr camera should compensate the distortion of the lense or not.
  42157. */
  42158. compensateDistortion: boolean;
  42159. /**
  42160. * Defines if multiview should be enabled when rendering (Default: false)
  42161. */
  42162. multiviewEnabled: boolean;
  42163. /**
  42164. * Gets the rendering aspect ratio based on the provided resolutions.
  42165. */
  42166. get aspectRatio(): number;
  42167. /**
  42168. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42169. */
  42170. get aspectRatioFov(): number;
  42171. /**
  42172. * @hidden
  42173. */
  42174. get leftHMatrix(): Matrix;
  42175. /**
  42176. * @hidden
  42177. */
  42178. get rightHMatrix(): Matrix;
  42179. /**
  42180. * @hidden
  42181. */
  42182. get leftPreViewMatrix(): Matrix;
  42183. /**
  42184. * @hidden
  42185. */
  42186. get rightPreViewMatrix(): Matrix;
  42187. /**
  42188. * Get the default VRMetrics based on the most generic setup.
  42189. * @returns the default vr metrics
  42190. */
  42191. static GetDefault(): VRCameraMetrics;
  42192. }
  42193. }
  42194. declare module BABYLON {
  42195. /** @hidden */
  42196. export var vrDistortionCorrectionPixelShader: {
  42197. name: string;
  42198. shader: string;
  42199. };
  42200. }
  42201. declare module BABYLON {
  42202. /**
  42203. * VRDistortionCorrectionPostProcess used for mobile VR
  42204. */
  42205. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42206. private _isRightEye;
  42207. private _distortionFactors;
  42208. private _postProcessScaleFactor;
  42209. private _lensCenterOffset;
  42210. private _scaleIn;
  42211. private _scaleFactor;
  42212. private _lensCenter;
  42213. /**
  42214. * Initializes the VRDistortionCorrectionPostProcess
  42215. * @param name The name of the effect.
  42216. * @param camera The camera to apply the render pass to.
  42217. * @param isRightEye If this is for the right eye distortion
  42218. * @param vrMetrics All the required metrics for the VR camera
  42219. */
  42220. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42221. }
  42222. }
  42223. declare module BABYLON {
  42224. /**
  42225. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42226. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42227. */
  42228. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42229. /**
  42230. * Creates a new VRDeviceOrientationArcRotateCamera
  42231. * @param name defines camera name
  42232. * @param alpha defines the camera rotation along the logitudinal axis
  42233. * @param beta defines the camera rotation along the latitudinal axis
  42234. * @param radius defines the camera distance from its target
  42235. * @param target defines the camera target
  42236. * @param scene defines the scene the camera belongs to
  42237. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42238. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42239. */
  42240. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42241. /**
  42242. * Gets camera class name
  42243. * @returns VRDeviceOrientationArcRotateCamera
  42244. */
  42245. getClassName(): string;
  42246. }
  42247. }
  42248. declare module BABYLON {
  42249. /**
  42250. * Camera used to simulate VR rendering (based on FreeCamera)
  42251. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42252. */
  42253. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42254. /**
  42255. * Creates a new VRDeviceOrientationFreeCamera
  42256. * @param name defines camera name
  42257. * @param position defines the start position of the camera
  42258. * @param scene defines the scene the camera belongs to
  42259. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42260. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42261. */
  42262. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42263. /**
  42264. * Gets camera class name
  42265. * @returns VRDeviceOrientationFreeCamera
  42266. */
  42267. getClassName(): string;
  42268. }
  42269. }
  42270. declare module BABYLON {
  42271. /**
  42272. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42273. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42274. */
  42275. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42276. /**
  42277. * Creates a new VRDeviceOrientationGamepadCamera
  42278. * @param name defines camera name
  42279. * @param position defines the start position of the camera
  42280. * @param scene defines the scene the camera belongs to
  42281. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42282. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42283. */
  42284. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42285. /**
  42286. * Gets camera class name
  42287. * @returns VRDeviceOrientationGamepadCamera
  42288. */
  42289. getClassName(): string;
  42290. }
  42291. }
  42292. declare module BABYLON {
  42293. /** @hidden */
  42294. export var imageProcessingPixelShader: {
  42295. name: string;
  42296. shader: string;
  42297. };
  42298. }
  42299. declare module BABYLON {
  42300. /**
  42301. * ImageProcessingPostProcess
  42302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42303. */
  42304. export class ImageProcessingPostProcess extends PostProcess {
  42305. /**
  42306. * Default configuration related to image processing available in the PBR Material.
  42307. */
  42308. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42309. /**
  42310. * Gets the image processing configuration used either in this material.
  42311. */
  42312. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42313. /**
  42314. * Sets the Default image processing configuration used either in the this material.
  42315. *
  42316. * If sets to null, the scene one is in use.
  42317. */
  42318. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42319. /**
  42320. * Keep track of the image processing observer to allow dispose and replace.
  42321. */
  42322. private _imageProcessingObserver;
  42323. /**
  42324. * Attaches a new image processing configuration to the PBR Material.
  42325. * @param configuration
  42326. */
  42327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42328. /**
  42329. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42330. */
  42331. get colorCurves(): Nullable<ColorCurves>;
  42332. /**
  42333. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42334. */
  42335. set colorCurves(value: Nullable<ColorCurves>);
  42336. /**
  42337. * Gets wether the color curves effect is enabled.
  42338. */
  42339. get colorCurvesEnabled(): boolean;
  42340. /**
  42341. * Sets wether the color curves effect is enabled.
  42342. */
  42343. set colorCurvesEnabled(value: boolean);
  42344. /**
  42345. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42346. */
  42347. get colorGradingTexture(): Nullable<BaseTexture>;
  42348. /**
  42349. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42350. */
  42351. set colorGradingTexture(value: Nullable<BaseTexture>);
  42352. /**
  42353. * Gets wether the color grading effect is enabled.
  42354. */
  42355. get colorGradingEnabled(): boolean;
  42356. /**
  42357. * Gets wether the color grading effect is enabled.
  42358. */
  42359. set colorGradingEnabled(value: boolean);
  42360. /**
  42361. * Gets exposure used in the effect.
  42362. */
  42363. get exposure(): number;
  42364. /**
  42365. * Sets exposure used in the effect.
  42366. */
  42367. set exposure(value: number);
  42368. /**
  42369. * Gets wether tonemapping is enabled or not.
  42370. */
  42371. get toneMappingEnabled(): boolean;
  42372. /**
  42373. * Sets wether tonemapping is enabled or not
  42374. */
  42375. set toneMappingEnabled(value: boolean);
  42376. /**
  42377. * Gets the type of tone mapping effect.
  42378. */
  42379. get toneMappingType(): number;
  42380. /**
  42381. * Sets the type of tone mapping effect.
  42382. */
  42383. set toneMappingType(value: number);
  42384. /**
  42385. * Gets contrast used in the effect.
  42386. */
  42387. get contrast(): number;
  42388. /**
  42389. * Sets contrast used in the effect.
  42390. */
  42391. set contrast(value: number);
  42392. /**
  42393. * Gets Vignette stretch size.
  42394. */
  42395. get vignetteStretch(): number;
  42396. /**
  42397. * Sets Vignette stretch size.
  42398. */
  42399. set vignetteStretch(value: number);
  42400. /**
  42401. * Gets Vignette centre X Offset.
  42402. */
  42403. get vignetteCentreX(): number;
  42404. /**
  42405. * Sets Vignette centre X Offset.
  42406. */
  42407. set vignetteCentreX(value: number);
  42408. /**
  42409. * Gets Vignette centre Y Offset.
  42410. */
  42411. get vignetteCentreY(): number;
  42412. /**
  42413. * Sets Vignette centre Y Offset.
  42414. */
  42415. set vignetteCentreY(value: number);
  42416. /**
  42417. * Gets Vignette weight or intensity of the vignette effect.
  42418. */
  42419. get vignetteWeight(): number;
  42420. /**
  42421. * Sets Vignette weight or intensity of the vignette effect.
  42422. */
  42423. set vignetteWeight(value: number);
  42424. /**
  42425. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42426. * if vignetteEnabled is set to true.
  42427. */
  42428. get vignetteColor(): Color4;
  42429. /**
  42430. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42431. * if vignetteEnabled is set to true.
  42432. */
  42433. set vignetteColor(value: Color4);
  42434. /**
  42435. * Gets Camera field of view used by the Vignette effect.
  42436. */
  42437. get vignetteCameraFov(): number;
  42438. /**
  42439. * Sets Camera field of view used by the Vignette effect.
  42440. */
  42441. set vignetteCameraFov(value: number);
  42442. /**
  42443. * Gets the vignette blend mode allowing different kind of effect.
  42444. */
  42445. get vignetteBlendMode(): number;
  42446. /**
  42447. * Sets the vignette blend mode allowing different kind of effect.
  42448. */
  42449. set vignetteBlendMode(value: number);
  42450. /**
  42451. * Gets wether the vignette effect is enabled.
  42452. */
  42453. get vignetteEnabled(): boolean;
  42454. /**
  42455. * Sets wether the vignette effect is enabled.
  42456. */
  42457. set vignetteEnabled(value: boolean);
  42458. private _fromLinearSpace;
  42459. /**
  42460. * Gets wether the input of the processing is in Gamma or Linear Space.
  42461. */
  42462. get fromLinearSpace(): boolean;
  42463. /**
  42464. * Sets wether the input of the processing is in Gamma or Linear Space.
  42465. */
  42466. set fromLinearSpace(value: boolean);
  42467. /**
  42468. * Defines cache preventing GC.
  42469. */
  42470. private _defines;
  42471. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42472. /**
  42473. * "ImageProcessingPostProcess"
  42474. * @returns "ImageProcessingPostProcess"
  42475. */
  42476. getClassName(): string;
  42477. protected _updateParameters(): void;
  42478. dispose(camera?: Camera): void;
  42479. }
  42480. }
  42481. declare module BABYLON {
  42482. /**
  42483. * Class containing static functions to help procedurally build meshes
  42484. */
  42485. export class GroundBuilder {
  42486. /**
  42487. * Creates a ground mesh
  42488. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42489. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42491. * @param name defines the name of the mesh
  42492. * @param options defines the options used to create the mesh
  42493. * @param scene defines the hosting scene
  42494. * @returns the ground mesh
  42495. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42496. */
  42497. static CreateGround(name: string, options: {
  42498. width?: number;
  42499. height?: number;
  42500. subdivisions?: number;
  42501. subdivisionsX?: number;
  42502. subdivisionsY?: number;
  42503. updatable?: boolean;
  42504. }, scene: any): Mesh;
  42505. /**
  42506. * Creates a tiled ground mesh
  42507. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42508. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42509. * * 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
  42510. * * 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
  42511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42512. * @param name defines the name of the mesh
  42513. * @param options defines the options used to create the mesh
  42514. * @param scene defines the hosting scene
  42515. * @returns the tiled ground mesh
  42516. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42517. */
  42518. static CreateTiledGround(name: string, options: {
  42519. xmin: number;
  42520. zmin: number;
  42521. xmax: number;
  42522. zmax: number;
  42523. subdivisions?: {
  42524. w: number;
  42525. h: number;
  42526. };
  42527. precision?: {
  42528. w: number;
  42529. h: number;
  42530. };
  42531. updatable?: boolean;
  42532. }, scene?: Nullable<Scene>): Mesh;
  42533. /**
  42534. * Creates a ground mesh from a height map
  42535. * * The parameter `url` sets the URL of the height map image resource.
  42536. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42537. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42538. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42539. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42540. * * 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.
  42541. * * 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).
  42542. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42544. * @param name defines the name of the mesh
  42545. * @param url defines the url to the height map
  42546. * @param options defines the options used to create the mesh
  42547. * @param scene defines the hosting scene
  42548. * @returns the ground mesh
  42549. * @see https://doc.babylonjs.com/babylon101/height_map
  42550. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42551. */
  42552. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42553. width?: number;
  42554. height?: number;
  42555. subdivisions?: number;
  42556. minHeight?: number;
  42557. maxHeight?: number;
  42558. colorFilter?: Color3;
  42559. alphaFilter?: number;
  42560. updatable?: boolean;
  42561. onReady?: (mesh: GroundMesh) => void;
  42562. }, scene?: Nullable<Scene>): GroundMesh;
  42563. }
  42564. }
  42565. declare module BABYLON {
  42566. /**
  42567. * Class containing static functions to help procedurally build meshes
  42568. */
  42569. export class TorusBuilder {
  42570. /**
  42571. * Creates a torus mesh
  42572. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42573. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42574. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42576. * * 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
  42577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42578. * @param name defines the name of the mesh
  42579. * @param options defines the options used to create the mesh
  42580. * @param scene defines the hosting scene
  42581. * @returns the torus mesh
  42582. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42583. */
  42584. static CreateTorus(name: string, options: {
  42585. diameter?: number;
  42586. thickness?: number;
  42587. tessellation?: number;
  42588. updatable?: boolean;
  42589. sideOrientation?: number;
  42590. frontUVs?: Vector4;
  42591. backUVs?: Vector4;
  42592. }, scene: any): Mesh;
  42593. }
  42594. }
  42595. declare module BABYLON {
  42596. /**
  42597. * Class containing static functions to help procedurally build meshes
  42598. */
  42599. export class CylinderBuilder {
  42600. /**
  42601. * Creates a cylinder or a cone mesh
  42602. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42603. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42604. * * 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.
  42605. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42606. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42607. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42608. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42609. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  42610. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42611. * * 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).
  42612. * * 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
  42613. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42614. * * 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
  42615. * * 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.
  42616. * * If `enclose` is false, a ring surface is one element.
  42617. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42618. * * 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
  42619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42620. * * 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
  42621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42622. * @param name defines the name of the mesh
  42623. * @param options defines the options used to create the mesh
  42624. * @param scene defines the hosting scene
  42625. * @returns the cylinder mesh
  42626. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42627. */
  42628. static CreateCylinder(name: string, options: {
  42629. height?: number;
  42630. diameterTop?: number;
  42631. diameterBottom?: number;
  42632. diameter?: number;
  42633. tessellation?: number;
  42634. subdivisions?: number;
  42635. arc?: number;
  42636. faceColors?: Color4[];
  42637. faceUV?: Vector4[];
  42638. updatable?: boolean;
  42639. hasRings?: boolean;
  42640. enclose?: boolean;
  42641. cap?: number;
  42642. sideOrientation?: number;
  42643. frontUVs?: Vector4;
  42644. backUVs?: Vector4;
  42645. }, scene: any): Mesh;
  42646. }
  42647. }
  42648. declare module BABYLON {
  42649. /**
  42650. * States of the webXR experience
  42651. */
  42652. export enum WebXRState {
  42653. /**
  42654. * Transitioning to being in XR mode
  42655. */
  42656. ENTERING_XR = 0,
  42657. /**
  42658. * Transitioning to non XR mode
  42659. */
  42660. EXITING_XR = 1,
  42661. /**
  42662. * In XR mode and presenting
  42663. */
  42664. IN_XR = 2,
  42665. /**
  42666. * Not entered XR mode
  42667. */
  42668. NOT_IN_XR = 3
  42669. }
  42670. /**
  42671. * Abstraction of the XR render target
  42672. */
  42673. export interface WebXRRenderTarget extends IDisposable {
  42674. /**
  42675. * xrpresent context of the canvas which can be used to display/mirror xr content
  42676. */
  42677. canvasContext: WebGLRenderingContext;
  42678. /**
  42679. * xr layer for the canvas
  42680. */
  42681. xrLayer: Nullable<XRWebGLLayer>;
  42682. /**
  42683. * Initializes the xr layer for the session
  42684. * @param xrSession xr session
  42685. * @returns a promise that will resolve once the XR Layer has been created
  42686. */
  42687. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42688. }
  42689. }
  42690. declare module BABYLON {
  42691. /**
  42692. * COnfiguration object for WebXR output canvas
  42693. */
  42694. export class WebXRManagedOutputCanvasOptions {
  42695. /**
  42696. * An optional canvas in case you wish to create it yourself and provide it here.
  42697. * If not provided, a new canvas will be created
  42698. */
  42699. canvasElement?: HTMLCanvasElement;
  42700. /**
  42701. * Options for this XR Layer output
  42702. */
  42703. canvasOptions?: XRWebGLLayerOptions;
  42704. /**
  42705. * CSS styling for a newly created canvas (if not provided)
  42706. */
  42707. newCanvasCssStyle?: string;
  42708. /**
  42709. * Get the default values of the configuration object
  42710. * @returns default values of this configuration object
  42711. */
  42712. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42713. }
  42714. /**
  42715. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42716. */
  42717. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42718. private _options;
  42719. private _canvas;
  42720. private _engine;
  42721. /**
  42722. * Rendering context of the canvas which can be used to display/mirror xr content
  42723. */
  42724. canvasContext: WebGLRenderingContext;
  42725. /**
  42726. * xr layer for the canvas
  42727. */
  42728. xrLayer: Nullable<XRWebGLLayer>;
  42729. /**
  42730. * Initializes the canvas to be added/removed upon entering/exiting xr
  42731. * @param _xrSessionManager The XR Session manager
  42732. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42733. */
  42734. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42735. /**
  42736. * Disposes of the object
  42737. */
  42738. dispose(): void;
  42739. /**
  42740. * Initializes the xr layer for the session
  42741. * @param xrSession xr session
  42742. * @returns a promise that will resolve once the XR Layer has been created
  42743. */
  42744. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42745. private _addCanvas;
  42746. private _removeCanvas;
  42747. private _setManagedOutputCanvas;
  42748. }
  42749. }
  42750. declare module BABYLON {
  42751. /**
  42752. * Manages an XRSession to work with Babylon's engine
  42753. * @see https://doc.babylonjs.com/how_to/webxr
  42754. */
  42755. export class WebXRSessionManager implements IDisposable {
  42756. /** The scene which the session should be created for */
  42757. scene: Scene;
  42758. private _referenceSpace;
  42759. private _rttProvider;
  42760. private _sessionEnded;
  42761. private _xrNavigator;
  42762. private baseLayer;
  42763. /**
  42764. * The base reference space from which the session started. good if you want to reset your
  42765. * reference space
  42766. */
  42767. baseReferenceSpace: XRReferenceSpace;
  42768. /**
  42769. * Current XR frame
  42770. */
  42771. currentFrame: Nullable<XRFrame>;
  42772. /** WebXR timestamp updated every frame */
  42773. currentTimestamp: number;
  42774. /**
  42775. * Used just in case of a failure to initialize an immersive session.
  42776. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42777. */
  42778. defaultHeightCompensation: number;
  42779. /**
  42780. * Fires every time a new xrFrame arrives which can be used to update the camera
  42781. */
  42782. onXRFrameObservable: Observable<XRFrame>;
  42783. /**
  42784. * Fires when the reference space changed
  42785. */
  42786. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42787. /**
  42788. * Fires when the xr session is ended either by the device or manually done
  42789. */
  42790. onXRSessionEnded: Observable<any>;
  42791. /**
  42792. * Fires when the xr session is ended either by the device or manually done
  42793. */
  42794. onXRSessionInit: Observable<XRSession>;
  42795. /**
  42796. * Underlying xr session
  42797. */
  42798. session: XRSession;
  42799. /**
  42800. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42801. * or get the offset the player is currently at.
  42802. */
  42803. viewerReferenceSpace: XRReferenceSpace;
  42804. /**
  42805. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42806. * @param scene The scene which the session should be created for
  42807. */
  42808. constructor(
  42809. /** The scene which the session should be created for */
  42810. scene: Scene);
  42811. /**
  42812. * The current reference space used in this session. This reference space can constantly change!
  42813. * It is mainly used to offset the camera's position.
  42814. */
  42815. get referenceSpace(): XRReferenceSpace;
  42816. /**
  42817. * Set a new reference space and triggers the observable
  42818. */
  42819. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42820. /**
  42821. * Disposes of the session manager
  42822. */
  42823. dispose(): void;
  42824. /**
  42825. * Stops the xrSession and restores the render loop
  42826. * @returns Promise which resolves after it exits XR
  42827. */
  42828. exitXRAsync(): Promise<void>;
  42829. /**
  42830. * Gets the correct render target texture to be rendered this frame for this eye
  42831. * @param eye the eye for which to get the render target
  42832. * @returns the render target for the specified eye
  42833. */
  42834. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42835. /**
  42836. * Creates a WebXRRenderTarget object for the XR session
  42837. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42838. * @param options optional options to provide when creating a new render target
  42839. * @returns a WebXR render target to which the session can render
  42840. */
  42841. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42842. /**
  42843. * Initializes the manager
  42844. * After initialization enterXR can be called to start an XR session
  42845. * @returns Promise which resolves after it is initialized
  42846. */
  42847. initializeAsync(): Promise<void>;
  42848. /**
  42849. * Initializes an xr session
  42850. * @param xrSessionMode mode to initialize
  42851. * @param xrSessionInit defines optional and required values to pass to the session builder
  42852. * @returns a promise which will resolve once the session has been initialized
  42853. */
  42854. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42855. /**
  42856. * Checks if a session would be supported for the creation options specified
  42857. * @param sessionMode session mode to check if supported eg. immersive-vr
  42858. * @returns A Promise that resolves to true if supported and false if not
  42859. */
  42860. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42861. /**
  42862. * Resets the reference space to the one started the session
  42863. */
  42864. resetReferenceSpace(): void;
  42865. /**
  42866. * Starts rendering to the xr layer
  42867. */
  42868. runXRRenderLoop(): void;
  42869. /**
  42870. * Sets the reference space on the xr session
  42871. * @param referenceSpaceType space to set
  42872. * @returns a promise that will resolve once the reference space has been set
  42873. */
  42874. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42875. /**
  42876. * Updates the render state of the session
  42877. * @param state state to set
  42878. * @returns a promise that resolves once the render state has been updated
  42879. */
  42880. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42881. /**
  42882. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42883. * @param sessionMode defines the session to test
  42884. * @returns a promise with boolean as final value
  42885. */
  42886. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42887. private _createRenderTargetTexture;
  42888. }
  42889. }
  42890. declare module BABYLON {
  42891. /**
  42892. * WebXR Camera which holds the views for the xrSession
  42893. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42894. */
  42895. export class WebXRCamera extends FreeCamera {
  42896. private _xrSessionManager;
  42897. private _firstFrame;
  42898. private _referenceQuaternion;
  42899. private _referencedPosition;
  42900. private _xrInvPositionCache;
  42901. private _xrInvQuaternionCache;
  42902. /**
  42903. * Should position compensation execute on first frame.
  42904. * This is used when copying the position from a native (non XR) camera
  42905. */
  42906. compensateOnFirstFrame: boolean;
  42907. /**
  42908. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42909. * @param name the name of the camera
  42910. * @param scene the scene to add the camera to
  42911. * @param _xrSessionManager a constructed xr session manager
  42912. */
  42913. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42914. /**
  42915. * Return the user's height, unrelated to the current ground.
  42916. * This will be the y position of this camera, when ground level is 0.
  42917. */
  42918. get realWorldHeight(): number;
  42919. /** @hidden */
  42920. _updateForDualEyeDebugging(): void;
  42921. /**
  42922. * Sets this camera's transformation based on a non-vr camera
  42923. * @param otherCamera the non-vr camera to copy the transformation from
  42924. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42925. */
  42926. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42927. /**
  42928. * Gets the current instance class name ("WebXRCamera").
  42929. * @returns the class name
  42930. */
  42931. getClassName(): string;
  42932. private _updateFromXRSession;
  42933. private _updateNumberOfRigCameras;
  42934. private _updateReferenceSpace;
  42935. private _updateReferenceSpaceOffset;
  42936. }
  42937. }
  42938. declare module BABYLON {
  42939. /**
  42940. * Defining the interface required for a (webxr) feature
  42941. */
  42942. export interface IWebXRFeature extends IDisposable {
  42943. /**
  42944. * Is this feature attached
  42945. */
  42946. attached: boolean;
  42947. /**
  42948. * Should auto-attach be disabled?
  42949. */
  42950. disableAutoAttach: boolean;
  42951. /**
  42952. * Attach the feature to the session
  42953. * Will usually be called by the features manager
  42954. *
  42955. * @param force should attachment be forced (even when already attached)
  42956. * @returns true if successful.
  42957. */
  42958. attach(force?: boolean): boolean;
  42959. /**
  42960. * Detach the feature from the session
  42961. * Will usually be called by the features manager
  42962. *
  42963. * @returns true if successful.
  42964. */
  42965. detach(): boolean;
  42966. }
  42967. /**
  42968. * A list of the currently available features without referencing them
  42969. */
  42970. export class WebXRFeatureName {
  42971. /**
  42972. * The name of the anchor system feature
  42973. */
  42974. static ANCHOR_SYSTEM: string;
  42975. /**
  42976. * The name of the background remover feature
  42977. */
  42978. static BACKGROUND_REMOVER: string;
  42979. /**
  42980. * The name of the hit test feature
  42981. */
  42982. static HIT_TEST: string;
  42983. /**
  42984. * physics impostors for xr controllers feature
  42985. */
  42986. static PHYSICS_CONTROLLERS: string;
  42987. /**
  42988. * The name of the plane detection feature
  42989. */
  42990. static PLANE_DETECTION: string;
  42991. /**
  42992. * The name of the pointer selection feature
  42993. */
  42994. static POINTER_SELECTION: string;
  42995. /**
  42996. * The name of the teleportation feature
  42997. */
  42998. static TELEPORTATION: string;
  42999. }
  43000. /**
  43001. * Defining the constructor of a feature. Used to register the modules.
  43002. */
  43003. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43004. /**
  43005. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43006. * It is mainly used in AR sessions.
  43007. *
  43008. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43009. */
  43010. export class WebXRFeaturesManager implements IDisposable {
  43011. private _xrSessionManager;
  43012. private static readonly _AvailableFeatures;
  43013. private _features;
  43014. /**
  43015. * constructs a new features manages.
  43016. *
  43017. * @param _xrSessionManager an instance of WebXRSessionManager
  43018. */
  43019. constructor(_xrSessionManager: WebXRSessionManager);
  43020. /**
  43021. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43022. * Mainly used internally.
  43023. *
  43024. * @param featureName the name of the feature to register
  43025. * @param constructorFunction the function used to construct the module
  43026. * @param version the (babylon) version of the module
  43027. * @param stable is that a stable version of this module
  43028. */
  43029. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43030. /**
  43031. * Returns a constructor of a specific feature.
  43032. *
  43033. * @param featureName the name of the feature to construct
  43034. * @param version the version of the feature to load
  43035. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43036. * @param options optional options provided to the module.
  43037. * @returns a function that, when called, will return a new instance of this feature
  43038. */
  43039. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43040. /**
  43041. * Can be used to return the list of features currently registered
  43042. *
  43043. * @returns an Array of available features
  43044. */
  43045. static GetAvailableFeatures(): string[];
  43046. /**
  43047. * Gets the versions available for a specific feature
  43048. * @param featureName the name of the feature
  43049. * @returns an array with the available versions
  43050. */
  43051. static GetAvailableVersions(featureName: string): string[];
  43052. /**
  43053. * Return the latest unstable version of this feature
  43054. * @param featureName the name of the feature to search
  43055. * @returns the version number. if not found will return -1
  43056. */
  43057. static GetLatestVersionOfFeature(featureName: string): number;
  43058. /**
  43059. * Return the latest stable version of this feature
  43060. * @param featureName the name of the feature to search
  43061. * @returns the version number. if not found will return -1
  43062. */
  43063. static GetStableVersionOfFeature(featureName: string): number;
  43064. /**
  43065. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43066. * Can be used during a session to start a feature
  43067. * @param featureName the name of feature to attach
  43068. */
  43069. attachFeature(featureName: string): void;
  43070. /**
  43071. * Can be used inside a session or when the session ends to detach a specific feature
  43072. * @param featureName the name of the feature to detach
  43073. */
  43074. detachFeature(featureName: string): void;
  43075. /**
  43076. * Used to disable an already-enabled feature
  43077. * The feature will be disposed and will be recreated once enabled.
  43078. * @param featureName the feature to disable
  43079. * @returns true if disable was successful
  43080. */
  43081. disableFeature(featureName: string | {
  43082. Name: string;
  43083. }): boolean;
  43084. /**
  43085. * dispose this features manager
  43086. */
  43087. dispose(): void;
  43088. /**
  43089. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  43090. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  43091. *
  43092. * @param featureName the name of the feature to load or the class of the feature
  43093. * @param version optional version to load. if not provided the latest version will be enabled
  43094. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43095. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43096. * @returns a new constructed feature or throws an error if feature not found.
  43097. */
  43098. enableFeature(featureName: string | {
  43099. Name: string;
  43100. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43101. /**
  43102. * get the implementation of an enabled feature.
  43103. * @param featureName the name of the feature to load
  43104. * @returns the feature class, if found
  43105. */
  43106. getEnabledFeature(featureName: string): IWebXRFeature;
  43107. /**
  43108. * Get the list of enabled features
  43109. * @returns an array of enabled features
  43110. */
  43111. getEnabledFeatures(): string[];
  43112. }
  43113. }
  43114. declare module BABYLON {
  43115. /**
  43116. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43117. * @see https://doc.babylonjs.com/how_to/webxr
  43118. */
  43119. export class WebXRExperienceHelper implements IDisposable {
  43120. private scene;
  43121. private _nonVRCamera;
  43122. private _originalSceneAutoClear;
  43123. private _supported;
  43124. /**
  43125. * Camera used to render xr content
  43126. */
  43127. camera: WebXRCamera;
  43128. /** A features manager for this xr session */
  43129. featuresManager: WebXRFeaturesManager;
  43130. /**
  43131. * Observers registered here will be triggered after the camera's initial transformation is set
  43132. * This can be used to set a different ground level or an extra rotation.
  43133. *
  43134. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43135. * to the position set after this observable is done executing.
  43136. */
  43137. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43138. /**
  43139. * Fires when the state of the experience helper has changed
  43140. */
  43141. onStateChangedObservable: Observable<WebXRState>;
  43142. /** Session manager used to keep track of xr session */
  43143. sessionManager: WebXRSessionManager;
  43144. /**
  43145. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43146. */
  43147. state: WebXRState;
  43148. /**
  43149. * Creates a WebXRExperienceHelper
  43150. * @param scene The scene the helper should be created in
  43151. */
  43152. private constructor();
  43153. /**
  43154. * Creates the experience helper
  43155. * @param scene the scene to attach the experience helper to
  43156. * @returns a promise for the experience helper
  43157. */
  43158. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43159. /**
  43160. * Disposes of the experience helper
  43161. */
  43162. dispose(): void;
  43163. /**
  43164. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43165. * @param sessionMode options for the XR session
  43166. * @param referenceSpaceType frame of reference of the XR session
  43167. * @param renderTarget the output canvas that will be used to enter XR mode
  43168. * @returns promise that resolves after xr mode has entered
  43169. */
  43170. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43171. /**
  43172. * Exits XR mode and returns the scene to its original state
  43173. * @returns promise that resolves after xr mode has exited
  43174. */
  43175. exitXRAsync(): Promise<void>;
  43176. private _nonXRToXRCamera;
  43177. private _setState;
  43178. }
  43179. }
  43180. declare module BABYLON {
  43181. /**
  43182. * X-Y values for axes in WebXR
  43183. */
  43184. export interface IWebXRMotionControllerAxesValue {
  43185. /**
  43186. * The value of the x axis
  43187. */
  43188. x: number;
  43189. /**
  43190. * The value of the y-axis
  43191. */
  43192. y: number;
  43193. }
  43194. /**
  43195. * changed / previous values for the values of this component
  43196. */
  43197. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43198. /**
  43199. * current (this frame) value
  43200. */
  43201. current: T;
  43202. /**
  43203. * previous (last change) value
  43204. */
  43205. previous: T;
  43206. }
  43207. /**
  43208. * Represents changes in the component between current frame and last values recorded
  43209. */
  43210. export interface IWebXRMotionControllerComponentChanges {
  43211. /**
  43212. * will be populated with previous and current values if axes changed
  43213. */
  43214. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43215. /**
  43216. * will be populated with previous and current values if pressed changed
  43217. */
  43218. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43219. /**
  43220. * will be populated with previous and current values if touched changed
  43221. */
  43222. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43223. /**
  43224. * will be populated with previous and current values if value changed
  43225. */
  43226. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43227. }
  43228. /**
  43229. * This class represents a single component (for example button or thumbstick) of a motion controller
  43230. */
  43231. export class WebXRControllerComponent implements IDisposable {
  43232. /**
  43233. * the id of this component
  43234. */
  43235. id: string;
  43236. /**
  43237. * the type of the component
  43238. */
  43239. type: MotionControllerComponentType;
  43240. private _buttonIndex;
  43241. private _axesIndices;
  43242. private _axes;
  43243. private _changes;
  43244. private _currentValue;
  43245. private _hasChanges;
  43246. private _pressed;
  43247. private _touched;
  43248. /**
  43249. * button component type
  43250. */
  43251. static BUTTON_TYPE: MotionControllerComponentType;
  43252. /**
  43253. * squeeze component type
  43254. */
  43255. static SQUEEZE_TYPE: MotionControllerComponentType;
  43256. /**
  43257. * Thumbstick component type
  43258. */
  43259. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43260. /**
  43261. * Touchpad component type
  43262. */
  43263. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43264. /**
  43265. * trigger component type
  43266. */
  43267. static TRIGGER_TYPE: MotionControllerComponentType;
  43268. /**
  43269. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43270. * the axes data changes
  43271. */
  43272. onAxisValueChangedObservable: Observable<{
  43273. x: number;
  43274. y: number;
  43275. }>;
  43276. /**
  43277. * Observers registered here will be triggered when the state of a button changes
  43278. * State change is either pressed / touched / value
  43279. */
  43280. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43281. /**
  43282. * Creates a new component for a motion controller.
  43283. * It is created by the motion controller itself
  43284. *
  43285. * @param id the id of this component
  43286. * @param type the type of the component
  43287. * @param _buttonIndex index in the buttons array of the gamepad
  43288. * @param _axesIndices indices of the values in the axes array of the gamepad
  43289. */
  43290. constructor(
  43291. /**
  43292. * the id of this component
  43293. */
  43294. id: string,
  43295. /**
  43296. * the type of the component
  43297. */
  43298. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43299. /**
  43300. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43301. */
  43302. get axes(): IWebXRMotionControllerAxesValue;
  43303. /**
  43304. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43305. */
  43306. get changes(): IWebXRMotionControllerComponentChanges;
  43307. /**
  43308. * Return whether or not the component changed the last frame
  43309. */
  43310. get hasChanges(): boolean;
  43311. /**
  43312. * is the button currently pressed
  43313. */
  43314. get pressed(): boolean;
  43315. /**
  43316. * is the button currently touched
  43317. */
  43318. get touched(): boolean;
  43319. /**
  43320. * Get the current value of this component
  43321. */
  43322. get value(): number;
  43323. /**
  43324. * Dispose this component
  43325. */
  43326. dispose(): void;
  43327. /**
  43328. * Are there axes correlating to this component
  43329. * @return true is axes data is available
  43330. */
  43331. isAxes(): boolean;
  43332. /**
  43333. * Is this component a button (hence - pressable)
  43334. * @returns true if can be pressed
  43335. */
  43336. isButton(): boolean;
  43337. /**
  43338. * update this component using the gamepad object it is in. Called on every frame
  43339. * @param nativeController the native gamepad controller object
  43340. */
  43341. update(nativeController: IMinimalMotionControllerObject): void;
  43342. }
  43343. }
  43344. declare module BABYLON {
  43345. /**
  43346. * Class used to represent data loading progression
  43347. */
  43348. export class SceneLoaderProgressEvent {
  43349. /** defines if data length to load can be evaluated */
  43350. readonly lengthComputable: boolean;
  43351. /** defines the loaded data length */
  43352. readonly loaded: number;
  43353. /** defines the data length to load */
  43354. readonly total: number;
  43355. /**
  43356. * Create a new progress event
  43357. * @param lengthComputable defines if data length to load can be evaluated
  43358. * @param loaded defines the loaded data length
  43359. * @param total defines the data length to load
  43360. */
  43361. constructor(
  43362. /** defines if data length to load can be evaluated */
  43363. lengthComputable: boolean,
  43364. /** defines the loaded data length */
  43365. loaded: number,
  43366. /** defines the data length to load */
  43367. total: number);
  43368. /**
  43369. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43370. * @param event defines the source event
  43371. * @returns a new SceneLoaderProgressEvent
  43372. */
  43373. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43374. }
  43375. /**
  43376. * Interface used by SceneLoader plugins to define supported file extensions
  43377. */
  43378. export interface ISceneLoaderPluginExtensions {
  43379. /**
  43380. * Defines the list of supported extensions
  43381. */
  43382. [extension: string]: {
  43383. isBinary: boolean;
  43384. };
  43385. }
  43386. /**
  43387. * Interface used by SceneLoader plugin factory
  43388. */
  43389. export interface ISceneLoaderPluginFactory {
  43390. /**
  43391. * Defines the name of the factory
  43392. */
  43393. name: string;
  43394. /**
  43395. * Function called to create a new plugin
  43396. * @return the new plugin
  43397. */
  43398. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43399. /**
  43400. * The callback that returns true if the data can be directly loaded.
  43401. * @param data string containing the file data
  43402. * @returns if the data can be loaded directly
  43403. */
  43404. canDirectLoad?(data: string): boolean;
  43405. }
  43406. /**
  43407. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43408. */
  43409. export interface ISceneLoaderPluginBase {
  43410. /**
  43411. * The friendly name of this plugin.
  43412. */
  43413. name: string;
  43414. /**
  43415. * The file extensions supported by this plugin.
  43416. */
  43417. extensions: string | ISceneLoaderPluginExtensions;
  43418. /**
  43419. * The callback called when loading from a url.
  43420. * @param scene scene loading this url
  43421. * @param url url to load
  43422. * @param onSuccess callback called when the file successfully loads
  43423. * @param onProgress callback called while file is loading (if the server supports this mode)
  43424. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43425. * @param onError callback called when the file fails to load
  43426. * @returns a file request object
  43427. */
  43428. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43429. /**
  43430. * The callback called when loading from a file object.
  43431. * @param scene scene loading this file
  43432. * @param file defines the file to load
  43433. * @param onSuccess defines the callback to call when data is loaded
  43434. * @param onProgress defines the callback to call during loading process
  43435. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43436. * @param onError defines the callback to call when an error occurs
  43437. * @returns a file request object
  43438. */
  43439. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43440. /**
  43441. * The callback that returns true if the data can be directly loaded.
  43442. * @param data string containing the file data
  43443. * @returns if the data can be loaded directly
  43444. */
  43445. canDirectLoad?(data: string): boolean;
  43446. /**
  43447. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43448. * @param scene scene loading this data
  43449. * @param data string containing the data
  43450. * @returns data to pass to the plugin
  43451. */
  43452. directLoad?(scene: Scene, data: string): any;
  43453. /**
  43454. * The callback that allows custom handling of the root url based on the response url.
  43455. * @param rootUrl the original root url
  43456. * @param responseURL the response url if available
  43457. * @returns the new root url
  43458. */
  43459. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43460. }
  43461. /**
  43462. * Interface used to define a SceneLoader plugin
  43463. */
  43464. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43465. /**
  43466. * Import meshes into a scene.
  43467. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43468. * @param scene The scene to import into
  43469. * @param data The data to import
  43470. * @param rootUrl The root url for scene and resources
  43471. * @param meshes The meshes array to import into
  43472. * @param particleSystems The particle systems array to import into
  43473. * @param skeletons The skeletons array to import into
  43474. * @param onError The callback when import fails
  43475. * @returns True if successful or false otherwise
  43476. */
  43477. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43478. /**
  43479. * Load into a scene.
  43480. * @param scene The scene to load into
  43481. * @param data The data to import
  43482. * @param rootUrl The root url for scene and resources
  43483. * @param onError The callback when import fails
  43484. * @returns True if successful or false otherwise
  43485. */
  43486. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43487. /**
  43488. * Load into an asset container.
  43489. * @param scene The scene to load into
  43490. * @param data The data to import
  43491. * @param rootUrl The root url for scene and resources
  43492. * @param onError The callback when import fails
  43493. * @returns The loaded asset container
  43494. */
  43495. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43496. }
  43497. /**
  43498. * Interface used to define an async SceneLoader plugin
  43499. */
  43500. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43501. /**
  43502. * Import meshes into a scene.
  43503. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43504. * @param scene The scene to import into
  43505. * @param data The data to import
  43506. * @param rootUrl The root url for scene and resources
  43507. * @param onProgress The callback when the load progresses
  43508. * @param fileName Defines the name of the file to load
  43509. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43510. */
  43511. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43512. meshes: AbstractMesh[];
  43513. particleSystems: IParticleSystem[];
  43514. skeletons: Skeleton[];
  43515. animationGroups: AnimationGroup[];
  43516. }>;
  43517. /**
  43518. * Load into a scene.
  43519. * @param scene The scene to load into
  43520. * @param data The data to import
  43521. * @param rootUrl The root url for scene and resources
  43522. * @param onProgress The callback when the load progresses
  43523. * @param fileName Defines the name of the file to load
  43524. * @returns Nothing
  43525. */
  43526. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43527. /**
  43528. * Load into an asset container.
  43529. * @param scene The scene to load into
  43530. * @param data The data to import
  43531. * @param rootUrl The root url for scene and resources
  43532. * @param onProgress The callback when the load progresses
  43533. * @param fileName Defines the name of the file to load
  43534. * @returns The loaded asset container
  43535. */
  43536. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43537. }
  43538. /**
  43539. * Mode that determines how to handle old animation groups before loading new ones.
  43540. */
  43541. export enum SceneLoaderAnimationGroupLoadingMode {
  43542. /**
  43543. * Reset all old animations to initial state then dispose them.
  43544. */
  43545. Clean = 0,
  43546. /**
  43547. * Stop all old animations.
  43548. */
  43549. Stop = 1,
  43550. /**
  43551. * Restart old animations from first frame.
  43552. */
  43553. Sync = 2,
  43554. /**
  43555. * Old animations remains untouched.
  43556. */
  43557. NoSync = 3
  43558. }
  43559. /**
  43560. * Class used to load scene from various file formats using registered plugins
  43561. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43562. */
  43563. export class SceneLoader {
  43564. /**
  43565. * No logging while loading
  43566. */
  43567. static readonly NO_LOGGING: number;
  43568. /**
  43569. * Minimal logging while loading
  43570. */
  43571. static readonly MINIMAL_LOGGING: number;
  43572. /**
  43573. * Summary logging while loading
  43574. */
  43575. static readonly SUMMARY_LOGGING: number;
  43576. /**
  43577. * Detailled logging while loading
  43578. */
  43579. static readonly DETAILED_LOGGING: number;
  43580. /**
  43581. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43582. */
  43583. static get ForceFullSceneLoadingForIncremental(): boolean;
  43584. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43585. /**
  43586. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43587. */
  43588. static get ShowLoadingScreen(): boolean;
  43589. static set ShowLoadingScreen(value: boolean);
  43590. /**
  43591. * Defines the current logging level (while loading the scene)
  43592. * @ignorenaming
  43593. */
  43594. static get loggingLevel(): number;
  43595. static set loggingLevel(value: number);
  43596. /**
  43597. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43598. */
  43599. static get CleanBoneMatrixWeights(): boolean;
  43600. static set CleanBoneMatrixWeights(value: boolean);
  43601. /**
  43602. * Event raised when a plugin is used to load a scene
  43603. */
  43604. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43605. private static _registeredPlugins;
  43606. private static _getDefaultPlugin;
  43607. private static _getPluginForExtension;
  43608. private static _getPluginForDirectLoad;
  43609. private static _getPluginForFilename;
  43610. private static _getDirectLoad;
  43611. private static _loadData;
  43612. private static _getFileInfo;
  43613. /**
  43614. * Gets a plugin that can load the given extension
  43615. * @param extension defines the extension to load
  43616. * @returns a plugin or null if none works
  43617. */
  43618. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43619. /**
  43620. * Gets a boolean indicating that the given extension can be loaded
  43621. * @param extension defines the extension to load
  43622. * @returns true if the extension is supported
  43623. */
  43624. static IsPluginForExtensionAvailable(extension: string): boolean;
  43625. /**
  43626. * Adds a new plugin to the list of registered plugins
  43627. * @param plugin defines the plugin to add
  43628. */
  43629. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43630. /**
  43631. * Import meshes into a scene
  43632. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43633. * @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)
  43634. * @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)
  43635. * @param scene the instance of BABYLON.Scene to append to
  43636. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43637. * @param onProgress a callback with a progress event for each file being loaded
  43638. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43639. * @param pluginExtension the extension used to determine the plugin
  43640. * @returns The loaded plugin
  43641. */
  43642. 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>;
  43643. /**
  43644. * Import meshes into a scene
  43645. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43646. * @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)
  43647. * @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)
  43648. * @param scene the instance of BABYLON.Scene to append to
  43649. * @param onProgress a callback with a progress event for each file being loaded
  43650. * @param pluginExtension the extension used to determine the plugin
  43651. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43652. */
  43653. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43654. meshes: AbstractMesh[];
  43655. particleSystems: IParticleSystem[];
  43656. skeletons: Skeleton[];
  43657. animationGroups: AnimationGroup[];
  43658. }>;
  43659. /**
  43660. * Load a scene
  43661. * @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)
  43662. * @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)
  43663. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43664. * @param onSuccess a callback with the scene when import succeeds
  43665. * @param onProgress a callback with a progress event for each file being loaded
  43666. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43667. * @param pluginExtension the extension used to determine the plugin
  43668. * @returns The loaded plugin
  43669. */
  43670. 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>;
  43671. /**
  43672. * Load a scene
  43673. * @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)
  43674. * @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)
  43675. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43676. * @param onProgress a callback with a progress event for each file being loaded
  43677. * @param pluginExtension the extension used to determine the plugin
  43678. * @returns The loaded scene
  43679. */
  43680. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43681. /**
  43682. * Append a scene
  43683. * @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)
  43684. * @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)
  43685. * @param scene is the instance of BABYLON.Scene to append to
  43686. * @param onSuccess a callback with the scene when import succeeds
  43687. * @param onProgress a callback with a progress event for each file being loaded
  43688. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43689. * @param pluginExtension the extension used to determine the plugin
  43690. * @returns The loaded plugin
  43691. */
  43692. 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>;
  43693. /**
  43694. * Append a scene
  43695. * @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)
  43696. * @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)
  43697. * @param scene is the instance of BABYLON.Scene to append to
  43698. * @param onProgress a callback with a progress event for each file being loaded
  43699. * @param pluginExtension the extension used to determine the plugin
  43700. * @returns The given scene
  43701. */
  43702. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43703. /**
  43704. * Load a scene into an asset container
  43705. * @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)
  43706. * @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)
  43707. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43708. * @param onSuccess a callback with the scene when import succeeds
  43709. * @param onProgress a callback with a progress event for each file being loaded
  43710. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43711. * @param pluginExtension the extension used to determine the plugin
  43712. * @returns The loaded plugin
  43713. */
  43714. 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>;
  43715. /**
  43716. * Load a scene into an asset container
  43717. * @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)
  43718. * @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)
  43719. * @param scene is the instance of Scene to append to
  43720. * @param onProgress a callback with a progress event for each file being loaded
  43721. * @param pluginExtension the extension used to determine the plugin
  43722. * @returns The loaded asset container
  43723. */
  43724. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43725. /**
  43726. * Import animations from a file into a scene
  43727. * @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)
  43728. * @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)
  43729. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43730. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43731. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43732. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43733. * @param onSuccess a callback with the scene when import succeeds
  43734. * @param onProgress a callback with a progress event for each file being loaded
  43735. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43736. */
  43737. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  43738. /**
  43739. * Import animations from a file into a scene
  43740. * @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)
  43741. * @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)
  43742. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43743. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43744. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43745. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43746. * @param onSuccess a callback with the scene when import succeeds
  43747. * @param onProgress a callback with a progress event for each file being loaded
  43748. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43749. * @returns the updated scene with imported animations
  43750. */
  43751. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  43752. }
  43753. }
  43754. declare module BABYLON {
  43755. /**
  43756. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43757. */
  43758. export type MotionControllerHandness = "none" | "left" | "right";
  43759. /**
  43760. * The type of components available in motion controllers.
  43761. * This is not the name of the component.
  43762. */
  43763. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43764. /**
  43765. * The state of a controller component
  43766. */
  43767. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43768. /**
  43769. * The schema of motion controller layout.
  43770. * No object will be initialized using this interface
  43771. * This is used just to define the profile.
  43772. */
  43773. export interface IMotionControllerLayout {
  43774. /**
  43775. * Path to load the assets. Usually relative to the base path
  43776. */
  43777. assetPath: string;
  43778. /**
  43779. * Available components (unsorted)
  43780. */
  43781. components: {
  43782. /**
  43783. * A map of component Ids
  43784. */
  43785. [componentId: string]: {
  43786. /**
  43787. * The type of input the component outputs
  43788. */
  43789. type: MotionControllerComponentType;
  43790. /**
  43791. * The indices of this component in the gamepad object
  43792. */
  43793. gamepadIndices: {
  43794. /**
  43795. * Index of button
  43796. */
  43797. button?: number;
  43798. /**
  43799. * If available, index of x-axis
  43800. */
  43801. xAxis?: number;
  43802. /**
  43803. * If available, index of y-axis
  43804. */
  43805. yAxis?: number;
  43806. };
  43807. /**
  43808. * The mesh's root node name
  43809. */
  43810. rootNodeName: string;
  43811. /**
  43812. * Animation definitions for this model
  43813. */
  43814. visualResponses: {
  43815. [stateKey: string]: {
  43816. /**
  43817. * What property will be animated
  43818. */
  43819. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43820. /**
  43821. * What states influence this visual response
  43822. */
  43823. states: MotionControllerComponentStateType[];
  43824. /**
  43825. * Type of animation - movement or visibility
  43826. */
  43827. valueNodeProperty: "transform" | "visibility";
  43828. /**
  43829. * Base node name to move. Its position will be calculated according to the min and max nodes
  43830. */
  43831. valueNodeName?: string;
  43832. /**
  43833. * Minimum movement node
  43834. */
  43835. minNodeName?: string;
  43836. /**
  43837. * Max movement node
  43838. */
  43839. maxNodeName?: string;
  43840. };
  43841. };
  43842. /**
  43843. * If touch enabled, what is the name of node to display user feedback
  43844. */
  43845. touchPointNodeName?: string;
  43846. };
  43847. };
  43848. /**
  43849. * Is it xr standard mapping or not
  43850. */
  43851. gamepadMapping: "" | "xr-standard";
  43852. /**
  43853. * Base root node of this entire model
  43854. */
  43855. rootNodeName: string;
  43856. /**
  43857. * Defines the main button component id
  43858. */
  43859. selectComponentId: string;
  43860. }
  43861. /**
  43862. * A definition for the layout map in the input profile
  43863. */
  43864. export interface IMotionControllerLayoutMap {
  43865. /**
  43866. * Layouts with handness type as a key
  43867. */
  43868. [handness: string]: IMotionControllerLayout;
  43869. }
  43870. /**
  43871. * The XR Input profile schema
  43872. * Profiles can be found here:
  43873. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43874. */
  43875. export interface IMotionControllerProfile {
  43876. /**
  43877. * fallback profiles for this profileId
  43878. */
  43879. fallbackProfileIds: string[];
  43880. /**
  43881. * The layout map, with handness as key
  43882. */
  43883. layouts: IMotionControllerLayoutMap;
  43884. /**
  43885. * The id of this profile
  43886. * correlates to the profile(s) in the xrInput.profiles array
  43887. */
  43888. profileId: string;
  43889. }
  43890. /**
  43891. * A helper-interface for the 3 meshes needed for controller button animation
  43892. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43893. */
  43894. export interface IMotionControllerButtonMeshMap {
  43895. /**
  43896. * the mesh that defines the pressed value mesh position.
  43897. * This is used to find the max-position of this button
  43898. */
  43899. pressedMesh: AbstractMesh;
  43900. /**
  43901. * the mesh that defines the unpressed value mesh position.
  43902. * This is used to find the min (or initial) position of this button
  43903. */
  43904. unpressedMesh: AbstractMesh;
  43905. /**
  43906. * The mesh that will be changed when value changes
  43907. */
  43908. valueMesh: AbstractMesh;
  43909. }
  43910. /**
  43911. * A helper-interface for the 3 meshes needed for controller axis animation.
  43912. * This will be expanded when touchpad animations are fully supported
  43913. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43914. */
  43915. export interface IMotionControllerMeshMap {
  43916. /**
  43917. * the mesh that defines the maximum value mesh position.
  43918. */
  43919. maxMesh?: AbstractMesh;
  43920. /**
  43921. * the mesh that defines the minimum value mesh position.
  43922. */
  43923. minMesh?: AbstractMesh;
  43924. /**
  43925. * The mesh that will be changed when axis value changes
  43926. */
  43927. valueMesh: AbstractMesh;
  43928. }
  43929. /**
  43930. * The elements needed for change-detection of the gamepad objects in motion controllers
  43931. */
  43932. export interface IMinimalMotionControllerObject {
  43933. /**
  43934. * Available axes of this controller
  43935. */
  43936. axes: number[];
  43937. /**
  43938. * An array of available buttons
  43939. */
  43940. buttons: Array<{
  43941. /**
  43942. * Value of the button/trigger
  43943. */
  43944. value: number;
  43945. /**
  43946. * If the button/trigger is currently touched
  43947. */
  43948. touched: boolean;
  43949. /**
  43950. * If the button/trigger is currently pressed
  43951. */
  43952. pressed: boolean;
  43953. }>;
  43954. }
  43955. /**
  43956. * An Abstract Motion controller
  43957. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43958. * Each component has an observable to check for changes in value and state
  43959. */
  43960. export abstract class WebXRAbstractMotionController implements IDisposable {
  43961. protected scene: Scene;
  43962. protected layout: IMotionControllerLayout;
  43963. /**
  43964. * The gamepad object correlating to this controller
  43965. */
  43966. gamepadObject: IMinimalMotionControllerObject;
  43967. /**
  43968. * handness (left/right/none) of this controller
  43969. */
  43970. handness: MotionControllerHandness;
  43971. private _initComponent;
  43972. private _modelReady;
  43973. /**
  43974. * A map of components (WebXRControllerComponent) in this motion controller
  43975. * Components have a ComponentType and can also have both button and axis definitions
  43976. */
  43977. readonly components: {
  43978. [id: string]: WebXRControllerComponent;
  43979. };
  43980. /**
  43981. * Disable the model's animation. Can be set at any time.
  43982. */
  43983. disableAnimation: boolean;
  43984. /**
  43985. * Observers registered here will be triggered when the model of this controller is done loading
  43986. */
  43987. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43988. /**
  43989. * The profile id of this motion controller
  43990. */
  43991. abstract profileId: string;
  43992. /**
  43993. * The root mesh of the model. It is null if the model was not yet initialized
  43994. */
  43995. rootMesh: Nullable<AbstractMesh>;
  43996. /**
  43997. * constructs a new abstract motion controller
  43998. * @param scene the scene to which the model of the controller will be added
  43999. * @param layout The profile layout to load
  44000. * @param gamepadObject The gamepad object correlating to this controller
  44001. * @param handness handness (left/right/none) of this controller
  44002. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44003. */
  44004. constructor(scene: Scene, layout: IMotionControllerLayout,
  44005. /**
  44006. * The gamepad object correlating to this controller
  44007. */
  44008. gamepadObject: IMinimalMotionControllerObject,
  44009. /**
  44010. * handness (left/right/none) of this controller
  44011. */
  44012. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44013. /**
  44014. * Dispose this controller, the model mesh and all its components
  44015. */
  44016. dispose(): void;
  44017. /**
  44018. * Returns all components of specific type
  44019. * @param type the type to search for
  44020. * @return an array of components with this type
  44021. */
  44022. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44023. /**
  44024. * get a component based an its component id as defined in layout.components
  44025. * @param id the id of the component
  44026. * @returns the component correlates to the id or undefined if not found
  44027. */
  44028. getComponent(id: string): WebXRControllerComponent;
  44029. /**
  44030. * Get the list of components available in this motion controller
  44031. * @returns an array of strings correlating to available components
  44032. */
  44033. getComponentIds(): string[];
  44034. /**
  44035. * Get the first component of specific type
  44036. * @param type type of component to find
  44037. * @return a controller component or null if not found
  44038. */
  44039. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44040. /**
  44041. * Get the main (Select) component of this controller as defined in the layout
  44042. * @returns the main component of this controller
  44043. */
  44044. getMainComponent(): WebXRControllerComponent;
  44045. /**
  44046. * Loads the model correlating to this controller
  44047. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44048. * @returns A promise fulfilled with the result of the model loading
  44049. */
  44050. loadModel(): Promise<boolean>;
  44051. /**
  44052. * Update this model using the current XRFrame
  44053. * @param xrFrame the current xr frame to use and update the model
  44054. */
  44055. updateFromXRFrame(xrFrame: XRFrame): void;
  44056. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44057. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44058. /**
  44059. * Moves the axis on the controller mesh based on its current state
  44060. * @param axis the index of the axis
  44061. * @param axisValue the value of the axis which determines the meshes new position
  44062. * @hidden
  44063. */
  44064. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44065. /**
  44066. * Update the model itself with the current frame data
  44067. * @param xrFrame the frame to use for updating the model mesh
  44068. */
  44069. protected updateModel(xrFrame: XRFrame): void;
  44070. /**
  44071. * Get the filename and path for this controller's model
  44072. * @returns a map of filename and path
  44073. */
  44074. protected abstract _getFilenameAndPath(): {
  44075. filename: string;
  44076. path: string;
  44077. };
  44078. /**
  44079. * This function is called before the mesh is loaded. It checks for loading constraints.
  44080. * For example, this function can check if the GLB loader is available
  44081. * If this function returns false, the generic controller will be loaded instead
  44082. * @returns Is the client ready to load the mesh
  44083. */
  44084. protected abstract _getModelLoadingConstraints(): boolean;
  44085. /**
  44086. * This function will be called after the model was successfully loaded and can be used
  44087. * for mesh transformations before it is available for the user
  44088. * @param meshes the loaded meshes
  44089. */
  44090. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44091. /**
  44092. * Set the root mesh for this controller. Important for the WebXR controller class
  44093. * @param meshes the loaded meshes
  44094. */
  44095. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44096. /**
  44097. * A function executed each frame that updates the mesh (if needed)
  44098. * @param xrFrame the current xrFrame
  44099. */
  44100. protected abstract _updateModel(xrFrame: XRFrame): void;
  44101. private _getGenericFilenameAndPath;
  44102. private _getGenericParentMesh;
  44103. }
  44104. }
  44105. declare module BABYLON {
  44106. /**
  44107. * A generic trigger-only motion controller for WebXR
  44108. */
  44109. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44110. /**
  44111. * Static version of the profile id of this controller
  44112. */
  44113. static ProfileId: string;
  44114. profileId: string;
  44115. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44116. protected _getFilenameAndPath(): {
  44117. filename: string;
  44118. path: string;
  44119. };
  44120. protected _getModelLoadingConstraints(): boolean;
  44121. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44122. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44123. protected _updateModel(): void;
  44124. }
  44125. }
  44126. declare module BABYLON {
  44127. /**
  44128. * Class containing static functions to help procedurally build meshes
  44129. */
  44130. export class SphereBuilder {
  44131. /**
  44132. * Creates a sphere mesh
  44133. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44134. * * 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`)
  44135. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44136. * * 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
  44137. * * 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)
  44138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44139. * * 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
  44140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44141. * @param name defines the name of the mesh
  44142. * @param options defines the options used to create the mesh
  44143. * @param scene defines the hosting scene
  44144. * @returns the sphere mesh
  44145. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44146. */
  44147. static CreateSphere(name: string, options: {
  44148. segments?: number;
  44149. diameter?: number;
  44150. diameterX?: number;
  44151. diameterY?: number;
  44152. diameterZ?: number;
  44153. arc?: number;
  44154. slice?: number;
  44155. sideOrientation?: number;
  44156. frontUVs?: Vector4;
  44157. backUVs?: Vector4;
  44158. updatable?: boolean;
  44159. }, scene?: Nullable<Scene>): Mesh;
  44160. }
  44161. }
  44162. declare module BABYLON {
  44163. /**
  44164. * A profiled motion controller has its profile loaded from an online repository.
  44165. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44166. */
  44167. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44168. private _repositoryUrl;
  44169. private _buttonMeshMapping;
  44170. private _touchDots;
  44171. /**
  44172. * The profile ID of this controller. Will be populated when the controller initializes.
  44173. */
  44174. profileId: string;
  44175. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44176. dispose(): void;
  44177. protected _getFilenameAndPath(): {
  44178. filename: string;
  44179. path: string;
  44180. };
  44181. protected _getModelLoadingConstraints(): boolean;
  44182. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44183. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44184. protected _updateModel(_xrFrame: XRFrame): void;
  44185. }
  44186. }
  44187. declare module BABYLON {
  44188. /**
  44189. * A construction function type to create a new controller based on an xrInput object
  44190. */
  44191. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44192. /**
  44193. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44194. *
  44195. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44196. * it should be replaced with auto-loaded controllers.
  44197. *
  44198. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44199. */
  44200. export class WebXRMotionControllerManager {
  44201. private static _AvailableControllers;
  44202. private static _Fallbacks;
  44203. private static _ProfileLoadingPromises;
  44204. private static _ProfilesList;
  44205. /**
  44206. * The base URL of the online controller repository. Can be changed at any time.
  44207. */
  44208. static BaseRepositoryUrl: string;
  44209. /**
  44210. * Which repository gets priority - local or online
  44211. */
  44212. static PrioritizeOnlineRepository: boolean;
  44213. /**
  44214. * Use the online repository, or use only locally-defined controllers
  44215. */
  44216. static UseOnlineRepository: boolean;
  44217. /**
  44218. * Clear the cache used for profile loading and reload when requested again
  44219. */
  44220. static ClearProfilesCache(): void;
  44221. /**
  44222. * Register the default fallbacks.
  44223. * This function is called automatically when this file is imported.
  44224. */
  44225. static DefaultFallbacks(): void;
  44226. /**
  44227. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44228. * @param profileId the profile to which a fallback needs to be found
  44229. * @return an array with corresponding fallback profiles
  44230. */
  44231. static FindFallbackWithProfileId(profileId: string): string[];
  44232. /**
  44233. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44234. * The order of search:
  44235. *
  44236. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44237. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44238. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44239. * 4) return the generic trigger controller if none were found
  44240. *
  44241. * @param xrInput the xrInput to which a new controller is initialized
  44242. * @param scene the scene to which the model will be added
  44243. * @param forceProfile force a certain profile for this controller
  44244. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44245. */
  44246. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44247. /**
  44248. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44249. *
  44250. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44251. *
  44252. * @param type the profile type to register
  44253. * @param constructFunction the function to be called when loading this profile
  44254. */
  44255. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44256. /**
  44257. * Register a fallback to a specific profile.
  44258. * @param profileId the profileId that will receive the fallbacks
  44259. * @param fallbacks A list of fallback profiles
  44260. */
  44261. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44262. /**
  44263. * Will update the list of profiles available in the repository
  44264. * @return a promise that resolves to a map of profiles available online
  44265. */
  44266. static UpdateProfilesList(): Promise<{
  44267. [profile: string]: string;
  44268. }>;
  44269. private static _LoadProfileFromRepository;
  44270. private static _LoadProfilesFromAvailableControllers;
  44271. }
  44272. }
  44273. declare module BABYLON {
  44274. /**
  44275. * Configuration options for the WebXR controller creation
  44276. */
  44277. export interface IWebXRControllerOptions {
  44278. /**
  44279. * Should the controller mesh be animated when a user interacts with it
  44280. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44281. */
  44282. disableMotionControllerAnimation?: boolean;
  44283. /**
  44284. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44285. */
  44286. doNotLoadControllerMesh?: boolean;
  44287. /**
  44288. * Force a specific controller type for this controller.
  44289. * This can be used when creating your own profile or when testing different controllers
  44290. */
  44291. forceControllerProfile?: string;
  44292. }
  44293. /**
  44294. * Represents an XR controller
  44295. */
  44296. export class WebXRInputSource {
  44297. private _scene;
  44298. /** The underlying input source for the controller */
  44299. inputSource: XRInputSource;
  44300. private _options;
  44301. private _tmpQuaternion;
  44302. private _tmpVector;
  44303. private _uniqueId;
  44304. /**
  44305. * 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
  44306. */
  44307. grip?: AbstractMesh;
  44308. /**
  44309. * If available, this is the gamepad object related to this controller.
  44310. * Using this object it is possible to get click events and trackpad changes of the
  44311. * webxr controller that is currently being used.
  44312. */
  44313. motionController?: WebXRAbstractMotionController;
  44314. /**
  44315. * Event that fires when the controller is removed/disposed.
  44316. * The object provided as event data is this controller, after associated assets were disposed.
  44317. * uniqueId is still available.
  44318. */
  44319. onDisposeObservable: Observable<WebXRInputSource>;
  44320. /**
  44321. * Will be triggered when the mesh associated with the motion controller is done loading.
  44322. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44323. * A shortened version of controller -> motion controller -> on mesh loaded.
  44324. */
  44325. onMeshLoadedObservable: Observable<AbstractMesh>;
  44326. /**
  44327. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44328. */
  44329. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44330. /**
  44331. * Pointer which can be used to select objects or attach a visible laser to
  44332. */
  44333. pointer: AbstractMesh;
  44334. /**
  44335. * Creates the controller
  44336. * @see https://doc.babylonjs.com/how_to/webxr
  44337. * @param _scene the scene which the controller should be associated to
  44338. * @param inputSource the underlying input source for the controller
  44339. * @param _options options for this controller creation
  44340. */
  44341. constructor(_scene: Scene,
  44342. /** The underlying input source for the controller */
  44343. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44344. /**
  44345. * Get this controllers unique id
  44346. */
  44347. get uniqueId(): string;
  44348. /**
  44349. * Disposes of the object
  44350. */
  44351. dispose(): void;
  44352. /**
  44353. * Gets a world space ray coming from the pointer or grip
  44354. * @param result the resulting ray
  44355. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44356. */
  44357. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44358. /**
  44359. * Updates the controller pose based on the given XRFrame
  44360. * @param xrFrame xr frame to update the pose with
  44361. * @param referenceSpace reference space to use
  44362. */
  44363. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44364. }
  44365. }
  44366. declare module BABYLON {
  44367. /**
  44368. * The schema for initialization options of the XR Input class
  44369. */
  44370. export interface IWebXRInputOptions {
  44371. /**
  44372. * If set to true no model will be automatically loaded
  44373. */
  44374. doNotLoadControllerMeshes?: boolean;
  44375. /**
  44376. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44377. * If not found, the xr input profile data will be used.
  44378. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44379. */
  44380. forceInputProfile?: string;
  44381. /**
  44382. * Do not send a request to the controller repository to load the profile.
  44383. *
  44384. * Instead, use the controllers available in babylon itself.
  44385. */
  44386. disableOnlineControllerRepository?: boolean;
  44387. /**
  44388. * A custom URL for the controllers repository
  44389. */
  44390. customControllersRepositoryURL?: string;
  44391. /**
  44392. * Should the controller model's components not move according to the user input
  44393. */
  44394. disableControllerAnimation?: boolean;
  44395. }
  44396. /**
  44397. * XR input used to track XR inputs such as controllers/rays
  44398. */
  44399. export class WebXRInput implements IDisposable {
  44400. /**
  44401. * the xr session manager for this session
  44402. */
  44403. xrSessionManager: WebXRSessionManager;
  44404. /**
  44405. * the WebXR camera for this session. Mainly used for teleportation
  44406. */
  44407. xrCamera: WebXRCamera;
  44408. private readonly options;
  44409. /**
  44410. * XR controllers being tracked
  44411. */
  44412. controllers: Array<WebXRInputSource>;
  44413. private _frameObserver;
  44414. private _sessionEndedObserver;
  44415. private _sessionInitObserver;
  44416. /**
  44417. * Event when a controller has been connected/added
  44418. */
  44419. onControllerAddedObservable: Observable<WebXRInputSource>;
  44420. /**
  44421. * Event when a controller has been removed/disconnected
  44422. */
  44423. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44424. /**
  44425. * Initializes the WebXRInput
  44426. * @param xrSessionManager the xr session manager for this session
  44427. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44428. * @param options = initialization options for this xr input
  44429. */
  44430. constructor(
  44431. /**
  44432. * the xr session manager for this session
  44433. */
  44434. xrSessionManager: WebXRSessionManager,
  44435. /**
  44436. * the WebXR camera for this session. Mainly used for teleportation
  44437. */
  44438. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44439. private _onInputSourcesChange;
  44440. private _addAndRemoveControllers;
  44441. /**
  44442. * Disposes of the object
  44443. */
  44444. dispose(): void;
  44445. }
  44446. }
  44447. declare module BABYLON {
  44448. /**
  44449. * This is the base class for all WebXR features.
  44450. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44451. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44452. */
  44453. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44454. protected _xrSessionManager: WebXRSessionManager;
  44455. private _attached;
  44456. private _removeOnDetach;
  44457. /**
  44458. * Should auto-attach be disabled?
  44459. */
  44460. disableAutoAttach: boolean;
  44461. /**
  44462. * Construct a new (abstract) WebXR feature
  44463. * @param _xrSessionManager the xr session manager for this feature
  44464. */
  44465. constructor(_xrSessionManager: WebXRSessionManager);
  44466. /**
  44467. * Is this feature attached
  44468. */
  44469. get attached(): boolean;
  44470. /**
  44471. * attach this feature
  44472. *
  44473. * @param force should attachment be forced (even when already attached)
  44474. * @returns true if successful, false is failed or already attached
  44475. */
  44476. attach(force?: boolean): boolean;
  44477. /**
  44478. * detach this feature.
  44479. *
  44480. * @returns true if successful, false if failed or already detached
  44481. */
  44482. detach(): boolean;
  44483. /**
  44484. * Dispose this feature and all of the resources attached
  44485. */
  44486. dispose(): void;
  44487. /**
  44488. * This is used to register callbacks that will automatically be removed when detach is called.
  44489. * @param observable the observable to which the observer will be attached
  44490. * @param callback the callback to register
  44491. */
  44492. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44493. /**
  44494. * Code in this function will be executed on each xrFrame received from the browser.
  44495. * This function will not execute after the feature is detached.
  44496. * @param _xrFrame the current frame
  44497. */
  44498. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44499. }
  44500. }
  44501. declare module BABYLON {
  44502. /**
  44503. * Renders a layer on top of an existing scene
  44504. */
  44505. export class UtilityLayerRenderer implements IDisposable {
  44506. /** the original scene that will be rendered on top of */
  44507. originalScene: Scene;
  44508. private _pointerCaptures;
  44509. private _lastPointerEvents;
  44510. private static _DefaultUtilityLayer;
  44511. private static _DefaultKeepDepthUtilityLayer;
  44512. private _sharedGizmoLight;
  44513. private _renderCamera;
  44514. /**
  44515. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44516. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44517. * @returns the camera that is used when rendering the utility layer
  44518. */
  44519. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44520. /**
  44521. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44522. * @param cam the camera that should be used when rendering the utility layer
  44523. */
  44524. setRenderCamera(cam: Nullable<Camera>): void;
  44525. /**
  44526. * @hidden
  44527. * Light which used by gizmos to get light shading
  44528. */
  44529. _getSharedGizmoLight(): HemisphericLight;
  44530. /**
  44531. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44532. */
  44533. pickUtilitySceneFirst: boolean;
  44534. /**
  44535. * 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)
  44536. */
  44537. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44538. /**
  44539. * 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)
  44540. */
  44541. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44542. /**
  44543. * The scene that is rendered on top of the original scene
  44544. */
  44545. utilityLayerScene: Scene;
  44546. /**
  44547. * If the utility layer should automatically be rendered on top of existing scene
  44548. */
  44549. shouldRender: boolean;
  44550. /**
  44551. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44552. */
  44553. onlyCheckPointerDownEvents: boolean;
  44554. /**
  44555. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44556. */
  44557. processAllEvents: boolean;
  44558. /**
  44559. * Observable raised when the pointer move from the utility layer scene to the main scene
  44560. */
  44561. onPointerOutObservable: Observable<number>;
  44562. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44563. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44564. private _afterRenderObserver;
  44565. private _sceneDisposeObserver;
  44566. private _originalPointerObserver;
  44567. /**
  44568. * Instantiates a UtilityLayerRenderer
  44569. * @param originalScene the original scene that will be rendered on top of
  44570. * @param handleEvents boolean indicating if the utility layer should handle events
  44571. */
  44572. constructor(
  44573. /** the original scene that will be rendered on top of */
  44574. originalScene: Scene, handleEvents?: boolean);
  44575. private _notifyObservers;
  44576. /**
  44577. * Renders the utility layers scene on top of the original scene
  44578. */
  44579. render(): void;
  44580. /**
  44581. * Disposes of the renderer
  44582. */
  44583. dispose(): void;
  44584. private _updateCamera;
  44585. }
  44586. }
  44587. declare module BABYLON {
  44588. /**
  44589. * Options interface for the pointer selection module
  44590. */
  44591. export interface IWebXRControllerPointerSelectionOptions {
  44592. /**
  44593. * if provided, this scene will be used to render meshes.
  44594. */
  44595. customUtilityLayerScene?: Scene;
  44596. /**
  44597. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  44598. * If not disabled, the last picked point will be used to execute a pointer up event
  44599. * If disabled, pointer up event will be triggered right after the pointer down event.
  44600. * Used in screen and gaze target ray mode only
  44601. */
  44602. disablePointerUpOnTouchOut: boolean;
  44603. /**
  44604. * For gaze mode (time to select instead of press)
  44605. */
  44606. forceGazeMode: boolean;
  44607. /**
  44608. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  44609. * to start a new countdown to the pointer down event.
  44610. * Defaults to 1.
  44611. */
  44612. gazeModePointerMovedFactor?: number;
  44613. /**
  44614. * Different button type to use instead of the main component
  44615. */
  44616. overrideButtonId?: string;
  44617. /**
  44618. * use this rendering group id for the meshes (optional)
  44619. */
  44620. renderingGroupId?: number;
  44621. /**
  44622. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44623. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44624. * 3000 means 3 seconds between pointing at something and selecting it
  44625. */
  44626. timeToSelect?: number;
  44627. /**
  44628. * Should meshes created here be added to a utility layer or the main scene
  44629. */
  44630. useUtilityLayer?: boolean;
  44631. /**
  44632. * the xr input to use with this pointer selection
  44633. */
  44634. xrInput: WebXRInput;
  44635. }
  44636. /**
  44637. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44638. */
  44639. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44640. private readonly _options;
  44641. private static _idCounter;
  44642. private _attachController;
  44643. private _controllers;
  44644. private _scene;
  44645. private _tmpVectorForPickCompare;
  44646. /**
  44647. * The module's name
  44648. */
  44649. static readonly Name: string;
  44650. /**
  44651. * The (Babylon) version of this module.
  44652. * This is an integer representing the implementation version.
  44653. * This number does not correspond to the WebXR specs version
  44654. */
  44655. static readonly Version: number;
  44656. /**
  44657. * Disable lighting on the laser pointer (so it will always be visible)
  44658. */
  44659. disablePointerLighting: boolean;
  44660. /**
  44661. * Disable lighting on the selection mesh (so it will always be visible)
  44662. */
  44663. disableSelectionMeshLighting: boolean;
  44664. /**
  44665. * Should the laser pointer be displayed
  44666. */
  44667. displayLaserPointer: boolean;
  44668. /**
  44669. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44670. */
  44671. displaySelectionMesh: boolean;
  44672. /**
  44673. * This color will be set to the laser pointer when selection is triggered
  44674. */
  44675. laserPointerPickedColor: Color3;
  44676. /**
  44677. * Default color of the laser pointer
  44678. */
  44679. lasterPointerDefaultColor: Color3;
  44680. /**
  44681. * default color of the selection ring
  44682. */
  44683. selectionMeshDefaultColor: Color3;
  44684. /**
  44685. * This color will be applied to the selection ring when selection is triggered
  44686. */
  44687. selectionMeshPickedColor: Color3;
  44688. /**
  44689. * Optional filter to be used for ray selection. This predicate shares behavior with
  44690. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44691. */
  44692. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44693. /**
  44694. * constructs a new background remover module
  44695. * @param _xrSessionManager the session manager for this module
  44696. * @param _options read-only options to be used in this module
  44697. */
  44698. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44699. /**
  44700. * attach this feature
  44701. * Will usually be called by the features manager
  44702. *
  44703. * @returns true if successful.
  44704. */
  44705. attach(): boolean;
  44706. /**
  44707. * detach this feature.
  44708. * Will usually be called by the features manager
  44709. *
  44710. * @returns true if successful.
  44711. */
  44712. detach(): boolean;
  44713. /**
  44714. * Will get the mesh under a specific pointer.
  44715. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44716. * @param controllerId the controllerId to check
  44717. * @returns The mesh under pointer or null if no mesh is under the pointer
  44718. */
  44719. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44720. /**
  44721. * Get the xr controller that correlates to the pointer id in the pointer event
  44722. *
  44723. * @param id the pointer id to search for
  44724. * @returns the controller that correlates to this id or null if not found
  44725. */
  44726. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44727. protected _onXRFrame(_xrFrame: XRFrame): void;
  44728. private _attachGazeMode;
  44729. private _attachScreenRayMode;
  44730. private _attachTrackedPointerRayMode;
  44731. private _convertNormalToDirectionOfRay;
  44732. private _detachController;
  44733. private _generateNewMeshPair;
  44734. private _pickingMoved;
  44735. private _updatePointerDistance;
  44736. }
  44737. }
  44738. declare module BABYLON {
  44739. /**
  44740. * Button which can be used to enter a different mode of XR
  44741. */
  44742. export class WebXREnterExitUIButton {
  44743. /** button element */
  44744. element: HTMLElement;
  44745. /** XR initialization options for the button */
  44746. sessionMode: XRSessionMode;
  44747. /** Reference space type */
  44748. referenceSpaceType: XRReferenceSpaceType;
  44749. /**
  44750. * Creates a WebXREnterExitUIButton
  44751. * @param element button element
  44752. * @param sessionMode XR initialization session mode
  44753. * @param referenceSpaceType the type of reference space to be used
  44754. */
  44755. constructor(
  44756. /** button element */
  44757. element: HTMLElement,
  44758. /** XR initialization options for the button */
  44759. sessionMode: XRSessionMode,
  44760. /** Reference space type */
  44761. referenceSpaceType: XRReferenceSpaceType);
  44762. /**
  44763. * Extendable function which can be used to update the button's visuals when the state changes
  44764. * @param activeButton the current active button in the UI
  44765. */
  44766. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44767. }
  44768. /**
  44769. * Options to create the webXR UI
  44770. */
  44771. export class WebXREnterExitUIOptions {
  44772. /**
  44773. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44774. */
  44775. customButtons?: Array<WebXREnterExitUIButton>;
  44776. /**
  44777. * A reference space type to use when creating the default button.
  44778. * Default is local-floor
  44779. */
  44780. referenceSpaceType?: XRReferenceSpaceType;
  44781. /**
  44782. * Context to enter xr with
  44783. */
  44784. renderTarget?: Nullable<WebXRRenderTarget>;
  44785. /**
  44786. * A session mode to use when creating the default button.
  44787. * Default is immersive-vr
  44788. */
  44789. sessionMode?: XRSessionMode;
  44790. }
  44791. /**
  44792. * UI to allow the user to enter/exit XR mode
  44793. */
  44794. export class WebXREnterExitUI implements IDisposable {
  44795. private scene;
  44796. /** version of the options passed to this UI */
  44797. options: WebXREnterExitUIOptions;
  44798. private _activeButton;
  44799. private _buttons;
  44800. private _overlay;
  44801. /**
  44802. * Fired every time the active button is changed.
  44803. *
  44804. * When xr is entered via a button that launches xr that button will be the callback parameter
  44805. *
  44806. * When exiting xr the callback parameter will be null)
  44807. */
  44808. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44809. /**
  44810. *
  44811. * @param scene babylon scene object to use
  44812. * @param options (read-only) version of the options passed to this UI
  44813. */
  44814. private constructor();
  44815. /**
  44816. * Creates UI to allow the user to enter/exit XR mode
  44817. * @param scene the scene to add the ui to
  44818. * @param helper the xr experience helper to enter/exit xr with
  44819. * @param options options to configure the UI
  44820. * @returns the created ui
  44821. */
  44822. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44823. /**
  44824. * Disposes of the XR UI component
  44825. */
  44826. dispose(): void;
  44827. private _updateButtons;
  44828. }
  44829. }
  44830. declare module BABYLON {
  44831. /**
  44832. * Class containing static functions to help procedurally build meshes
  44833. */
  44834. export class LinesBuilder {
  44835. /**
  44836. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44837. * * 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
  44838. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44839. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44840. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44841. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44842. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44843. * * 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
  44844. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44847. * @param name defines the name of the new line system
  44848. * @param options defines the options used to create the line system
  44849. * @param scene defines the hosting scene
  44850. * @returns a new line system mesh
  44851. */
  44852. static CreateLineSystem(name: string, options: {
  44853. lines: Vector3[][];
  44854. updatable?: boolean;
  44855. instance?: Nullable<LinesMesh>;
  44856. colors?: Nullable<Color4[][]>;
  44857. useVertexAlpha?: boolean;
  44858. }, scene: Nullable<Scene>): LinesMesh;
  44859. /**
  44860. * Creates a line mesh
  44861. * 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
  44862. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44863. * * The parameter `points` is an array successive Vector3
  44864. * * 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
  44865. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44866. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44867. * * When updating an instance, remember that only point positions can change, not the number of points
  44868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44870. * @param name defines the name of the new line system
  44871. * @param options defines the options used to create the line system
  44872. * @param scene defines the hosting scene
  44873. * @returns a new line mesh
  44874. */
  44875. static CreateLines(name: string, options: {
  44876. points: Vector3[];
  44877. updatable?: boolean;
  44878. instance?: Nullable<LinesMesh>;
  44879. colors?: Color4[];
  44880. useVertexAlpha?: boolean;
  44881. }, scene?: Nullable<Scene>): LinesMesh;
  44882. /**
  44883. * Creates a dashed line mesh
  44884. * * 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
  44885. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44886. * * The parameter `points` is an array successive Vector3
  44887. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44888. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44889. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44890. * * 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
  44891. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44892. * * When updating an instance, remember that only point positions can change, not the number of points
  44893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44894. * @param name defines the name of the mesh
  44895. * @param options defines the options used to create the mesh
  44896. * @param scene defines the hosting scene
  44897. * @returns the dashed line mesh
  44898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44899. */
  44900. static CreateDashedLines(name: string, options: {
  44901. points: Vector3[];
  44902. dashSize?: number;
  44903. gapSize?: number;
  44904. dashNb?: number;
  44905. updatable?: boolean;
  44906. instance?: LinesMesh;
  44907. useVertexAlpha?: boolean;
  44908. }, scene?: Nullable<Scene>): LinesMesh;
  44909. }
  44910. }
  44911. declare module BABYLON {
  44912. /**
  44913. * The options container for the teleportation module
  44914. */
  44915. export interface IWebXRTeleportationOptions {
  44916. /**
  44917. * if provided, this scene will be used to render meshes.
  44918. */
  44919. customUtilityLayerScene?: Scene;
  44920. /**
  44921. * Values to configure the default target mesh
  44922. */
  44923. defaultTargetMeshOptions?: {
  44924. /**
  44925. * Fill color of the teleportation area
  44926. */
  44927. teleportationFillColor?: string;
  44928. /**
  44929. * Border color for the teleportation area
  44930. */
  44931. teleportationBorderColor?: string;
  44932. /**
  44933. * Disable the mesh's animation sequence
  44934. */
  44935. disableAnimation?: boolean;
  44936. /**
  44937. * Disable lighting on the material or the ring and arrow
  44938. */
  44939. disableLighting?: boolean;
  44940. /**
  44941. * Override the default material of the torus and arrow
  44942. */
  44943. torusArrowMaterial?: Material;
  44944. };
  44945. /**
  44946. * A list of meshes to use as floor meshes.
  44947. * Meshes can be added and removed after initializing the feature using the
  44948. * addFloorMesh and removeFloorMesh functions
  44949. * If empty, rotation will still work
  44950. */
  44951. floorMeshes?: AbstractMesh[];
  44952. /**
  44953. * use this rendering group id for the meshes (optional)
  44954. */
  44955. renderingGroupId?: number;
  44956. /**
  44957. * Should teleportation move only to snap points
  44958. */
  44959. snapPointsOnly?: boolean;
  44960. /**
  44961. * An array of points to which the teleportation will snap to.
  44962. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44963. */
  44964. snapPositions?: Vector3[];
  44965. /**
  44966. * How close should the teleportation ray be in order to snap to position.
  44967. * Default to 0.8 units (meters)
  44968. */
  44969. snapToPositionRadius?: number;
  44970. /**
  44971. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44972. * If you want to support rotation, make sure your mesh has a direction indicator.
  44973. *
  44974. * When left untouched, the default mesh will be initialized.
  44975. */
  44976. teleportationTargetMesh?: AbstractMesh;
  44977. /**
  44978. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  44979. */
  44980. timeToTeleport?: number;
  44981. /**
  44982. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  44983. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  44984. */
  44985. useMainComponentOnly?: boolean;
  44986. /**
  44987. * Should meshes created here be added to a utility layer or the main scene
  44988. */
  44989. useUtilityLayer?: boolean;
  44990. /**
  44991. * Babylon XR Input class for controller
  44992. */
  44993. xrInput: WebXRInput;
  44994. }
  44995. /**
  44996. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  44997. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44998. * the input of the attached controllers.
  44999. */
  45000. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45001. private _options;
  45002. private _controllers;
  45003. private _currentTeleportationControllerId;
  45004. private _floorMeshes;
  45005. private _quadraticBezierCurve;
  45006. private _selectionFeature;
  45007. private _snapToPositions;
  45008. private _snappedToPoint;
  45009. private _teleportationRingMaterial?;
  45010. private _tmpRay;
  45011. private _tmpVector;
  45012. /**
  45013. * The module's name
  45014. */
  45015. static readonly Name: string;
  45016. /**
  45017. * The (Babylon) version of this module.
  45018. * This is an integer representing the implementation version.
  45019. * This number does not correspond to the webxr specs version
  45020. */
  45021. static readonly Version: number;
  45022. /**
  45023. * Is movement backwards enabled
  45024. */
  45025. backwardsMovementEnabled: boolean;
  45026. /**
  45027. * Distance to travel when moving backwards
  45028. */
  45029. backwardsTeleportationDistance: number;
  45030. /**
  45031. * The distance from the user to the inspection point in the direction of the controller
  45032. * A higher number will allow the user to move further
  45033. * defaults to 5 (meters, in xr units)
  45034. */
  45035. parabolicCheckRadius: number;
  45036. /**
  45037. * Should the module support parabolic ray on top of direct ray
  45038. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45039. * Very helpful when moving between floors / different heights
  45040. */
  45041. parabolicRayEnabled: boolean;
  45042. /**
  45043. * How much rotation should be applied when rotating right and left
  45044. */
  45045. rotationAngle: number;
  45046. /**
  45047. * Is rotation enabled when moving forward?
  45048. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45049. */
  45050. rotationEnabled: boolean;
  45051. /**
  45052. * constructs a new anchor system
  45053. * @param _xrSessionManager an instance of WebXRSessionManager
  45054. * @param _options configuration object for this feature
  45055. */
  45056. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45057. /**
  45058. * Get the snapPointsOnly flag
  45059. */
  45060. get snapPointsOnly(): boolean;
  45061. /**
  45062. * Sets the snapPointsOnly flag
  45063. * @param snapToPoints should teleportation be exclusively to snap points
  45064. */
  45065. set snapPointsOnly(snapToPoints: boolean);
  45066. /**
  45067. * Add a new mesh to the floor meshes array
  45068. * @param mesh the mesh to use as floor mesh
  45069. */
  45070. addFloorMesh(mesh: AbstractMesh): void;
  45071. /**
  45072. * Add a new snap-to point to fix teleportation to this position
  45073. * @param newSnapPoint The new Snap-To point
  45074. */
  45075. addSnapPoint(newSnapPoint: Vector3): void;
  45076. attach(): boolean;
  45077. detach(): boolean;
  45078. dispose(): void;
  45079. /**
  45080. * Remove a mesh from the floor meshes array
  45081. * @param mesh the mesh to remove
  45082. */
  45083. removeFloorMesh(mesh: AbstractMesh): void;
  45084. /**
  45085. * Remove a mesh from the floor meshes array using its name
  45086. * @param name the mesh name to remove
  45087. */
  45088. removeFloorMeshByName(name: string): void;
  45089. /**
  45090. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  45091. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45092. * @returns was the point found and removed or not
  45093. */
  45094. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45095. /**
  45096. * This function sets a selection feature that will be disabled when
  45097. * the forward ray is shown and will be reattached when hidden.
  45098. * This is used to remove the selection rays when moving.
  45099. * @param selectionFeature the feature to disable when forward movement is enabled
  45100. */
  45101. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45102. protected _onXRFrame(_xrFrame: XRFrame): void;
  45103. private _attachController;
  45104. private _createDefaultTargetMesh;
  45105. private _detachController;
  45106. private _findClosestSnapPointWithRadius;
  45107. private _setTargetMeshPosition;
  45108. private _setTargetMeshVisibility;
  45109. private _showParabolicPath;
  45110. private _teleportForward;
  45111. }
  45112. }
  45113. declare module BABYLON {
  45114. /**
  45115. * Options for the default xr helper
  45116. */
  45117. export class WebXRDefaultExperienceOptions {
  45118. /**
  45119. * Enable or disable default UI to enter XR
  45120. */
  45121. disableDefaultUI?: boolean;
  45122. /**
  45123. * Should teleportation not initialize. defaults to false.
  45124. */
  45125. disableTeleportation?: boolean;
  45126. /**
  45127. * Floor meshes that will be used for teleport
  45128. */
  45129. floorMeshes?: Array<AbstractMesh>;
  45130. /**
  45131. * If set to true, the first frame will not be used to reset position
  45132. * The first frame is mainly used when copying transformation from the old camera
  45133. * Mainly used in AR
  45134. */
  45135. ignoreNativeCameraTransformation?: boolean;
  45136. /**
  45137. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45138. */
  45139. inputOptions?: IWebXRInputOptions;
  45140. /**
  45141. * optional configuration for the output canvas
  45142. */
  45143. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45144. /**
  45145. * optional UI options. This can be used among other to change session mode and reference space type
  45146. */
  45147. uiOptions?: WebXREnterExitUIOptions;
  45148. /**
  45149. * When loading teleportation and pointer select, use stable versions instead of latest.
  45150. */
  45151. useStablePlugins?: boolean;
  45152. }
  45153. /**
  45154. * Default experience which provides a similar setup to the previous webVRExperience
  45155. */
  45156. export class WebXRDefaultExperience {
  45157. /**
  45158. * Base experience
  45159. */
  45160. baseExperience: WebXRExperienceHelper;
  45161. /**
  45162. * Enables ui for entering/exiting xr
  45163. */
  45164. enterExitUI: WebXREnterExitUI;
  45165. /**
  45166. * Input experience extension
  45167. */
  45168. input: WebXRInput;
  45169. /**
  45170. * Enables laser pointer and selection
  45171. */
  45172. pointerSelection: WebXRControllerPointerSelection;
  45173. /**
  45174. * Default target xr should render to
  45175. */
  45176. renderTarget: WebXRRenderTarget;
  45177. /**
  45178. * Enables teleportation
  45179. */
  45180. teleportation: WebXRMotionControllerTeleportation;
  45181. private constructor();
  45182. /**
  45183. * Creates the default xr experience
  45184. * @param scene scene
  45185. * @param options options for basic configuration
  45186. * @returns resulting WebXRDefaultExperience
  45187. */
  45188. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45189. /**
  45190. * DIsposes of the experience helper
  45191. */
  45192. dispose(): void;
  45193. }
  45194. }
  45195. declare module BABYLON {
  45196. /**
  45197. * Options to modify the vr teleportation behavior.
  45198. */
  45199. export interface VRTeleportationOptions {
  45200. /**
  45201. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45202. */
  45203. floorMeshName?: string;
  45204. /**
  45205. * A list of meshes to be used as the teleportation floor. (default: empty)
  45206. */
  45207. floorMeshes?: Mesh[];
  45208. /**
  45209. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45210. */
  45211. teleportationMode?: number;
  45212. /**
  45213. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45214. */
  45215. teleportationTime?: number;
  45216. /**
  45217. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45218. */
  45219. teleportationSpeed?: number;
  45220. /**
  45221. * The easing function used in the animation or null for Linear. (default CircleEase)
  45222. */
  45223. easingFunction?: EasingFunction;
  45224. }
  45225. /**
  45226. * Options to modify the vr experience helper's behavior.
  45227. */
  45228. export interface VRExperienceHelperOptions extends WebVROptions {
  45229. /**
  45230. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45231. */
  45232. createDeviceOrientationCamera?: boolean;
  45233. /**
  45234. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45235. */
  45236. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45237. /**
  45238. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45239. */
  45240. laserToggle?: boolean;
  45241. /**
  45242. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45243. */
  45244. floorMeshes?: Mesh[];
  45245. /**
  45246. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45247. */
  45248. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45249. /**
  45250. * Defines if WebXR should be used instead of WebVR (if available)
  45251. */
  45252. useXR?: boolean;
  45253. }
  45254. /**
  45255. * Event containing information after VR has been entered
  45256. */
  45257. export class OnAfterEnteringVRObservableEvent {
  45258. /**
  45259. * If entering vr was successful
  45260. */
  45261. success: boolean;
  45262. }
  45263. /**
  45264. * Helps to quickly add VR support to an existing scene.
  45265. * See http://doc.babylonjs.com/how_to/webvr_helper
  45266. */
  45267. export class VRExperienceHelper {
  45268. /** Options to modify the vr experience helper's behavior. */
  45269. webVROptions: VRExperienceHelperOptions;
  45270. private _scene;
  45271. private _position;
  45272. private _btnVR;
  45273. private _btnVRDisplayed;
  45274. private _webVRsupported;
  45275. private _webVRready;
  45276. private _webVRrequesting;
  45277. private _webVRpresenting;
  45278. private _hasEnteredVR;
  45279. private _fullscreenVRpresenting;
  45280. private _inputElement;
  45281. private _webVRCamera;
  45282. private _vrDeviceOrientationCamera;
  45283. private _deviceOrientationCamera;
  45284. private _existingCamera;
  45285. private _onKeyDown;
  45286. private _onVrDisplayPresentChange;
  45287. private _onVRDisplayChanged;
  45288. private _onVRRequestPresentStart;
  45289. private _onVRRequestPresentComplete;
  45290. /**
  45291. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  45292. */
  45293. enableGazeEvenWhenNoPointerLock: boolean;
  45294. /**
  45295. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45296. */
  45297. exitVROnDoubleTap: boolean;
  45298. /**
  45299. * Observable raised right before entering VR.
  45300. */
  45301. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45302. /**
  45303. * Observable raised when entering VR has completed.
  45304. */
  45305. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45306. /**
  45307. * Observable raised when exiting VR.
  45308. */
  45309. onExitingVRObservable: Observable<VRExperienceHelper>;
  45310. /**
  45311. * Observable raised when controller mesh is loaded.
  45312. */
  45313. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45314. /** Return this.onEnteringVRObservable
  45315. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45316. */
  45317. get onEnteringVR(): Observable<VRExperienceHelper>;
  45318. /** Return this.onExitingVRObservable
  45319. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45320. */
  45321. get onExitingVR(): Observable<VRExperienceHelper>;
  45322. /** Return this.onControllerMeshLoadedObservable
  45323. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45324. */
  45325. get onControllerMeshLoaded(): Observable<WebVRController>;
  45326. private _rayLength;
  45327. private _useCustomVRButton;
  45328. private _teleportationRequested;
  45329. private _teleportActive;
  45330. private _floorMeshName;
  45331. private _floorMeshesCollection;
  45332. private _teleportationMode;
  45333. private _teleportationTime;
  45334. private _teleportationSpeed;
  45335. private _teleportationEasing;
  45336. private _rotationAllowed;
  45337. private _teleportBackwardsVector;
  45338. private _teleportationTarget;
  45339. private _isDefaultTeleportationTarget;
  45340. private _postProcessMove;
  45341. private _teleportationFillColor;
  45342. private _teleportationBorderColor;
  45343. private _rotationAngle;
  45344. private _haloCenter;
  45345. private _cameraGazer;
  45346. private _padSensibilityUp;
  45347. private _padSensibilityDown;
  45348. private _leftController;
  45349. private _rightController;
  45350. private _gazeColor;
  45351. private _laserColor;
  45352. private _pickedLaserColor;
  45353. private _pickedGazeColor;
  45354. /**
  45355. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45356. */
  45357. onNewMeshSelected: Observable<AbstractMesh>;
  45358. /**
  45359. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45360. * This observable will provide the mesh and the controller used to select the mesh
  45361. */
  45362. onMeshSelectedWithController: Observable<{
  45363. mesh: AbstractMesh;
  45364. controller: WebVRController;
  45365. }>;
  45366. /**
  45367. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45368. */
  45369. onNewMeshPicked: Observable<PickingInfo>;
  45370. private _circleEase;
  45371. /**
  45372. * Observable raised before camera teleportation
  45373. */
  45374. onBeforeCameraTeleport: Observable<Vector3>;
  45375. /**
  45376. * Observable raised after camera teleportation
  45377. */
  45378. onAfterCameraTeleport: Observable<Vector3>;
  45379. /**
  45380. * Observable raised when current selected mesh gets unselected
  45381. */
  45382. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45383. private _raySelectionPredicate;
  45384. /**
  45385. * To be optionaly changed by user to define custom ray selection
  45386. */
  45387. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45388. /**
  45389. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45390. */
  45391. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45392. /**
  45393. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45394. */
  45395. teleportationEnabled: boolean;
  45396. private _defaultHeight;
  45397. private _teleportationInitialized;
  45398. private _interactionsEnabled;
  45399. private _interactionsRequested;
  45400. private _displayGaze;
  45401. private _displayLaserPointer;
  45402. /**
  45403. * The mesh used to display where the user is going to teleport.
  45404. */
  45405. get teleportationTarget(): Mesh;
  45406. /**
  45407. * Sets the mesh to be used to display where the user is going to teleport.
  45408. */
  45409. set teleportationTarget(value: Mesh);
  45410. /**
  45411. * 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
  45412. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45413. * See http://doc.babylonjs.com/resources/baking_transformations
  45414. */
  45415. get gazeTrackerMesh(): Mesh;
  45416. set gazeTrackerMesh(value: Mesh);
  45417. /**
  45418. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45419. */
  45420. updateGazeTrackerScale: boolean;
  45421. /**
  45422. * If the gaze trackers color should be updated when selecting meshes
  45423. */
  45424. updateGazeTrackerColor: boolean;
  45425. /**
  45426. * If the controller laser color should be updated when selecting meshes
  45427. */
  45428. updateControllerLaserColor: boolean;
  45429. /**
  45430. * The gaze tracking mesh corresponding to the left controller
  45431. */
  45432. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45433. /**
  45434. * The gaze tracking mesh corresponding to the right controller
  45435. */
  45436. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45437. /**
  45438. * If the ray of the gaze should be displayed.
  45439. */
  45440. get displayGaze(): boolean;
  45441. /**
  45442. * Sets if the ray of the gaze should be displayed.
  45443. */
  45444. set displayGaze(value: boolean);
  45445. /**
  45446. * If the ray of the LaserPointer should be displayed.
  45447. */
  45448. get displayLaserPointer(): boolean;
  45449. /**
  45450. * Sets if the ray of the LaserPointer should be displayed.
  45451. */
  45452. set displayLaserPointer(value: boolean);
  45453. /**
  45454. * The deviceOrientationCamera used as the camera when not in VR.
  45455. */
  45456. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45457. /**
  45458. * Based on the current WebVR support, returns the current VR camera used.
  45459. */
  45460. get currentVRCamera(): Nullable<Camera>;
  45461. /**
  45462. * The webVRCamera which is used when in VR.
  45463. */
  45464. get webVRCamera(): WebVRFreeCamera;
  45465. /**
  45466. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45467. */
  45468. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45469. /**
  45470. * The html button that is used to trigger entering into VR.
  45471. */
  45472. get vrButton(): Nullable<HTMLButtonElement>;
  45473. private get _teleportationRequestInitiated();
  45474. /**
  45475. * Defines whether or not Pointer lock should be requested when switching to
  45476. * full screen.
  45477. */
  45478. requestPointerLockOnFullScreen: boolean;
  45479. /**
  45480. * If asking to force XR, this will be populated with the default xr experience
  45481. */
  45482. xr: WebXRDefaultExperience;
  45483. /**
  45484. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45485. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45486. */
  45487. xrTestDone: boolean;
  45488. /**
  45489. * Instantiates a VRExperienceHelper.
  45490. * Helps to quickly add VR support to an existing scene.
  45491. * @param scene The scene the VRExperienceHelper belongs to.
  45492. * @param webVROptions Options to modify the vr experience helper's behavior.
  45493. */
  45494. constructor(scene: Scene,
  45495. /** Options to modify the vr experience helper's behavior. */
  45496. webVROptions?: VRExperienceHelperOptions);
  45497. private completeVRInit;
  45498. private _onDefaultMeshLoaded;
  45499. private _onResize;
  45500. private _onFullscreenChange;
  45501. /**
  45502. * Gets a value indicating if we are currently in VR mode.
  45503. */
  45504. get isInVRMode(): boolean;
  45505. private onVrDisplayPresentChange;
  45506. private onVRDisplayChanged;
  45507. private moveButtonToBottomRight;
  45508. private displayVRButton;
  45509. private updateButtonVisibility;
  45510. private _cachedAngularSensibility;
  45511. /**
  45512. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45513. * Otherwise, will use the fullscreen API.
  45514. */
  45515. enterVR(): void;
  45516. /**
  45517. * Attempt to exit VR, or fullscreen.
  45518. */
  45519. exitVR(): void;
  45520. /**
  45521. * The position of the vr experience helper.
  45522. */
  45523. get position(): Vector3;
  45524. /**
  45525. * Sets the position of the vr experience helper.
  45526. */
  45527. set position(value: Vector3);
  45528. /**
  45529. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45530. */
  45531. enableInteractions(): void;
  45532. private get _noControllerIsActive();
  45533. private beforeRender;
  45534. private _isTeleportationFloor;
  45535. /**
  45536. * Adds a floor mesh to be used for teleportation.
  45537. * @param floorMesh the mesh to be used for teleportation.
  45538. */
  45539. addFloorMesh(floorMesh: Mesh): void;
  45540. /**
  45541. * Removes a floor mesh from being used for teleportation.
  45542. * @param floorMesh the mesh to be removed.
  45543. */
  45544. removeFloorMesh(floorMesh: Mesh): void;
  45545. /**
  45546. * Enables interactions and teleportation using the VR controllers and gaze.
  45547. * @param vrTeleportationOptions options to modify teleportation behavior.
  45548. */
  45549. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45550. private _onNewGamepadConnected;
  45551. private _tryEnableInteractionOnController;
  45552. private _onNewGamepadDisconnected;
  45553. private _enableInteractionOnController;
  45554. private _checkTeleportWithRay;
  45555. private _checkRotate;
  45556. private _checkTeleportBackwards;
  45557. private _enableTeleportationOnController;
  45558. private _createTeleportationCircles;
  45559. private _displayTeleportationTarget;
  45560. private _hideTeleportationTarget;
  45561. private _rotateCamera;
  45562. private _moveTeleportationSelectorTo;
  45563. private _workingVector;
  45564. private _workingQuaternion;
  45565. private _workingMatrix;
  45566. /**
  45567. * Time Constant Teleportation Mode
  45568. */
  45569. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45570. /**
  45571. * Speed Constant Teleportation Mode
  45572. */
  45573. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45574. /**
  45575. * Teleports the users feet to the desired location
  45576. * @param location The location where the user's feet should be placed
  45577. */
  45578. teleportCamera(location: Vector3): void;
  45579. private _convertNormalToDirectionOfRay;
  45580. private _castRayAndSelectObject;
  45581. private _notifySelectedMeshUnselected;
  45582. /**
  45583. * Permanently set new colors for the laser pointer
  45584. * @param color the new laser color
  45585. * @param pickedColor the new laser color when picked mesh detected
  45586. */
  45587. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45588. /**
  45589. * Set lighting enabled / disabled on the laser pointer of both controllers
  45590. * @param enabled should the lighting be enabled on the laser pointer
  45591. */
  45592. setLaserLightingState(enabled?: boolean): void;
  45593. /**
  45594. * Permanently set new colors for the gaze pointer
  45595. * @param color the new gaze color
  45596. * @param pickedColor the new gaze color when picked mesh detected
  45597. */
  45598. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45599. /**
  45600. * Sets the color of the laser ray from the vr controllers.
  45601. * @param color new color for the ray.
  45602. */
  45603. changeLaserColor(color: Color3): void;
  45604. /**
  45605. * Sets the color of the ray from the vr headsets gaze.
  45606. * @param color new color for the ray.
  45607. */
  45608. changeGazeColor(color: Color3): void;
  45609. /**
  45610. * Exits VR and disposes of the vr experience helper
  45611. */
  45612. dispose(): void;
  45613. /**
  45614. * Gets the name of the VRExperienceHelper class
  45615. * @returns "VRExperienceHelper"
  45616. */
  45617. getClassName(): string;
  45618. }
  45619. }
  45620. declare module BABYLON {
  45621. /**
  45622. * Contains an array of blocks representing the octree
  45623. */
  45624. export interface IOctreeContainer<T> {
  45625. /**
  45626. * Blocks within the octree
  45627. */
  45628. blocks: Array<OctreeBlock<T>>;
  45629. }
  45630. /**
  45631. * Class used to store a cell in an octree
  45632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45633. */
  45634. export class OctreeBlock<T> {
  45635. /**
  45636. * Gets the content of the current block
  45637. */
  45638. entries: T[];
  45639. /**
  45640. * Gets the list of block children
  45641. */
  45642. blocks: Array<OctreeBlock<T>>;
  45643. private _depth;
  45644. private _maxDepth;
  45645. private _capacity;
  45646. private _minPoint;
  45647. private _maxPoint;
  45648. private _boundingVectors;
  45649. private _creationFunc;
  45650. /**
  45651. * Creates a new block
  45652. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45653. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45654. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45655. * @param depth defines the current depth of this block in the octree
  45656. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45657. * @param creationFunc defines a callback to call when an element is added to the block
  45658. */
  45659. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45660. /**
  45661. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45662. */
  45663. get capacity(): number;
  45664. /**
  45665. * Gets the minimum vector (in world space) of the block's bounding box
  45666. */
  45667. get minPoint(): Vector3;
  45668. /**
  45669. * Gets the maximum vector (in world space) of the block's bounding box
  45670. */
  45671. get maxPoint(): Vector3;
  45672. /**
  45673. * Add a new element to this block
  45674. * @param entry defines the element to add
  45675. */
  45676. addEntry(entry: T): void;
  45677. /**
  45678. * Remove an element from this block
  45679. * @param entry defines the element to remove
  45680. */
  45681. removeEntry(entry: T): void;
  45682. /**
  45683. * Add an array of elements to this block
  45684. * @param entries defines the array of elements to add
  45685. */
  45686. addEntries(entries: T[]): void;
  45687. /**
  45688. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45689. * @param frustumPlanes defines the frustum planes to test
  45690. * @param selection defines the array to store current content if selection is positive
  45691. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45692. */
  45693. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45694. /**
  45695. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45696. * @param sphereCenter defines the bounding sphere center
  45697. * @param sphereRadius defines the bounding sphere radius
  45698. * @param selection defines the array to store current content if selection is positive
  45699. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45700. */
  45701. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45702. /**
  45703. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45704. * @param ray defines the ray to test with
  45705. * @param selection defines the array to store current content if selection is positive
  45706. */
  45707. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45708. /**
  45709. * Subdivide the content into child blocks (this block will then be empty)
  45710. */
  45711. createInnerBlocks(): void;
  45712. /**
  45713. * @hidden
  45714. */
  45715. 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;
  45716. }
  45717. }
  45718. declare module BABYLON {
  45719. /**
  45720. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45721. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45722. */
  45723. export class Octree<T> {
  45724. /** 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.) */
  45725. maxDepth: number;
  45726. /**
  45727. * Blocks within the octree containing objects
  45728. */
  45729. blocks: Array<OctreeBlock<T>>;
  45730. /**
  45731. * Content stored in the octree
  45732. */
  45733. dynamicContent: T[];
  45734. private _maxBlockCapacity;
  45735. private _selectionContent;
  45736. private _creationFunc;
  45737. /**
  45738. * Creates a octree
  45739. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45740. * @param creationFunc function to be used to instatiate the octree
  45741. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45742. * @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.)
  45743. */
  45744. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45745. /** 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.) */
  45746. maxDepth?: number);
  45747. /**
  45748. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45749. * @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);
  45750. * @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);
  45751. * @param entries meshes to be added to the octree blocks
  45752. */
  45753. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45754. /**
  45755. * Adds a mesh to the octree
  45756. * @param entry Mesh to add to the octree
  45757. */
  45758. addMesh(entry: T): void;
  45759. /**
  45760. * Remove an element from the octree
  45761. * @param entry defines the element to remove
  45762. */
  45763. removeMesh(entry: T): void;
  45764. /**
  45765. * Selects an array of meshes within the frustum
  45766. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45767. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45768. * @returns array of meshes within the frustum
  45769. */
  45770. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45771. /**
  45772. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45773. * @param sphereCenter defines the bounding sphere center
  45774. * @param sphereRadius defines the bounding sphere radius
  45775. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45776. * @returns an array of objects that intersect the sphere
  45777. */
  45778. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45779. /**
  45780. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45781. * @param ray defines the ray to test with
  45782. * @returns array of intersected objects
  45783. */
  45784. intersectsRay(ray: Ray): SmartArray<T>;
  45785. /**
  45786. * Adds a mesh into the octree block if it intersects the block
  45787. */
  45788. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45789. /**
  45790. * Adds a submesh into the octree block if it intersects the block
  45791. */
  45792. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45793. }
  45794. }
  45795. declare module BABYLON {
  45796. interface Scene {
  45797. /**
  45798. * @hidden
  45799. * Backing Filed
  45800. */
  45801. _selectionOctree: Octree<AbstractMesh>;
  45802. /**
  45803. * Gets the octree used to boost mesh selection (picking)
  45804. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45805. */
  45806. selectionOctree: Octree<AbstractMesh>;
  45807. /**
  45808. * Creates or updates the octree used to boost selection (picking)
  45809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45810. * @param maxCapacity defines the maximum capacity per leaf
  45811. * @param maxDepth defines the maximum depth of the octree
  45812. * @returns an octree of AbstractMesh
  45813. */
  45814. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45815. }
  45816. interface AbstractMesh {
  45817. /**
  45818. * @hidden
  45819. * Backing Field
  45820. */
  45821. _submeshesOctree: Octree<SubMesh>;
  45822. /**
  45823. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45824. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45825. * @param maxCapacity defines the maximum size of each block (64 by default)
  45826. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45827. * @returns the new octree
  45828. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45829. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45830. */
  45831. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45832. }
  45833. /**
  45834. * Defines the octree scene component responsible to manage any octrees
  45835. * in a given scene.
  45836. */
  45837. export class OctreeSceneComponent {
  45838. /**
  45839. * The component name help to identify the component in the list of scene components.
  45840. */
  45841. readonly name: string;
  45842. /**
  45843. * The scene the component belongs to.
  45844. */
  45845. scene: Scene;
  45846. /**
  45847. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45848. */
  45849. readonly checksIsEnabled: boolean;
  45850. /**
  45851. * Creates a new instance of the component for the given scene
  45852. * @param scene Defines the scene to register the component in
  45853. */
  45854. constructor(scene: Scene);
  45855. /**
  45856. * Registers the component in a given scene
  45857. */
  45858. register(): void;
  45859. /**
  45860. * Return the list of active meshes
  45861. * @returns the list of active meshes
  45862. */
  45863. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45864. /**
  45865. * Return the list of active sub meshes
  45866. * @param mesh The mesh to get the candidates sub meshes from
  45867. * @returns the list of active sub meshes
  45868. */
  45869. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45870. private _tempRay;
  45871. /**
  45872. * Return the list of sub meshes intersecting with a given local ray
  45873. * @param mesh defines the mesh to find the submesh for
  45874. * @param localRay defines the ray in local space
  45875. * @returns the list of intersecting sub meshes
  45876. */
  45877. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45878. /**
  45879. * Return the list of sub meshes colliding with a collider
  45880. * @param mesh defines the mesh to find the submesh for
  45881. * @param collider defines the collider to evaluate the collision against
  45882. * @returns the list of colliding sub meshes
  45883. */
  45884. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45885. /**
  45886. * Rebuilds the elements related to this component in case of
  45887. * context lost for instance.
  45888. */
  45889. rebuild(): void;
  45890. /**
  45891. * Disposes the component and the associated ressources.
  45892. */
  45893. dispose(): void;
  45894. }
  45895. }
  45896. declare module BABYLON {
  45897. /**
  45898. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45899. */
  45900. export class Gizmo implements IDisposable {
  45901. /** The utility layer the gizmo will be added to */
  45902. gizmoLayer: UtilityLayerRenderer;
  45903. /**
  45904. * The root mesh of the gizmo
  45905. */
  45906. _rootMesh: Mesh;
  45907. private _attachedMesh;
  45908. /**
  45909. * Ratio for the scale of the gizmo (Default: 1)
  45910. */
  45911. scaleRatio: number;
  45912. /**
  45913. * If a custom mesh has been set (Default: false)
  45914. */
  45915. protected _customMeshSet: boolean;
  45916. /**
  45917. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45918. * * When set, interactions will be enabled
  45919. */
  45920. get attachedMesh(): Nullable<AbstractMesh>;
  45921. set attachedMesh(value: Nullable<AbstractMesh>);
  45922. /**
  45923. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45924. * @param mesh The mesh to replace the default mesh of the gizmo
  45925. */
  45926. setCustomMesh(mesh: Mesh): void;
  45927. /**
  45928. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45929. */
  45930. updateGizmoRotationToMatchAttachedMesh: boolean;
  45931. /**
  45932. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45933. */
  45934. updateGizmoPositionToMatchAttachedMesh: boolean;
  45935. /**
  45936. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45937. */
  45938. updateScale: boolean;
  45939. protected _interactionsEnabled: boolean;
  45940. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45941. private _beforeRenderObserver;
  45942. private _tempVector;
  45943. /**
  45944. * Creates a gizmo
  45945. * @param gizmoLayer The utility layer the gizmo will be added to
  45946. */
  45947. constructor(
  45948. /** The utility layer the gizmo will be added to */
  45949. gizmoLayer?: UtilityLayerRenderer);
  45950. /**
  45951. * Updates the gizmo to match the attached mesh's position/rotation
  45952. */
  45953. protected _update(): void;
  45954. /**
  45955. * Disposes of the gizmo
  45956. */
  45957. dispose(): void;
  45958. }
  45959. }
  45960. declare module BABYLON {
  45961. /**
  45962. * Single plane drag gizmo
  45963. */
  45964. export class PlaneDragGizmo extends Gizmo {
  45965. /**
  45966. * Drag behavior responsible for the gizmos dragging interactions
  45967. */
  45968. dragBehavior: PointerDragBehavior;
  45969. private _pointerObserver;
  45970. /**
  45971. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45972. */
  45973. snapDistance: number;
  45974. /**
  45975. * Event that fires each time the gizmo snaps to a new location.
  45976. * * snapDistance is the the change in distance
  45977. */
  45978. onSnapObservable: Observable<{
  45979. snapDistance: number;
  45980. }>;
  45981. private _plane;
  45982. private _coloredMaterial;
  45983. private _hoverMaterial;
  45984. private _isEnabled;
  45985. private _parent;
  45986. /** @hidden */
  45987. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45988. /** @hidden */
  45989. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45990. /**
  45991. * Creates a PlaneDragGizmo
  45992. * @param gizmoLayer The utility layer the gizmo will be added to
  45993. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45994. * @param color The color of the gizmo
  45995. */
  45996. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45997. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45998. /**
  45999. * If the gizmo is enabled
  46000. */
  46001. set isEnabled(value: boolean);
  46002. get isEnabled(): boolean;
  46003. /**
  46004. * Disposes of the gizmo
  46005. */
  46006. dispose(): void;
  46007. }
  46008. }
  46009. declare module BABYLON {
  46010. /**
  46011. * Gizmo that enables dragging a mesh along 3 axis
  46012. */
  46013. export class PositionGizmo extends Gizmo {
  46014. /**
  46015. * Internal gizmo used for interactions on the x axis
  46016. */
  46017. xGizmo: AxisDragGizmo;
  46018. /**
  46019. * Internal gizmo used for interactions on the y axis
  46020. */
  46021. yGizmo: AxisDragGizmo;
  46022. /**
  46023. * Internal gizmo used for interactions on the z axis
  46024. */
  46025. zGizmo: AxisDragGizmo;
  46026. /**
  46027. * Internal gizmo used for interactions on the yz plane
  46028. */
  46029. xPlaneGizmo: PlaneDragGizmo;
  46030. /**
  46031. * Internal gizmo used for interactions on the xz plane
  46032. */
  46033. yPlaneGizmo: PlaneDragGizmo;
  46034. /**
  46035. * Internal gizmo used for interactions on the xy plane
  46036. */
  46037. zPlaneGizmo: PlaneDragGizmo;
  46038. /**
  46039. * private variables
  46040. */
  46041. private _meshAttached;
  46042. private _updateGizmoRotationToMatchAttachedMesh;
  46043. private _snapDistance;
  46044. private _scaleRatio;
  46045. /** Fires an event when any of it's sub gizmos are dragged */
  46046. onDragStartObservable: Observable<unknown>;
  46047. /** Fires an event when any of it's sub gizmos are released from dragging */
  46048. onDragEndObservable: Observable<unknown>;
  46049. /**
  46050. * If set to true, planar drag is enabled
  46051. */
  46052. private _planarGizmoEnabled;
  46053. get attachedMesh(): Nullable<AbstractMesh>;
  46054. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46055. /**
  46056. * Creates a PositionGizmo
  46057. * @param gizmoLayer The utility layer the gizmo will be added to
  46058. */
  46059. constructor(gizmoLayer?: UtilityLayerRenderer);
  46060. /**
  46061. * If the planar drag gizmo is enabled
  46062. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46063. */
  46064. set planarGizmoEnabled(value: boolean);
  46065. get planarGizmoEnabled(): boolean;
  46066. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46067. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46068. /**
  46069. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46070. */
  46071. set snapDistance(value: number);
  46072. get snapDistance(): number;
  46073. /**
  46074. * Ratio for the scale of the gizmo (Default: 1)
  46075. */
  46076. set scaleRatio(value: number);
  46077. get scaleRatio(): number;
  46078. /**
  46079. * Disposes of the gizmo
  46080. */
  46081. dispose(): void;
  46082. /**
  46083. * CustomMeshes are not supported by this gizmo
  46084. * @param mesh The mesh to replace the default mesh of the gizmo
  46085. */
  46086. setCustomMesh(mesh: Mesh): void;
  46087. }
  46088. }
  46089. declare module BABYLON {
  46090. /**
  46091. * Single axis drag gizmo
  46092. */
  46093. export class AxisDragGizmo extends Gizmo {
  46094. /**
  46095. * Drag behavior responsible for the gizmos dragging interactions
  46096. */
  46097. dragBehavior: PointerDragBehavior;
  46098. private _pointerObserver;
  46099. /**
  46100. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46101. */
  46102. snapDistance: number;
  46103. /**
  46104. * Event that fires each time the gizmo snaps to a new location.
  46105. * * snapDistance is the the change in distance
  46106. */
  46107. onSnapObservable: Observable<{
  46108. snapDistance: number;
  46109. }>;
  46110. private _isEnabled;
  46111. private _parent;
  46112. private _arrow;
  46113. private _coloredMaterial;
  46114. private _hoverMaterial;
  46115. /** @hidden */
  46116. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46117. /** @hidden */
  46118. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46119. /**
  46120. * Creates an AxisDragGizmo
  46121. * @param gizmoLayer The utility layer the gizmo will be added to
  46122. * @param dragAxis The axis which the gizmo will be able to drag on
  46123. * @param color The color of the gizmo
  46124. */
  46125. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46126. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46127. /**
  46128. * If the gizmo is enabled
  46129. */
  46130. set isEnabled(value: boolean);
  46131. get isEnabled(): boolean;
  46132. /**
  46133. * Disposes of the gizmo
  46134. */
  46135. dispose(): void;
  46136. }
  46137. }
  46138. declare module BABYLON.Debug {
  46139. /**
  46140. * The Axes viewer will show 3 axes in a specific point in space
  46141. */
  46142. export class AxesViewer {
  46143. private _xAxis;
  46144. private _yAxis;
  46145. private _zAxis;
  46146. private _scaleLinesFactor;
  46147. private _instanced;
  46148. /**
  46149. * Gets the hosting scene
  46150. */
  46151. scene: Scene;
  46152. /**
  46153. * Gets or sets a number used to scale line length
  46154. */
  46155. scaleLines: number;
  46156. /** Gets the node hierarchy used to render x-axis */
  46157. get xAxis(): TransformNode;
  46158. /** Gets the node hierarchy used to render y-axis */
  46159. get yAxis(): TransformNode;
  46160. /** Gets the node hierarchy used to render z-axis */
  46161. get zAxis(): TransformNode;
  46162. /**
  46163. * Creates a new AxesViewer
  46164. * @param scene defines the hosting scene
  46165. * @param scaleLines defines a number used to scale line length (1 by default)
  46166. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46167. * @param xAxis defines the node hierarchy used to render the x-axis
  46168. * @param yAxis defines the node hierarchy used to render the y-axis
  46169. * @param zAxis defines the node hierarchy used to render the z-axis
  46170. */
  46171. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46172. /**
  46173. * Force the viewer to update
  46174. * @param position defines the position of the viewer
  46175. * @param xaxis defines the x axis of the viewer
  46176. * @param yaxis defines the y axis of the viewer
  46177. * @param zaxis defines the z axis of the viewer
  46178. */
  46179. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46180. /**
  46181. * Creates an instance of this axes viewer.
  46182. * @returns a new axes viewer with instanced meshes
  46183. */
  46184. createInstance(): AxesViewer;
  46185. /** Releases resources */
  46186. dispose(): void;
  46187. private static _SetRenderingGroupId;
  46188. }
  46189. }
  46190. declare module BABYLON.Debug {
  46191. /**
  46192. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46193. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46194. */
  46195. export class BoneAxesViewer extends AxesViewer {
  46196. /**
  46197. * Gets or sets the target mesh where to display the axes viewer
  46198. */
  46199. mesh: Nullable<Mesh>;
  46200. /**
  46201. * Gets or sets the target bone where to display the axes viewer
  46202. */
  46203. bone: Nullable<Bone>;
  46204. /** Gets current position */
  46205. pos: Vector3;
  46206. /** Gets direction of X axis */
  46207. xaxis: Vector3;
  46208. /** Gets direction of Y axis */
  46209. yaxis: Vector3;
  46210. /** Gets direction of Z axis */
  46211. zaxis: Vector3;
  46212. /**
  46213. * Creates a new BoneAxesViewer
  46214. * @param scene defines the hosting scene
  46215. * @param bone defines the target bone
  46216. * @param mesh defines the target mesh
  46217. * @param scaleLines defines a scaling factor for line length (1 by default)
  46218. */
  46219. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46220. /**
  46221. * Force the viewer to update
  46222. */
  46223. update(): void;
  46224. /** Releases resources */
  46225. dispose(): void;
  46226. }
  46227. }
  46228. declare module BABYLON {
  46229. /**
  46230. * Interface used to define scene explorer extensibility option
  46231. */
  46232. export interface IExplorerExtensibilityOption {
  46233. /**
  46234. * Define the option label
  46235. */
  46236. label: string;
  46237. /**
  46238. * Defines the action to execute on click
  46239. */
  46240. action: (entity: any) => void;
  46241. }
  46242. /**
  46243. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46244. */
  46245. export interface IExplorerExtensibilityGroup {
  46246. /**
  46247. * Defines a predicate to test if a given type mut be extended
  46248. */
  46249. predicate: (entity: any) => boolean;
  46250. /**
  46251. * Gets the list of options added to a type
  46252. */
  46253. entries: IExplorerExtensibilityOption[];
  46254. }
  46255. /**
  46256. * Interface used to define the options to use to create the Inspector
  46257. */
  46258. export interface IInspectorOptions {
  46259. /**
  46260. * Display in overlay mode (default: false)
  46261. */
  46262. overlay?: boolean;
  46263. /**
  46264. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46265. */
  46266. globalRoot?: HTMLElement;
  46267. /**
  46268. * Display the Scene explorer
  46269. */
  46270. showExplorer?: boolean;
  46271. /**
  46272. * Display the property inspector
  46273. */
  46274. showInspector?: boolean;
  46275. /**
  46276. * Display in embed mode (both panes on the right)
  46277. */
  46278. embedMode?: boolean;
  46279. /**
  46280. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46281. */
  46282. handleResize?: boolean;
  46283. /**
  46284. * Allow the panes to popup (default: true)
  46285. */
  46286. enablePopup?: boolean;
  46287. /**
  46288. * Allow the panes to be closed by users (default: true)
  46289. */
  46290. enableClose?: boolean;
  46291. /**
  46292. * Optional list of extensibility entries
  46293. */
  46294. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46295. /**
  46296. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46297. */
  46298. inspectorURL?: string;
  46299. /**
  46300. * Optional initial tab (default to DebugLayerTab.Properties)
  46301. */
  46302. initialTab?: DebugLayerTab;
  46303. }
  46304. interface Scene {
  46305. /**
  46306. * @hidden
  46307. * Backing field
  46308. */
  46309. _debugLayer: DebugLayer;
  46310. /**
  46311. * Gets the debug layer (aka Inspector) associated with the scene
  46312. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46313. */
  46314. debugLayer: DebugLayer;
  46315. }
  46316. /**
  46317. * Enum of inspector action tab
  46318. */
  46319. export enum DebugLayerTab {
  46320. /**
  46321. * Properties tag (default)
  46322. */
  46323. Properties = 0,
  46324. /**
  46325. * Debug tab
  46326. */
  46327. Debug = 1,
  46328. /**
  46329. * Statistics tab
  46330. */
  46331. Statistics = 2,
  46332. /**
  46333. * Tools tab
  46334. */
  46335. Tools = 3,
  46336. /**
  46337. * Settings tab
  46338. */
  46339. Settings = 4
  46340. }
  46341. /**
  46342. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46343. * what is happening in your scene
  46344. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46345. */
  46346. export class DebugLayer {
  46347. /**
  46348. * Define the url to get the inspector script from.
  46349. * By default it uses the babylonjs CDN.
  46350. * @ignoreNaming
  46351. */
  46352. static InspectorURL: string;
  46353. private _scene;
  46354. private BJSINSPECTOR;
  46355. private _onPropertyChangedObservable?;
  46356. /**
  46357. * Observable triggered when a property is changed through the inspector.
  46358. */
  46359. get onPropertyChangedObservable(): any;
  46360. /**
  46361. * Instantiates a new debug layer.
  46362. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46363. * what is happening in your scene
  46364. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46365. * @param scene Defines the scene to inspect
  46366. */
  46367. constructor(scene: Scene);
  46368. /** Creates the inspector window. */
  46369. private _createInspector;
  46370. /**
  46371. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46372. * @param entity defines the entity to select
  46373. * @param lineContainerTitle defines the specific block to highlight
  46374. */
  46375. select(entity: any, lineContainerTitle?: string): void;
  46376. /** Get the inspector from bundle or global */
  46377. private _getGlobalInspector;
  46378. /**
  46379. * Get if the inspector is visible or not.
  46380. * @returns true if visible otherwise, false
  46381. */
  46382. isVisible(): boolean;
  46383. /**
  46384. * Hide the inspector and close its window.
  46385. */
  46386. hide(): void;
  46387. /**
  46388. * Launch the debugLayer.
  46389. * @param config Define the configuration of the inspector
  46390. * @return a promise fulfilled when the debug layer is visible
  46391. */
  46392. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46393. }
  46394. }
  46395. declare module BABYLON {
  46396. /**
  46397. * Class containing static functions to help procedurally build meshes
  46398. */
  46399. export class BoxBuilder {
  46400. /**
  46401. * Creates a box mesh
  46402. * * The parameter `size` sets the size (float) of each box side (default 1)
  46403. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46404. * * 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)
  46405. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46407. * * 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
  46408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46409. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46410. * @param name defines the name of the mesh
  46411. * @param options defines the options used to create the mesh
  46412. * @param scene defines the hosting scene
  46413. * @returns the box mesh
  46414. */
  46415. static CreateBox(name: string, options: {
  46416. size?: number;
  46417. width?: number;
  46418. height?: number;
  46419. depth?: number;
  46420. faceUV?: Vector4[];
  46421. faceColors?: Color4[];
  46422. sideOrientation?: number;
  46423. frontUVs?: Vector4;
  46424. backUVs?: Vector4;
  46425. wrap?: boolean;
  46426. topBaseAt?: number;
  46427. bottomBaseAt?: number;
  46428. updatable?: boolean;
  46429. }, scene?: Nullable<Scene>): Mesh;
  46430. }
  46431. }
  46432. declare module BABYLON.Debug {
  46433. /**
  46434. * Used to show the physics impostor around the specific mesh
  46435. */
  46436. export class PhysicsViewer {
  46437. /** @hidden */
  46438. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46439. /** @hidden */
  46440. protected _meshes: Array<Nullable<AbstractMesh>>;
  46441. /** @hidden */
  46442. protected _scene: Nullable<Scene>;
  46443. /** @hidden */
  46444. protected _numMeshes: number;
  46445. /** @hidden */
  46446. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46447. private _renderFunction;
  46448. private _utilityLayer;
  46449. private _debugBoxMesh;
  46450. private _debugSphereMesh;
  46451. private _debugCylinderMesh;
  46452. private _debugMaterial;
  46453. private _debugMeshMeshes;
  46454. /**
  46455. * Creates a new PhysicsViewer
  46456. * @param scene defines the hosting scene
  46457. */
  46458. constructor(scene: Scene);
  46459. /** @hidden */
  46460. protected _updateDebugMeshes(): void;
  46461. /**
  46462. * Renders a specified physic impostor
  46463. * @param impostor defines the impostor to render
  46464. * @param targetMesh defines the mesh represented by the impostor
  46465. * @returns the new debug mesh used to render the impostor
  46466. */
  46467. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46468. /**
  46469. * Hides a specified physic impostor
  46470. * @param impostor defines the impostor to hide
  46471. */
  46472. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46473. private _getDebugMaterial;
  46474. private _getDebugBoxMesh;
  46475. private _getDebugSphereMesh;
  46476. private _getDebugCylinderMesh;
  46477. private _getDebugMeshMesh;
  46478. private _getDebugMesh;
  46479. /** Releases all resources */
  46480. dispose(): void;
  46481. }
  46482. }
  46483. declare module BABYLON {
  46484. /**
  46485. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46486. * in order to better appreciate the issue one might have.
  46487. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46488. */
  46489. export class RayHelper {
  46490. /**
  46491. * Defines the ray we are currently tryin to visualize.
  46492. */
  46493. ray: Nullable<Ray>;
  46494. private _renderPoints;
  46495. private _renderLine;
  46496. private _renderFunction;
  46497. private _scene;
  46498. private _updateToMeshFunction;
  46499. private _attachedToMesh;
  46500. private _meshSpaceDirection;
  46501. private _meshSpaceOrigin;
  46502. /**
  46503. * Helper function to create a colored helper in a scene in one line.
  46504. * @param ray Defines the ray we are currently tryin to visualize
  46505. * @param scene Defines the scene the ray is used in
  46506. * @param color Defines the color we want to see the ray in
  46507. * @returns The newly created ray helper.
  46508. */
  46509. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46510. /**
  46511. * Instantiate a new ray helper.
  46512. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46513. * in order to better appreciate the issue one might have.
  46514. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46515. * @param ray Defines the ray we are currently tryin to visualize
  46516. */
  46517. constructor(ray: Ray);
  46518. /**
  46519. * Shows the ray we are willing to debug.
  46520. * @param scene Defines the scene the ray needs to be rendered in
  46521. * @param color Defines the color the ray needs to be rendered in
  46522. */
  46523. show(scene: Scene, color?: Color3): void;
  46524. /**
  46525. * Hides the ray we are debugging.
  46526. */
  46527. hide(): void;
  46528. private _render;
  46529. /**
  46530. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46531. * @param mesh Defines the mesh we want the helper attached to
  46532. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46533. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46534. * @param length Defines the length of the ray
  46535. */
  46536. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46537. /**
  46538. * Detach the ray helper from the mesh it has previously been attached to.
  46539. */
  46540. detachFromMesh(): void;
  46541. private _updateToMesh;
  46542. /**
  46543. * Dispose the helper and release its associated resources.
  46544. */
  46545. dispose(): void;
  46546. }
  46547. }
  46548. declare module BABYLON.Debug {
  46549. /**
  46550. * Class used to render a debug view of a given skeleton
  46551. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46552. */
  46553. export class SkeletonViewer {
  46554. /** defines the skeleton to render */
  46555. skeleton: Skeleton;
  46556. /** defines the mesh attached to the skeleton */
  46557. mesh: AbstractMesh;
  46558. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46559. autoUpdateBonesMatrices: boolean;
  46560. /** defines the rendering group id to use with the viewer */
  46561. renderingGroupId: number;
  46562. /** Gets or sets the color used to render the skeleton */
  46563. color: Color3;
  46564. private _scene;
  46565. private _debugLines;
  46566. private _debugMesh;
  46567. private _isEnabled;
  46568. private _renderFunction;
  46569. private _utilityLayer;
  46570. /**
  46571. * Returns the mesh used to render the bones
  46572. */
  46573. get debugMesh(): Nullable<LinesMesh>;
  46574. /**
  46575. * Creates a new SkeletonViewer
  46576. * @param skeleton defines the skeleton to render
  46577. * @param mesh defines the mesh attached to the skeleton
  46578. * @param scene defines the hosting scene
  46579. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46580. * @param renderingGroupId defines the rendering group id to use with the viewer
  46581. */
  46582. constructor(
  46583. /** defines the skeleton to render */
  46584. skeleton: Skeleton,
  46585. /** defines the mesh attached to the skeleton */
  46586. mesh: AbstractMesh, scene: Scene,
  46587. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46588. autoUpdateBonesMatrices?: boolean,
  46589. /** defines the rendering group id to use with the viewer */
  46590. renderingGroupId?: number);
  46591. /** Gets or sets a boolean indicating if the viewer is enabled */
  46592. set isEnabled(value: boolean);
  46593. get isEnabled(): boolean;
  46594. private _getBonePosition;
  46595. private _getLinesForBonesWithLength;
  46596. private _getLinesForBonesNoLength;
  46597. /** Update the viewer to sync with current skeleton state */
  46598. update(): void;
  46599. /** Release associated resources */
  46600. dispose(): void;
  46601. }
  46602. }
  46603. declare module BABYLON {
  46604. /**
  46605. * Options to create the null engine
  46606. */
  46607. export class NullEngineOptions {
  46608. /**
  46609. * Render width (Default: 512)
  46610. */
  46611. renderWidth: number;
  46612. /**
  46613. * Render height (Default: 256)
  46614. */
  46615. renderHeight: number;
  46616. /**
  46617. * Texture size (Default: 512)
  46618. */
  46619. textureSize: number;
  46620. /**
  46621. * If delta time between frames should be constant
  46622. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46623. */
  46624. deterministicLockstep: boolean;
  46625. /**
  46626. * Maximum about of steps between frames (Default: 4)
  46627. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46628. */
  46629. lockstepMaxSteps: number;
  46630. }
  46631. /**
  46632. * The null engine class provides support for headless version of babylon.js.
  46633. * This can be used in server side scenario or for testing purposes
  46634. */
  46635. export class NullEngine extends Engine {
  46636. private _options;
  46637. /**
  46638. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46640. * @returns true if engine is in deterministic lock step mode
  46641. */
  46642. isDeterministicLockStep(): boolean;
  46643. /**
  46644. * Gets the max steps when engine is running in deterministic lock step
  46645. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46646. * @returns the max steps
  46647. */
  46648. getLockstepMaxSteps(): number;
  46649. /**
  46650. * Gets the current hardware scaling level.
  46651. * By default the hardware scaling level is computed from the window device ratio.
  46652. * 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.
  46653. * @returns a number indicating the current hardware scaling level
  46654. */
  46655. getHardwareScalingLevel(): number;
  46656. constructor(options?: NullEngineOptions);
  46657. /**
  46658. * Creates a vertex buffer
  46659. * @param vertices the data for the vertex buffer
  46660. * @returns the new WebGL static buffer
  46661. */
  46662. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46663. /**
  46664. * Creates a new index buffer
  46665. * @param indices defines the content of the index buffer
  46666. * @param updatable defines if the index buffer must be updatable
  46667. * @returns a new webGL buffer
  46668. */
  46669. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46670. /**
  46671. * Clear the current render buffer or the current render target (if any is set up)
  46672. * @param color defines the color to use
  46673. * @param backBuffer defines if the back buffer must be cleared
  46674. * @param depth defines if the depth buffer must be cleared
  46675. * @param stencil defines if the stencil buffer must be cleared
  46676. */
  46677. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46678. /**
  46679. * Gets the current render width
  46680. * @param useScreen defines if screen size must be used (or the current render target if any)
  46681. * @returns a number defining the current render width
  46682. */
  46683. getRenderWidth(useScreen?: boolean): number;
  46684. /**
  46685. * Gets the current render height
  46686. * @param useScreen defines if screen size must be used (or the current render target if any)
  46687. * @returns a number defining the current render height
  46688. */
  46689. getRenderHeight(useScreen?: boolean): number;
  46690. /**
  46691. * Set the WebGL's viewport
  46692. * @param viewport defines the viewport element to be used
  46693. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46694. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46695. */
  46696. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46697. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46698. /**
  46699. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46700. * @param pipelineContext defines the pipeline context to use
  46701. * @param uniformsNames defines the list of uniform names
  46702. * @returns an array of webGL uniform locations
  46703. */
  46704. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46705. /**
  46706. * Gets the lsit of active attributes for a given webGL program
  46707. * @param pipelineContext defines the pipeline context to use
  46708. * @param attributesNames defines the list of attribute names to get
  46709. * @returns an array of indices indicating the offset of each attribute
  46710. */
  46711. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46712. /**
  46713. * Binds an effect to the webGL context
  46714. * @param effect defines the effect to bind
  46715. */
  46716. bindSamplers(effect: Effect): void;
  46717. /**
  46718. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46719. * @param effect defines the effect to activate
  46720. */
  46721. enableEffect(effect: Effect): void;
  46722. /**
  46723. * Set various states to the webGL context
  46724. * @param culling defines backface culling state
  46725. * @param zOffset defines the value to apply to zOffset (0 by default)
  46726. * @param force defines if states must be applied even if cache is up to date
  46727. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46728. */
  46729. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46730. /**
  46731. * Set the value of an uniform to an array of int32
  46732. * @param uniform defines the webGL uniform location where to store the value
  46733. * @param array defines the array of int32 to store
  46734. */
  46735. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46736. /**
  46737. * Set the value of an uniform to an array of int32 (stored as vec2)
  46738. * @param uniform defines the webGL uniform location where to store the value
  46739. * @param array defines the array of int32 to store
  46740. */
  46741. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46742. /**
  46743. * Set the value of an uniform to an array of int32 (stored as vec3)
  46744. * @param uniform defines the webGL uniform location where to store the value
  46745. * @param array defines the array of int32 to store
  46746. */
  46747. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46748. /**
  46749. * Set the value of an uniform to an array of int32 (stored as vec4)
  46750. * @param uniform defines the webGL uniform location where to store the value
  46751. * @param array defines the array of int32 to store
  46752. */
  46753. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46754. /**
  46755. * Set the value of an uniform to an array of float32
  46756. * @param uniform defines the webGL uniform location where to store the value
  46757. * @param array defines the array of float32 to store
  46758. */
  46759. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46760. /**
  46761. * Set the value of an uniform to an array of float32 (stored as vec2)
  46762. * @param uniform defines the webGL uniform location where to store the value
  46763. * @param array defines the array of float32 to store
  46764. */
  46765. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46766. /**
  46767. * Set the value of an uniform to an array of float32 (stored as vec3)
  46768. * @param uniform defines the webGL uniform location where to store the value
  46769. * @param array defines the array of float32 to store
  46770. */
  46771. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46772. /**
  46773. * Set the value of an uniform to an array of float32 (stored as vec4)
  46774. * @param uniform defines the webGL uniform location where to store the value
  46775. * @param array defines the array of float32 to store
  46776. */
  46777. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46778. /**
  46779. * Set the value of an uniform to an array of number
  46780. * @param uniform defines the webGL uniform location where to store the value
  46781. * @param array defines the array of number to store
  46782. */
  46783. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46784. /**
  46785. * Set the value of an uniform to an array of number (stored as vec2)
  46786. * @param uniform defines the webGL uniform location where to store the value
  46787. * @param array defines the array of number to store
  46788. */
  46789. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46790. /**
  46791. * Set the value of an uniform to an array of number (stored as vec3)
  46792. * @param uniform defines the webGL uniform location where to store the value
  46793. * @param array defines the array of number to store
  46794. */
  46795. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46796. /**
  46797. * Set the value of an uniform to an array of number (stored as vec4)
  46798. * @param uniform defines the webGL uniform location where to store the value
  46799. * @param array defines the array of number to store
  46800. */
  46801. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46802. /**
  46803. * Set the value of an uniform to an array of float32 (stored as matrices)
  46804. * @param uniform defines the webGL uniform location where to store the value
  46805. * @param matrices defines the array of float32 to store
  46806. */
  46807. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46808. /**
  46809. * Set the value of an uniform to a matrix (3x3)
  46810. * @param uniform defines the webGL uniform location where to store the value
  46811. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46812. */
  46813. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46814. /**
  46815. * Set the value of an uniform to a matrix (2x2)
  46816. * @param uniform defines the webGL uniform location where to store the value
  46817. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46818. */
  46819. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46820. /**
  46821. * Set the value of an uniform to a number (float)
  46822. * @param uniform defines the webGL uniform location where to store the value
  46823. * @param value defines the float number to store
  46824. */
  46825. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46826. /**
  46827. * Set the value of an uniform to a vec2
  46828. * @param uniform defines the webGL uniform location where to store the value
  46829. * @param x defines the 1st component of the value
  46830. * @param y defines the 2nd component of the value
  46831. */
  46832. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46833. /**
  46834. * Set the value of an uniform to a vec3
  46835. * @param uniform defines the webGL uniform location where to store the value
  46836. * @param x defines the 1st component of the value
  46837. * @param y defines the 2nd component of the value
  46838. * @param z defines the 3rd component of the value
  46839. */
  46840. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46841. /**
  46842. * Set the value of an uniform to a boolean
  46843. * @param uniform defines the webGL uniform location where to store the value
  46844. * @param bool defines the boolean to store
  46845. */
  46846. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46847. /**
  46848. * Set the value of an uniform to a vec4
  46849. * @param uniform defines the webGL uniform location where to store the value
  46850. * @param x defines the 1st component of the value
  46851. * @param y defines the 2nd component of the value
  46852. * @param z defines the 3rd component of the value
  46853. * @param w defines the 4th component of the value
  46854. */
  46855. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46856. /**
  46857. * Sets the current alpha mode
  46858. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46859. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46860. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46861. */
  46862. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46863. /**
  46864. * Bind webGl buffers directly to the webGL context
  46865. * @param vertexBuffers defines the vertex buffer to bind
  46866. * @param indexBuffer defines the index buffer to bind
  46867. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46868. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46869. * @param effect defines the effect associated with the vertex buffer
  46870. */
  46871. bindBuffers(vertexBuffers: {
  46872. [key: string]: VertexBuffer;
  46873. }, indexBuffer: DataBuffer, effect: Effect): void;
  46874. /**
  46875. * Force the entire cache to be cleared
  46876. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46877. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46878. */
  46879. wipeCaches(bruteForce?: boolean): void;
  46880. /**
  46881. * Send a draw order
  46882. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46883. * @param indexStart defines the starting index
  46884. * @param indexCount defines the number of index to draw
  46885. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46886. */
  46887. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46888. /**
  46889. * Draw a list of indexed primitives
  46890. * @param fillMode defines the primitive to use
  46891. * @param indexStart defines the starting index
  46892. * @param indexCount defines the number of index to draw
  46893. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46894. */
  46895. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46896. /**
  46897. * Draw a list of unindexed primitives
  46898. * @param fillMode defines the primitive to use
  46899. * @param verticesStart defines the index of first vertex to draw
  46900. * @param verticesCount defines the count of vertices to draw
  46901. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46902. */
  46903. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46904. /** @hidden */
  46905. _createTexture(): WebGLTexture;
  46906. /** @hidden */
  46907. _releaseTexture(texture: InternalTexture): void;
  46908. /**
  46909. * Usually called from Texture.ts.
  46910. * Passed information to create a WebGLTexture
  46911. * @param urlArg defines a value which contains one of the following:
  46912. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46913. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46914. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46915. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46916. * @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)
  46917. * @param scene needed for loading to the correct scene
  46918. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46919. * @param onLoad optional callback to be called upon successful completion
  46920. * @param onError optional callback to be called upon failure
  46921. * @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
  46922. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46923. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46924. * @param forcedExtension defines the extension to use to pick the right loader
  46925. * @param mimeType defines an optional mime type
  46926. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46927. */
  46928. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  46929. /**
  46930. * Creates a new render target texture
  46931. * @param size defines the size of the texture
  46932. * @param options defines the options used to create the texture
  46933. * @returns a new render target texture stored in an InternalTexture
  46934. */
  46935. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46936. /**
  46937. * Update the sampling mode of a given texture
  46938. * @param samplingMode defines the required sampling mode
  46939. * @param texture defines the texture to update
  46940. */
  46941. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46942. /**
  46943. * Binds the frame buffer to the specified texture.
  46944. * @param texture The texture to render to or null for the default canvas
  46945. * @param faceIndex The face of the texture to render to in case of cube texture
  46946. * @param requiredWidth The width of the target to render to
  46947. * @param requiredHeight The height of the target to render to
  46948. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46949. * @param lodLevel defines le lod level to bind to the frame buffer
  46950. */
  46951. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46952. /**
  46953. * Unbind the current render target texture from the webGL context
  46954. * @param texture defines the render target texture to unbind
  46955. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46956. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46957. */
  46958. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46959. /**
  46960. * Creates a dynamic vertex buffer
  46961. * @param vertices the data for the dynamic vertex buffer
  46962. * @returns the new WebGL dynamic buffer
  46963. */
  46964. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46965. /**
  46966. * Update the content of a dynamic texture
  46967. * @param texture defines the texture to update
  46968. * @param canvas defines the canvas containing the source
  46969. * @param invertY defines if data must be stored with Y axis inverted
  46970. * @param premulAlpha defines if alpha is stored as premultiplied
  46971. * @param format defines the format of the data
  46972. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46973. */
  46974. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46975. /**
  46976. * Gets a boolean indicating if all created effects are ready
  46977. * @returns true if all effects are ready
  46978. */
  46979. areAllEffectsReady(): boolean;
  46980. /**
  46981. * @hidden
  46982. * Get the current error code of the webGL context
  46983. * @returns the error code
  46984. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46985. */
  46986. getError(): number;
  46987. /** @hidden */
  46988. _getUnpackAlignement(): number;
  46989. /** @hidden */
  46990. _unpackFlipY(value: boolean): void;
  46991. /**
  46992. * Update a dynamic index buffer
  46993. * @param indexBuffer defines the target index buffer
  46994. * @param indices defines the data to update
  46995. * @param offset defines the offset in the target index buffer where update should start
  46996. */
  46997. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46998. /**
  46999. * Updates a dynamic vertex buffer.
  47000. * @param vertexBuffer the vertex buffer to update
  47001. * @param vertices the data used to update the vertex buffer
  47002. * @param byteOffset the byte offset of the data (optional)
  47003. * @param byteLength the byte length of the data (optional)
  47004. */
  47005. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47006. /** @hidden */
  47007. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47008. /** @hidden */
  47009. _bindTexture(channel: number, texture: InternalTexture): void;
  47010. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47011. /**
  47012. * 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
  47013. */
  47014. releaseEffects(): void;
  47015. displayLoadingUI(): void;
  47016. hideLoadingUI(): void;
  47017. /** @hidden */
  47018. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47019. /** @hidden */
  47020. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47021. /** @hidden */
  47022. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47023. /** @hidden */
  47024. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47025. }
  47026. }
  47027. declare module BABYLON {
  47028. /**
  47029. * @hidden
  47030. **/
  47031. export class _TimeToken {
  47032. _startTimeQuery: Nullable<WebGLQuery>;
  47033. _endTimeQuery: Nullable<WebGLQuery>;
  47034. _timeElapsedQuery: Nullable<WebGLQuery>;
  47035. _timeElapsedQueryEnded: boolean;
  47036. }
  47037. }
  47038. declare module BABYLON {
  47039. /** @hidden */
  47040. export class _OcclusionDataStorage {
  47041. /** @hidden */
  47042. occlusionInternalRetryCounter: number;
  47043. /** @hidden */
  47044. isOcclusionQueryInProgress: boolean;
  47045. /** @hidden */
  47046. isOccluded: boolean;
  47047. /** @hidden */
  47048. occlusionRetryCount: number;
  47049. /** @hidden */
  47050. occlusionType: number;
  47051. /** @hidden */
  47052. occlusionQueryAlgorithmType: number;
  47053. }
  47054. interface Engine {
  47055. /**
  47056. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47057. * @return the new query
  47058. */
  47059. createQuery(): WebGLQuery;
  47060. /**
  47061. * Delete and release a webGL query
  47062. * @param query defines the query to delete
  47063. * @return the current engine
  47064. */
  47065. deleteQuery(query: WebGLQuery): Engine;
  47066. /**
  47067. * Check if a given query has resolved and got its value
  47068. * @param query defines the query to check
  47069. * @returns true if the query got its value
  47070. */
  47071. isQueryResultAvailable(query: WebGLQuery): boolean;
  47072. /**
  47073. * Gets the value of a given query
  47074. * @param query defines the query to check
  47075. * @returns the value of the query
  47076. */
  47077. getQueryResult(query: WebGLQuery): number;
  47078. /**
  47079. * Initiates an occlusion query
  47080. * @param algorithmType defines the algorithm to use
  47081. * @param query defines the query to use
  47082. * @returns the current engine
  47083. * @see http://doc.babylonjs.com/features/occlusionquery
  47084. */
  47085. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47086. /**
  47087. * Ends an occlusion query
  47088. * @see http://doc.babylonjs.com/features/occlusionquery
  47089. * @param algorithmType defines the algorithm to use
  47090. * @returns the current engine
  47091. */
  47092. endOcclusionQuery(algorithmType: number): Engine;
  47093. /**
  47094. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47095. * Please note that only one query can be issued at a time
  47096. * @returns a time token used to track the time span
  47097. */
  47098. startTimeQuery(): Nullable<_TimeToken>;
  47099. /**
  47100. * Ends a time query
  47101. * @param token defines the token used to measure the time span
  47102. * @returns the time spent (in ns)
  47103. */
  47104. endTimeQuery(token: _TimeToken): int;
  47105. /** @hidden */
  47106. _currentNonTimestampToken: Nullable<_TimeToken>;
  47107. /** @hidden */
  47108. _createTimeQuery(): WebGLQuery;
  47109. /** @hidden */
  47110. _deleteTimeQuery(query: WebGLQuery): void;
  47111. /** @hidden */
  47112. _getGlAlgorithmType(algorithmType: number): number;
  47113. /** @hidden */
  47114. _getTimeQueryResult(query: WebGLQuery): any;
  47115. /** @hidden */
  47116. _getTimeQueryAvailability(query: WebGLQuery): any;
  47117. }
  47118. interface AbstractMesh {
  47119. /**
  47120. * Backing filed
  47121. * @hidden
  47122. */
  47123. __occlusionDataStorage: _OcclusionDataStorage;
  47124. /**
  47125. * Access property
  47126. * @hidden
  47127. */
  47128. _occlusionDataStorage: _OcclusionDataStorage;
  47129. /**
  47130. * 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.
  47131. * The default value is -1 which means don't break the query and wait till the result
  47132. * @see http://doc.babylonjs.com/features/occlusionquery
  47133. */
  47134. occlusionRetryCount: number;
  47135. /**
  47136. * 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:
  47137. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47138. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47139. * * 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.
  47140. * @see http://doc.babylonjs.com/features/occlusionquery
  47141. */
  47142. occlusionType: number;
  47143. /**
  47144. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47145. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47146. * * 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.
  47147. * @see http://doc.babylonjs.com/features/occlusionquery
  47148. */
  47149. occlusionQueryAlgorithmType: number;
  47150. /**
  47151. * 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
  47152. * @see http://doc.babylonjs.com/features/occlusionquery
  47153. */
  47154. isOccluded: boolean;
  47155. /**
  47156. * Flag to check the progress status of the query
  47157. * @see http://doc.babylonjs.com/features/occlusionquery
  47158. */
  47159. isOcclusionQueryInProgress: boolean;
  47160. }
  47161. }
  47162. declare module BABYLON {
  47163. /** @hidden */
  47164. export var _forceTransformFeedbackToBundle: boolean;
  47165. interface Engine {
  47166. /**
  47167. * Creates a webGL transform feedback object
  47168. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47169. * @returns the webGL transform feedback object
  47170. */
  47171. createTransformFeedback(): WebGLTransformFeedback;
  47172. /**
  47173. * Delete a webGL transform feedback object
  47174. * @param value defines the webGL transform feedback object to delete
  47175. */
  47176. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47177. /**
  47178. * Bind a webGL transform feedback object to the webgl context
  47179. * @param value defines the webGL transform feedback object to bind
  47180. */
  47181. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47182. /**
  47183. * Begins a transform feedback operation
  47184. * @param usePoints defines if points or triangles must be used
  47185. */
  47186. beginTransformFeedback(usePoints: boolean): void;
  47187. /**
  47188. * Ends a transform feedback operation
  47189. */
  47190. endTransformFeedback(): void;
  47191. /**
  47192. * Specify the varyings to use with transform feedback
  47193. * @param program defines the associated webGL program
  47194. * @param value defines the list of strings representing the varying names
  47195. */
  47196. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47197. /**
  47198. * Bind a webGL buffer for a transform feedback operation
  47199. * @param value defines the webGL buffer to bind
  47200. */
  47201. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47202. }
  47203. }
  47204. declare module BABYLON {
  47205. /**
  47206. * Creation options of the multi render target texture.
  47207. */
  47208. export interface IMultiRenderTargetOptions {
  47209. /**
  47210. * Define if the texture needs to create mip maps after render.
  47211. */
  47212. generateMipMaps?: boolean;
  47213. /**
  47214. * Define the types of all the draw buffers we want to create
  47215. */
  47216. types?: number[];
  47217. /**
  47218. * Define the sampling modes of all the draw buffers we want to create
  47219. */
  47220. samplingModes?: number[];
  47221. /**
  47222. * Define if a depth buffer is required
  47223. */
  47224. generateDepthBuffer?: boolean;
  47225. /**
  47226. * Define if a stencil buffer is required
  47227. */
  47228. generateStencilBuffer?: boolean;
  47229. /**
  47230. * Define if a depth texture is required instead of a depth buffer
  47231. */
  47232. generateDepthTexture?: boolean;
  47233. /**
  47234. * Define the number of desired draw buffers
  47235. */
  47236. textureCount?: number;
  47237. /**
  47238. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47239. */
  47240. doNotChangeAspectRatio?: boolean;
  47241. /**
  47242. * Define the default type of the buffers we are creating
  47243. */
  47244. defaultType?: number;
  47245. }
  47246. /**
  47247. * A multi render target, like a render target provides the ability to render to a texture.
  47248. * Unlike the render target, it can render to several draw buffers in one draw.
  47249. * This is specially interesting in deferred rendering or for any effects requiring more than
  47250. * just one color from a single pass.
  47251. */
  47252. export class MultiRenderTarget extends RenderTargetTexture {
  47253. private _internalTextures;
  47254. private _textures;
  47255. private _multiRenderTargetOptions;
  47256. /**
  47257. * Get if draw buffers are currently supported by the used hardware and browser.
  47258. */
  47259. get isSupported(): boolean;
  47260. /**
  47261. * Get the list of textures generated by the multi render target.
  47262. */
  47263. get textures(): Texture[];
  47264. /**
  47265. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47266. */
  47267. get depthTexture(): Texture;
  47268. /**
  47269. * Set the wrapping mode on U of all the textures we are rendering to.
  47270. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47271. */
  47272. set wrapU(wrap: number);
  47273. /**
  47274. * Set the wrapping mode on V of all the textures we are rendering to.
  47275. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47276. */
  47277. set wrapV(wrap: number);
  47278. /**
  47279. * Instantiate a new multi render target texture.
  47280. * A multi render target, like a render target provides the ability to render to a texture.
  47281. * Unlike the render target, it can render to several draw buffers in one draw.
  47282. * This is specially interesting in deferred rendering or for any effects requiring more than
  47283. * just one color from a single pass.
  47284. * @param name Define the name of the texture
  47285. * @param size Define the size of the buffers to render to
  47286. * @param count Define the number of target we are rendering into
  47287. * @param scene Define the scene the texture belongs to
  47288. * @param options Define the options used to create the multi render target
  47289. */
  47290. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47291. /** @hidden */
  47292. _rebuild(): void;
  47293. private _createInternalTextures;
  47294. private _createTextures;
  47295. /**
  47296. * Define the number of samples used if MSAA is enabled.
  47297. */
  47298. get samples(): number;
  47299. set samples(value: number);
  47300. /**
  47301. * Resize all the textures in the multi render target.
  47302. * Be carrefull as it will recreate all the data in the new texture.
  47303. * @param size Define the new size
  47304. */
  47305. resize(size: any): void;
  47306. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47307. /**
  47308. * Dispose the render targets and their associated resources
  47309. */
  47310. dispose(): void;
  47311. /**
  47312. * Release all the underlying texture used as draw buffers.
  47313. */
  47314. releaseInternalTextures(): void;
  47315. }
  47316. }
  47317. declare module BABYLON {
  47318. interface ThinEngine {
  47319. /**
  47320. * Unbind a list of render target textures from the webGL context
  47321. * This is used only when drawBuffer extension or webGL2 are active
  47322. * @param textures defines the render target textures to unbind
  47323. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47324. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47325. */
  47326. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47327. /**
  47328. * Create a multi render target texture
  47329. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47330. * @param size defines the size of the texture
  47331. * @param options defines the creation options
  47332. * @returns the cube texture as an InternalTexture
  47333. */
  47334. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47335. /**
  47336. * Update the sample count for a given multiple render target texture
  47337. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47338. * @param textures defines the textures to update
  47339. * @param samples defines the sample count to set
  47340. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47341. */
  47342. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47343. }
  47344. }
  47345. declare module BABYLON {
  47346. /**
  47347. * Class used to define an additional view for the engine
  47348. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47349. */
  47350. export class EngineView {
  47351. /** Defines the canvas where to render the view */
  47352. target: HTMLCanvasElement;
  47353. /** Defines an optional camera used to render the view (will use active camera else) */
  47354. camera?: Camera;
  47355. }
  47356. interface Engine {
  47357. /**
  47358. * Gets or sets the HTML element to use for attaching events
  47359. */
  47360. inputElement: Nullable<HTMLElement>;
  47361. /**
  47362. * Gets the current engine view
  47363. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47364. */
  47365. activeView: Nullable<EngineView>;
  47366. /** Gets or sets the list of views */
  47367. views: EngineView[];
  47368. /**
  47369. * Register a new child canvas
  47370. * @param canvas defines the canvas to register
  47371. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47372. * @returns the associated view
  47373. */
  47374. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47375. /**
  47376. * Remove a registered child canvas
  47377. * @param canvas defines the canvas to remove
  47378. * @returns the current engine
  47379. */
  47380. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47381. }
  47382. }
  47383. declare module BABYLON {
  47384. /**
  47385. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47386. */
  47387. export interface CubeMapInfo {
  47388. /**
  47389. * The pixel array for the front face.
  47390. * This is stored in format, left to right, up to down format.
  47391. */
  47392. front: Nullable<ArrayBufferView>;
  47393. /**
  47394. * The pixel array for the back face.
  47395. * This is stored in format, left to right, up to down format.
  47396. */
  47397. back: Nullable<ArrayBufferView>;
  47398. /**
  47399. * The pixel array for the left face.
  47400. * This is stored in format, left to right, up to down format.
  47401. */
  47402. left: Nullable<ArrayBufferView>;
  47403. /**
  47404. * The pixel array for the right face.
  47405. * This is stored in format, left to right, up to down format.
  47406. */
  47407. right: Nullable<ArrayBufferView>;
  47408. /**
  47409. * The pixel array for the up face.
  47410. * This is stored in format, left to right, up to down format.
  47411. */
  47412. up: Nullable<ArrayBufferView>;
  47413. /**
  47414. * The pixel array for the down face.
  47415. * This is stored in format, left to right, up to down format.
  47416. */
  47417. down: Nullable<ArrayBufferView>;
  47418. /**
  47419. * The size of the cubemap stored.
  47420. *
  47421. * Each faces will be size * size pixels.
  47422. */
  47423. size: number;
  47424. /**
  47425. * The format of the texture.
  47426. *
  47427. * RGBA, RGB.
  47428. */
  47429. format: number;
  47430. /**
  47431. * The type of the texture data.
  47432. *
  47433. * UNSIGNED_INT, FLOAT.
  47434. */
  47435. type: number;
  47436. /**
  47437. * Specifies whether the texture is in gamma space.
  47438. */
  47439. gammaSpace: boolean;
  47440. }
  47441. /**
  47442. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47443. */
  47444. export class PanoramaToCubeMapTools {
  47445. private static FACE_FRONT;
  47446. private static FACE_BACK;
  47447. private static FACE_RIGHT;
  47448. private static FACE_LEFT;
  47449. private static FACE_DOWN;
  47450. private static FACE_UP;
  47451. /**
  47452. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47453. *
  47454. * @param float32Array The source data.
  47455. * @param inputWidth The width of the input panorama.
  47456. * @param inputHeight The height of the input panorama.
  47457. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47458. * @return The cubemap data
  47459. */
  47460. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47461. private static CreateCubemapTexture;
  47462. private static CalcProjectionSpherical;
  47463. }
  47464. }
  47465. declare module BABYLON {
  47466. /**
  47467. * Helper class dealing with the extraction of spherical polynomial dataArray
  47468. * from a cube map.
  47469. */
  47470. export class CubeMapToSphericalPolynomialTools {
  47471. private static FileFaces;
  47472. /**
  47473. * Converts a texture to the according Spherical Polynomial data.
  47474. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47475. *
  47476. * @param texture The texture to extract the information from.
  47477. * @return The Spherical Polynomial data.
  47478. */
  47479. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47480. /**
  47481. * Converts a cubemap to the according Spherical Polynomial data.
  47482. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47483. *
  47484. * @param cubeInfo The Cube map to extract the information from.
  47485. * @return The Spherical Polynomial data.
  47486. */
  47487. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47488. }
  47489. }
  47490. declare module BABYLON {
  47491. interface BaseTexture {
  47492. /**
  47493. * Get the polynomial representation of the texture data.
  47494. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47495. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47496. */
  47497. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47498. }
  47499. }
  47500. declare module BABYLON {
  47501. /** @hidden */
  47502. export var rgbdEncodePixelShader: {
  47503. name: string;
  47504. shader: string;
  47505. };
  47506. }
  47507. declare module BABYLON {
  47508. /** @hidden */
  47509. export var rgbdDecodePixelShader: {
  47510. name: string;
  47511. shader: string;
  47512. };
  47513. }
  47514. declare module BABYLON {
  47515. /**
  47516. * Raw texture data and descriptor sufficient for WebGL texture upload
  47517. */
  47518. export interface EnvironmentTextureInfo {
  47519. /**
  47520. * Version of the environment map
  47521. */
  47522. version: number;
  47523. /**
  47524. * Width of image
  47525. */
  47526. width: number;
  47527. /**
  47528. * Irradiance information stored in the file.
  47529. */
  47530. irradiance: any;
  47531. /**
  47532. * Specular information stored in the file.
  47533. */
  47534. specular: any;
  47535. }
  47536. /**
  47537. * Defines One Image in the file. It requires only the position in the file
  47538. * as well as the length.
  47539. */
  47540. interface BufferImageData {
  47541. /**
  47542. * Length of the image data.
  47543. */
  47544. length: number;
  47545. /**
  47546. * Position of the data from the null terminator delimiting the end of the JSON.
  47547. */
  47548. position: number;
  47549. }
  47550. /**
  47551. * Defines the specular data enclosed in the file.
  47552. * This corresponds to the version 1 of the data.
  47553. */
  47554. export interface EnvironmentTextureSpecularInfoV1 {
  47555. /**
  47556. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47557. */
  47558. specularDataPosition?: number;
  47559. /**
  47560. * This contains all the images data needed to reconstruct the cubemap.
  47561. */
  47562. mipmaps: Array<BufferImageData>;
  47563. /**
  47564. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47565. */
  47566. lodGenerationScale: number;
  47567. }
  47568. /**
  47569. * Sets of helpers addressing the serialization and deserialization of environment texture
  47570. * stored in a BabylonJS env file.
  47571. * Those files are usually stored as .env files.
  47572. */
  47573. export class EnvironmentTextureTools {
  47574. /**
  47575. * Magic number identifying the env file.
  47576. */
  47577. private static _MagicBytes;
  47578. /**
  47579. * Gets the environment info from an env file.
  47580. * @param data The array buffer containing the .env bytes.
  47581. * @returns the environment file info (the json header) if successfully parsed.
  47582. */
  47583. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47584. /**
  47585. * Creates an environment texture from a loaded cube texture.
  47586. * @param texture defines the cube texture to convert in env file
  47587. * @return a promise containing the environment data if succesfull.
  47588. */
  47589. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47590. /**
  47591. * Creates a JSON representation of the spherical data.
  47592. * @param texture defines the texture containing the polynomials
  47593. * @return the JSON representation of the spherical info
  47594. */
  47595. private static _CreateEnvTextureIrradiance;
  47596. /**
  47597. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47598. * @param data the image data
  47599. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47600. * @return the views described by info providing access to the underlying buffer
  47601. */
  47602. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47603. /**
  47604. * Uploads the texture info contained in the env file to the GPU.
  47605. * @param texture defines the internal texture to upload to
  47606. * @param data defines the data to load
  47607. * @param info defines the texture info retrieved through the GetEnvInfo method
  47608. * @returns a promise
  47609. */
  47610. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47611. private static _OnImageReadyAsync;
  47612. /**
  47613. * Uploads the levels of image data to the GPU.
  47614. * @param texture defines the internal texture to upload to
  47615. * @param imageData defines the array buffer views of image data [mipmap][face]
  47616. * @returns a promise
  47617. */
  47618. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47619. /**
  47620. * Uploads spherical polynomials information to the texture.
  47621. * @param texture defines the texture we are trying to upload the information to
  47622. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47623. */
  47624. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47625. /** @hidden */
  47626. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47627. }
  47628. }
  47629. declare module BABYLON {
  47630. /**
  47631. * Contains position and normal vectors for a vertex
  47632. */
  47633. export class PositionNormalVertex {
  47634. /** the position of the vertex (defaut: 0,0,0) */
  47635. position: Vector3;
  47636. /** the normal of the vertex (defaut: 0,1,0) */
  47637. normal: Vector3;
  47638. /**
  47639. * Creates a PositionNormalVertex
  47640. * @param position the position of the vertex (defaut: 0,0,0)
  47641. * @param normal the normal of the vertex (defaut: 0,1,0)
  47642. */
  47643. constructor(
  47644. /** the position of the vertex (defaut: 0,0,0) */
  47645. position?: Vector3,
  47646. /** the normal of the vertex (defaut: 0,1,0) */
  47647. normal?: Vector3);
  47648. /**
  47649. * Clones the PositionNormalVertex
  47650. * @returns the cloned PositionNormalVertex
  47651. */
  47652. clone(): PositionNormalVertex;
  47653. }
  47654. /**
  47655. * Contains position, normal and uv vectors for a vertex
  47656. */
  47657. export class PositionNormalTextureVertex {
  47658. /** the position of the vertex (defaut: 0,0,0) */
  47659. position: Vector3;
  47660. /** the normal of the vertex (defaut: 0,1,0) */
  47661. normal: Vector3;
  47662. /** the uv of the vertex (default: 0,0) */
  47663. uv: Vector2;
  47664. /**
  47665. * Creates a PositionNormalTextureVertex
  47666. * @param position the position of the vertex (defaut: 0,0,0)
  47667. * @param normal the normal of the vertex (defaut: 0,1,0)
  47668. * @param uv the uv of the vertex (default: 0,0)
  47669. */
  47670. constructor(
  47671. /** the position of the vertex (defaut: 0,0,0) */
  47672. position?: Vector3,
  47673. /** the normal of the vertex (defaut: 0,1,0) */
  47674. normal?: Vector3,
  47675. /** the uv of the vertex (default: 0,0) */
  47676. uv?: Vector2);
  47677. /**
  47678. * Clones the PositionNormalTextureVertex
  47679. * @returns the cloned PositionNormalTextureVertex
  47680. */
  47681. clone(): PositionNormalTextureVertex;
  47682. }
  47683. }
  47684. declare module BABYLON {
  47685. /** @hidden */
  47686. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47687. private _genericAttributeLocation;
  47688. private _varyingLocationCount;
  47689. private _varyingLocationMap;
  47690. private _replacements;
  47691. private _textureCount;
  47692. private _uniforms;
  47693. lineProcessor(line: string): string;
  47694. attributeProcessor(attribute: string): string;
  47695. varyingProcessor(varying: string, isFragment: boolean): string;
  47696. uniformProcessor(uniform: string): string;
  47697. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47698. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47699. }
  47700. }
  47701. declare module BABYLON {
  47702. /**
  47703. * Container for accessors for natively-stored mesh data buffers.
  47704. */
  47705. class NativeDataBuffer extends DataBuffer {
  47706. /**
  47707. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47708. */
  47709. nativeIndexBuffer?: any;
  47710. /**
  47711. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47712. */
  47713. nativeVertexBuffer?: any;
  47714. }
  47715. /** @hidden */
  47716. class NativeTexture extends InternalTexture {
  47717. getInternalTexture(): InternalTexture;
  47718. getViewCount(): number;
  47719. }
  47720. /** @hidden */
  47721. export class NativeEngine extends Engine {
  47722. private readonly _native;
  47723. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47724. private readonly INVALID_HANDLE;
  47725. getHardwareScalingLevel(): number;
  47726. constructor();
  47727. /**
  47728. * Can be used to override the current requestAnimationFrame requester.
  47729. * @hidden
  47730. */
  47731. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47732. /**
  47733. * Override default engine behavior.
  47734. * @param color
  47735. * @param backBuffer
  47736. * @param depth
  47737. * @param stencil
  47738. */
  47739. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47740. /**
  47741. * Gets host document
  47742. * @returns the host document object
  47743. */
  47744. getHostDocument(): Nullable<Document>;
  47745. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47746. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47747. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47748. recordVertexArrayObject(vertexBuffers: {
  47749. [key: string]: VertexBuffer;
  47750. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47751. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47752. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47753. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47754. /**
  47755. * Draw a list of indexed primitives
  47756. * @param fillMode defines the primitive to use
  47757. * @param indexStart defines the starting index
  47758. * @param indexCount defines the number of index to draw
  47759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47760. */
  47761. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47762. /**
  47763. * Draw a list of unindexed primitives
  47764. * @param fillMode defines the primitive to use
  47765. * @param verticesStart defines the index of first vertex to draw
  47766. * @param verticesCount defines the count of vertices to draw
  47767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47768. */
  47769. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47770. createPipelineContext(): IPipelineContext;
  47771. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47772. /** @hidden */
  47773. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47774. /** @hidden */
  47775. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47776. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47777. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47778. protected _setProgram(program: WebGLProgram): void;
  47779. _releaseEffect(effect: Effect): void;
  47780. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47781. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47782. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47783. bindSamplers(effect: Effect): void;
  47784. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47785. getRenderWidth(useScreen?: boolean): number;
  47786. getRenderHeight(useScreen?: boolean): number;
  47787. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47788. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47789. /**
  47790. * Set the z offset to apply to current rendering
  47791. * @param value defines the offset to apply
  47792. */
  47793. setZOffset(value: number): void;
  47794. /**
  47795. * Gets the current value of the zOffset
  47796. * @returns the current zOffset state
  47797. */
  47798. getZOffset(): number;
  47799. /**
  47800. * Enable or disable depth buffering
  47801. * @param enable defines the state to set
  47802. */
  47803. setDepthBuffer(enable: boolean): void;
  47804. /**
  47805. * Gets a boolean indicating if depth writing is enabled
  47806. * @returns the current depth writing state
  47807. */
  47808. getDepthWrite(): boolean;
  47809. /**
  47810. * Enable or disable depth writing
  47811. * @param enable defines the state to set
  47812. */
  47813. setDepthWrite(enable: boolean): void;
  47814. /**
  47815. * Enable or disable color writing
  47816. * @param enable defines the state to set
  47817. */
  47818. setColorWrite(enable: boolean): void;
  47819. /**
  47820. * Gets a boolean indicating if color writing is enabled
  47821. * @returns the current color writing state
  47822. */
  47823. getColorWrite(): boolean;
  47824. /**
  47825. * Sets alpha constants used by some alpha blending modes
  47826. * @param r defines the red component
  47827. * @param g defines the green component
  47828. * @param b defines the blue component
  47829. * @param a defines the alpha component
  47830. */
  47831. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47832. /**
  47833. * Sets the current alpha mode
  47834. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47835. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47836. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47837. */
  47838. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47839. /**
  47840. * Gets the current alpha mode
  47841. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47842. * @returns the current alpha mode
  47843. */
  47844. getAlphaMode(): number;
  47845. setInt(uniform: WebGLUniformLocation, int: number): void;
  47846. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47847. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47848. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47849. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47850. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47851. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47852. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47853. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47854. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47855. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47856. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47857. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47858. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47859. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47860. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47861. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47862. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47863. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47864. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47865. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47866. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47867. wipeCaches(bruteForce?: boolean): void;
  47868. _createTexture(): WebGLTexture;
  47869. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47870. /**
  47871. * Usually called from Texture.ts.
  47872. * Passed information to create a WebGLTexture
  47873. * @param urlArg defines a value which contains one of the following:
  47874. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47875. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47876. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47877. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47878. * @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)
  47879. * @param scene needed for loading to the correct scene
  47880. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47881. * @param onLoad optional callback to be called upon successful completion
  47882. * @param onError optional callback to be called upon failure
  47883. * @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
  47884. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47885. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47886. * @param forcedExtension defines the extension to use to pick the right loader
  47887. * @param mimeType defines an optional mime type
  47888. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47889. */
  47890. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  47891. /**
  47892. * Creates a cube texture
  47893. * @param rootUrl defines the url where the files to load is located
  47894. * @param scene defines the current scene
  47895. * @param files defines the list of files to load (1 per face)
  47896. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47897. * @param onLoad defines an optional callback raised when the texture is loaded
  47898. * @param onError defines an optional callback raised if there is an issue to load the texture
  47899. * @param format defines the format of the data
  47900. * @param forcedExtension defines the extension to use to pick the right loader
  47901. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47902. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47903. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47904. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47905. * @returns the cube texture as an InternalTexture
  47906. */
  47907. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  47908. private _getSamplingFilter;
  47909. private static _GetNativeTextureFormat;
  47910. createRenderTargetTexture(size: number | {
  47911. width: number;
  47912. height: number;
  47913. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47914. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47915. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47916. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47917. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47918. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47919. /**
  47920. * Updates a dynamic vertex buffer.
  47921. * @param vertexBuffer the vertex buffer to update
  47922. * @param data the data used to update the vertex buffer
  47923. * @param byteOffset the byte offset of the data (optional)
  47924. * @param byteLength the byte length of the data (optional)
  47925. */
  47926. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47927. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47928. private _updateAnisotropicLevel;
  47929. private _getAddressMode;
  47930. /** @hidden */
  47931. _bindTexture(channel: number, texture: InternalTexture): void;
  47932. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47933. releaseEffects(): void;
  47934. /** @hidden */
  47935. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47936. /** @hidden */
  47937. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47938. /** @hidden */
  47939. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47940. /** @hidden */
  47941. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47942. }
  47943. }
  47944. declare module BABYLON {
  47945. /**
  47946. * Gather the list of clipboard event types as constants.
  47947. */
  47948. export class ClipboardEventTypes {
  47949. /**
  47950. * The clipboard event is fired when a copy command is active (pressed).
  47951. */
  47952. static readonly COPY: number;
  47953. /**
  47954. * The clipboard event is fired when a cut command is active (pressed).
  47955. */
  47956. static readonly CUT: number;
  47957. /**
  47958. * The clipboard event is fired when a paste command is active (pressed).
  47959. */
  47960. static readonly PASTE: number;
  47961. }
  47962. /**
  47963. * This class is used to store clipboard related info for the onClipboardObservable event.
  47964. */
  47965. export class ClipboardInfo {
  47966. /**
  47967. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47968. */
  47969. type: number;
  47970. /**
  47971. * Defines the related dom event
  47972. */
  47973. event: ClipboardEvent;
  47974. /**
  47975. *Creates an instance of ClipboardInfo.
  47976. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47977. * @param event Defines the related dom event
  47978. */
  47979. constructor(
  47980. /**
  47981. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47982. */
  47983. type: number,
  47984. /**
  47985. * Defines the related dom event
  47986. */
  47987. event: ClipboardEvent);
  47988. /**
  47989. * Get the clipboard event's type from the keycode.
  47990. * @param keyCode Defines the keyCode for the current keyboard event.
  47991. * @return {number}
  47992. */
  47993. static GetTypeFromCharacter(keyCode: number): number;
  47994. }
  47995. }
  47996. declare module BABYLON {
  47997. /**
  47998. * Google Daydream controller
  47999. */
  48000. export class DaydreamController extends WebVRController {
  48001. /**
  48002. * Base Url for the controller model.
  48003. */
  48004. static MODEL_BASE_URL: string;
  48005. /**
  48006. * File name for the controller model.
  48007. */
  48008. static MODEL_FILENAME: string;
  48009. /**
  48010. * Gamepad Id prefix used to identify Daydream Controller.
  48011. */
  48012. static readonly GAMEPAD_ID_PREFIX: string;
  48013. /**
  48014. * Creates a new DaydreamController from a gamepad
  48015. * @param vrGamepad the gamepad that the controller should be created from
  48016. */
  48017. constructor(vrGamepad: any);
  48018. /**
  48019. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48020. * @param scene scene in which to add meshes
  48021. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48022. */
  48023. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48024. /**
  48025. * Called once for each button that changed state since the last frame
  48026. * @param buttonIdx Which button index changed
  48027. * @param state New state of the button
  48028. * @param changes Which properties on the state changed since last frame
  48029. */
  48030. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48031. }
  48032. }
  48033. declare module BABYLON {
  48034. /**
  48035. * Gear VR Controller
  48036. */
  48037. export class GearVRController extends WebVRController {
  48038. /**
  48039. * Base Url for the controller model.
  48040. */
  48041. static MODEL_BASE_URL: string;
  48042. /**
  48043. * File name for the controller model.
  48044. */
  48045. static MODEL_FILENAME: string;
  48046. /**
  48047. * Gamepad Id prefix used to identify this controller.
  48048. */
  48049. static readonly GAMEPAD_ID_PREFIX: string;
  48050. private readonly _buttonIndexToObservableNameMap;
  48051. /**
  48052. * Creates a new GearVRController from a gamepad
  48053. * @param vrGamepad the gamepad that the controller should be created from
  48054. */
  48055. constructor(vrGamepad: any);
  48056. /**
  48057. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48058. * @param scene scene in which to add meshes
  48059. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48060. */
  48061. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48062. /**
  48063. * Called once for each button that changed state since the last frame
  48064. * @param buttonIdx Which button index changed
  48065. * @param state New state of the button
  48066. * @param changes Which properties on the state changed since last frame
  48067. */
  48068. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48069. }
  48070. }
  48071. declare module BABYLON {
  48072. /**
  48073. * Generic Controller
  48074. */
  48075. export class GenericController extends WebVRController {
  48076. /**
  48077. * Base Url for the controller model.
  48078. */
  48079. static readonly MODEL_BASE_URL: string;
  48080. /**
  48081. * File name for the controller model.
  48082. */
  48083. static readonly MODEL_FILENAME: string;
  48084. /**
  48085. * Creates a new GenericController from a gamepad
  48086. * @param vrGamepad the gamepad that the controller should be created from
  48087. */
  48088. constructor(vrGamepad: any);
  48089. /**
  48090. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48091. * @param scene scene in which to add meshes
  48092. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48093. */
  48094. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48095. /**
  48096. * Called once for each button that changed state since the last frame
  48097. * @param buttonIdx Which button index changed
  48098. * @param state New state of the button
  48099. * @param changes Which properties on the state changed since last frame
  48100. */
  48101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48102. }
  48103. }
  48104. declare module BABYLON {
  48105. /**
  48106. * Oculus Touch Controller
  48107. */
  48108. export class OculusTouchController extends WebVRController {
  48109. /**
  48110. * Base Url for the controller model.
  48111. */
  48112. static MODEL_BASE_URL: string;
  48113. /**
  48114. * File name for the left controller model.
  48115. */
  48116. static MODEL_LEFT_FILENAME: string;
  48117. /**
  48118. * File name for the right controller model.
  48119. */
  48120. static MODEL_RIGHT_FILENAME: string;
  48121. /**
  48122. * Base Url for the Quest controller model.
  48123. */
  48124. static QUEST_MODEL_BASE_URL: string;
  48125. /**
  48126. * @hidden
  48127. * If the controllers are running on a device that needs the updated Quest controller models
  48128. */
  48129. static _IsQuest: boolean;
  48130. /**
  48131. * Fired when the secondary trigger on this controller is modified
  48132. */
  48133. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48134. /**
  48135. * Fired when the thumb rest on this controller is modified
  48136. */
  48137. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48138. /**
  48139. * Creates a new OculusTouchController from a gamepad
  48140. * @param vrGamepad the gamepad that the controller should be created from
  48141. */
  48142. constructor(vrGamepad: any);
  48143. /**
  48144. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48145. * @param scene scene in which to add meshes
  48146. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48147. */
  48148. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48149. /**
  48150. * Fired when the A button on this controller is modified
  48151. */
  48152. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48153. /**
  48154. * Fired when the B button on this controller is modified
  48155. */
  48156. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48157. /**
  48158. * Fired when the X button on this controller is modified
  48159. */
  48160. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48161. /**
  48162. * Fired when the Y button on this controller is modified
  48163. */
  48164. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48165. /**
  48166. * Called once for each button that changed state since the last frame
  48167. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48168. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48169. * 2) secondary trigger (same)
  48170. * 3) A (right) X (left), touch, pressed = value
  48171. * 4) B / Y
  48172. * 5) thumb rest
  48173. * @param buttonIdx Which button index changed
  48174. * @param state New state of the button
  48175. * @param changes Which properties on the state changed since last frame
  48176. */
  48177. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48178. }
  48179. }
  48180. declare module BABYLON {
  48181. /**
  48182. * Vive Controller
  48183. */
  48184. export class ViveController extends WebVRController {
  48185. /**
  48186. * Base Url for the controller model.
  48187. */
  48188. static MODEL_BASE_URL: string;
  48189. /**
  48190. * File name for the controller model.
  48191. */
  48192. static MODEL_FILENAME: string;
  48193. /**
  48194. * Creates a new ViveController from a gamepad
  48195. * @param vrGamepad the gamepad that the controller should be created from
  48196. */
  48197. constructor(vrGamepad: any);
  48198. /**
  48199. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48200. * @param scene scene in which to add meshes
  48201. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48202. */
  48203. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48204. /**
  48205. * Fired when the left button on this controller is modified
  48206. */
  48207. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48208. /**
  48209. * Fired when the right button on this controller is modified
  48210. */
  48211. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48212. /**
  48213. * Fired when the menu button on this controller is modified
  48214. */
  48215. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48216. /**
  48217. * Called once for each button that changed state since the last frame
  48218. * Vive mapping:
  48219. * 0: touchpad
  48220. * 1: trigger
  48221. * 2: left AND right buttons
  48222. * 3: menu button
  48223. * @param buttonIdx Which button index changed
  48224. * @param state New state of the button
  48225. * @param changes Which properties on the state changed since last frame
  48226. */
  48227. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48228. }
  48229. }
  48230. declare module BABYLON {
  48231. /**
  48232. * Defines the WindowsMotionController object that the state of the windows motion controller
  48233. */
  48234. export class WindowsMotionController extends WebVRController {
  48235. /**
  48236. * The base url used to load the left and right controller models
  48237. */
  48238. static MODEL_BASE_URL: string;
  48239. /**
  48240. * The name of the left controller model file
  48241. */
  48242. static MODEL_LEFT_FILENAME: string;
  48243. /**
  48244. * The name of the right controller model file
  48245. */
  48246. static MODEL_RIGHT_FILENAME: string;
  48247. /**
  48248. * The controller name prefix for this controller type
  48249. */
  48250. static readonly GAMEPAD_ID_PREFIX: string;
  48251. /**
  48252. * The controller id pattern for this controller type
  48253. */
  48254. private static readonly GAMEPAD_ID_PATTERN;
  48255. private _loadedMeshInfo;
  48256. protected readonly _mapping: {
  48257. buttons: string[];
  48258. buttonMeshNames: {
  48259. 'trigger': string;
  48260. 'menu': string;
  48261. 'grip': string;
  48262. 'thumbstick': string;
  48263. 'trackpad': string;
  48264. };
  48265. buttonObservableNames: {
  48266. 'trigger': string;
  48267. 'menu': string;
  48268. 'grip': string;
  48269. 'thumbstick': string;
  48270. 'trackpad': string;
  48271. };
  48272. axisMeshNames: string[];
  48273. pointingPoseMeshName: string;
  48274. };
  48275. /**
  48276. * Fired when the trackpad on this controller is clicked
  48277. */
  48278. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48279. /**
  48280. * Fired when the trackpad on this controller is modified
  48281. */
  48282. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48283. /**
  48284. * The current x and y values of this controller's trackpad
  48285. */
  48286. trackpad: StickValues;
  48287. /**
  48288. * Creates a new WindowsMotionController from a gamepad
  48289. * @param vrGamepad the gamepad that the controller should be created from
  48290. */
  48291. constructor(vrGamepad: any);
  48292. /**
  48293. * Fired when the trigger on this controller is modified
  48294. */
  48295. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48296. /**
  48297. * Fired when the menu button on this controller is modified
  48298. */
  48299. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48300. /**
  48301. * Fired when the grip button on this controller is modified
  48302. */
  48303. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48304. /**
  48305. * Fired when the thumbstick button on this controller is modified
  48306. */
  48307. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48308. /**
  48309. * Fired when the touchpad button on this controller is modified
  48310. */
  48311. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48312. /**
  48313. * Fired when the touchpad values on this controller are modified
  48314. */
  48315. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48316. protected _updateTrackpad(): void;
  48317. /**
  48318. * Called once per frame by the engine.
  48319. */
  48320. update(): void;
  48321. /**
  48322. * Called once for each button that changed state since the last frame
  48323. * @param buttonIdx Which button index changed
  48324. * @param state New state of the button
  48325. * @param changes Which properties on the state changed since last frame
  48326. */
  48327. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48328. /**
  48329. * Moves the buttons on the controller mesh based on their current state
  48330. * @param buttonName the name of the button to move
  48331. * @param buttonValue the value of the button which determines the buttons new position
  48332. */
  48333. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48334. /**
  48335. * Moves the axis on the controller mesh based on its current state
  48336. * @param axis the index of the axis
  48337. * @param axisValue the value of the axis which determines the meshes new position
  48338. * @hidden
  48339. */
  48340. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48341. /**
  48342. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48343. * @param scene scene in which to add meshes
  48344. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48345. */
  48346. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48347. /**
  48348. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48349. * can be transformed by button presses and axes values, based on this._mapping.
  48350. *
  48351. * @param scene scene in which the meshes exist
  48352. * @param meshes list of meshes that make up the controller model to process
  48353. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48354. */
  48355. private processModel;
  48356. private createMeshInfo;
  48357. /**
  48358. * Gets the ray of the controller in the direction the controller is pointing
  48359. * @param length the length the resulting ray should be
  48360. * @returns a ray in the direction the controller is pointing
  48361. */
  48362. getForwardRay(length?: number): Ray;
  48363. /**
  48364. * Disposes of the controller
  48365. */
  48366. dispose(): void;
  48367. }
  48368. /**
  48369. * This class represents a new windows motion controller in XR.
  48370. */
  48371. export class XRWindowsMotionController extends WindowsMotionController {
  48372. /**
  48373. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48374. */
  48375. protected readonly _mapping: {
  48376. buttons: string[];
  48377. buttonMeshNames: {
  48378. 'trigger': string;
  48379. 'menu': string;
  48380. 'grip': string;
  48381. 'thumbstick': string;
  48382. 'trackpad': string;
  48383. };
  48384. buttonObservableNames: {
  48385. 'trigger': string;
  48386. 'menu': string;
  48387. 'grip': string;
  48388. 'thumbstick': string;
  48389. 'trackpad': string;
  48390. };
  48391. axisMeshNames: string[];
  48392. pointingPoseMeshName: string;
  48393. };
  48394. /**
  48395. * Construct a new XR-Based windows motion controller
  48396. *
  48397. * @param gamepadInfo the gamepad object from the browser
  48398. */
  48399. constructor(gamepadInfo: any);
  48400. /**
  48401. * holds the thumbstick values (X,Y)
  48402. */
  48403. thumbstickValues: StickValues;
  48404. /**
  48405. * Fired when the thumbstick on this controller is clicked
  48406. */
  48407. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48408. /**
  48409. * Fired when the thumbstick on this controller is modified
  48410. */
  48411. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48412. /**
  48413. * Fired when the touchpad button on this controller is modified
  48414. */
  48415. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48416. /**
  48417. * Fired when the touchpad values on this controller are modified
  48418. */
  48419. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48420. /**
  48421. * Fired when the thumbstick button on this controller is modified
  48422. * here to prevent breaking changes
  48423. */
  48424. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48425. /**
  48426. * updating the thumbstick(!) and not the trackpad.
  48427. * This is named this way due to the difference between WebVR and XR and to avoid
  48428. * changing the parent class.
  48429. */
  48430. protected _updateTrackpad(): void;
  48431. /**
  48432. * Disposes the class with joy
  48433. */
  48434. dispose(): void;
  48435. }
  48436. }
  48437. declare module BABYLON {
  48438. /**
  48439. * Class containing static functions to help procedurally build meshes
  48440. */
  48441. export class PolyhedronBuilder {
  48442. /**
  48443. * Creates a polyhedron mesh
  48444. * * 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
  48445. * * The parameter `size` (positive float, default 1) sets the polygon size
  48446. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48447. * * 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`
  48448. * * 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
  48449. * * 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)`)
  48450. * * 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
  48451. * * 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
  48452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48453. * * 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
  48454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48455. * @param name defines the name of the mesh
  48456. * @param options defines the options used to create the mesh
  48457. * @param scene defines the hosting scene
  48458. * @returns the polyhedron mesh
  48459. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48460. */
  48461. static CreatePolyhedron(name: string, options: {
  48462. type?: number;
  48463. size?: number;
  48464. sizeX?: number;
  48465. sizeY?: number;
  48466. sizeZ?: number;
  48467. custom?: any;
  48468. faceUV?: Vector4[];
  48469. faceColors?: Color4[];
  48470. flat?: boolean;
  48471. updatable?: boolean;
  48472. sideOrientation?: number;
  48473. frontUVs?: Vector4;
  48474. backUVs?: Vector4;
  48475. }, scene?: Nullable<Scene>): Mesh;
  48476. }
  48477. }
  48478. declare module BABYLON {
  48479. /**
  48480. * Gizmo that enables scaling a mesh along 3 axis
  48481. */
  48482. export class ScaleGizmo extends Gizmo {
  48483. /**
  48484. * Internal gizmo used for interactions on the x axis
  48485. */
  48486. xGizmo: AxisScaleGizmo;
  48487. /**
  48488. * Internal gizmo used for interactions on the y axis
  48489. */
  48490. yGizmo: AxisScaleGizmo;
  48491. /**
  48492. * Internal gizmo used for interactions on the z axis
  48493. */
  48494. zGizmo: AxisScaleGizmo;
  48495. /**
  48496. * Internal gizmo used to scale all axis equally
  48497. */
  48498. uniformScaleGizmo: AxisScaleGizmo;
  48499. private _meshAttached;
  48500. private _updateGizmoRotationToMatchAttachedMesh;
  48501. private _snapDistance;
  48502. private _scaleRatio;
  48503. private _uniformScalingMesh;
  48504. private _octahedron;
  48505. private _sensitivity;
  48506. /** Fires an event when any of it's sub gizmos are dragged */
  48507. onDragStartObservable: Observable<unknown>;
  48508. /** Fires an event when any of it's sub gizmos are released from dragging */
  48509. onDragEndObservable: Observable<unknown>;
  48510. get attachedMesh(): Nullable<AbstractMesh>;
  48511. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48512. /**
  48513. * Creates a ScaleGizmo
  48514. * @param gizmoLayer The utility layer the gizmo will be added to
  48515. */
  48516. constructor(gizmoLayer?: UtilityLayerRenderer);
  48517. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48518. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48519. /**
  48520. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48521. */
  48522. set snapDistance(value: number);
  48523. get snapDistance(): number;
  48524. /**
  48525. * Ratio for the scale of the gizmo (Default: 1)
  48526. */
  48527. set scaleRatio(value: number);
  48528. get scaleRatio(): number;
  48529. /**
  48530. * Sensitivity factor for dragging (Default: 1)
  48531. */
  48532. set sensitivity(value: number);
  48533. get sensitivity(): number;
  48534. /**
  48535. * Disposes of the gizmo
  48536. */
  48537. dispose(): void;
  48538. }
  48539. }
  48540. declare module BABYLON {
  48541. /**
  48542. * Single axis scale gizmo
  48543. */
  48544. export class AxisScaleGizmo extends Gizmo {
  48545. /**
  48546. * Drag behavior responsible for the gizmos dragging interactions
  48547. */
  48548. dragBehavior: PointerDragBehavior;
  48549. private _pointerObserver;
  48550. /**
  48551. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48552. */
  48553. snapDistance: number;
  48554. /**
  48555. * Event that fires each time the gizmo snaps to a new location.
  48556. * * snapDistance is the the change in distance
  48557. */
  48558. onSnapObservable: Observable<{
  48559. snapDistance: number;
  48560. }>;
  48561. /**
  48562. * If the scaling operation should be done on all axis (default: false)
  48563. */
  48564. uniformScaling: boolean;
  48565. /**
  48566. * Custom sensitivity value for the drag strength
  48567. */
  48568. sensitivity: number;
  48569. private _isEnabled;
  48570. private _parent;
  48571. private _arrow;
  48572. private _coloredMaterial;
  48573. private _hoverMaterial;
  48574. /**
  48575. * Creates an AxisScaleGizmo
  48576. * @param gizmoLayer The utility layer the gizmo will be added to
  48577. * @param dragAxis The axis which the gizmo will be able to scale on
  48578. * @param color The color of the gizmo
  48579. */
  48580. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48581. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48582. /**
  48583. * If the gizmo is enabled
  48584. */
  48585. set isEnabled(value: boolean);
  48586. get isEnabled(): boolean;
  48587. /**
  48588. * Disposes of the gizmo
  48589. */
  48590. dispose(): void;
  48591. /**
  48592. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48593. * @param mesh The mesh to replace the default mesh of the gizmo
  48594. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48595. */
  48596. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48597. }
  48598. }
  48599. declare module BABYLON {
  48600. /**
  48601. * Bounding box gizmo
  48602. */
  48603. export class BoundingBoxGizmo extends Gizmo {
  48604. private _lineBoundingBox;
  48605. private _rotateSpheresParent;
  48606. private _scaleBoxesParent;
  48607. private _boundingDimensions;
  48608. private _renderObserver;
  48609. private _pointerObserver;
  48610. private _scaleDragSpeed;
  48611. private _tmpQuaternion;
  48612. private _tmpVector;
  48613. private _tmpRotationMatrix;
  48614. /**
  48615. * 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)
  48616. */
  48617. ignoreChildren: boolean;
  48618. /**
  48619. * 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)
  48620. */
  48621. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48622. /**
  48623. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48624. */
  48625. rotationSphereSize: number;
  48626. /**
  48627. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48628. */
  48629. scaleBoxSize: number;
  48630. /**
  48631. * 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)
  48632. */
  48633. fixedDragMeshScreenSize: boolean;
  48634. /**
  48635. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48636. */
  48637. fixedDragMeshScreenSizeDistanceFactor: number;
  48638. /**
  48639. * Fired when a rotation sphere or scale box is dragged
  48640. */
  48641. onDragStartObservable: Observable<{}>;
  48642. /**
  48643. * Fired when a scale box is dragged
  48644. */
  48645. onScaleBoxDragObservable: Observable<{}>;
  48646. /**
  48647. * Fired when a scale box drag is ended
  48648. */
  48649. onScaleBoxDragEndObservable: Observable<{}>;
  48650. /**
  48651. * Fired when a rotation sphere is dragged
  48652. */
  48653. onRotationSphereDragObservable: Observable<{}>;
  48654. /**
  48655. * Fired when a rotation sphere drag is ended
  48656. */
  48657. onRotationSphereDragEndObservable: Observable<{}>;
  48658. /**
  48659. * 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)
  48660. */
  48661. scalePivot: Nullable<Vector3>;
  48662. /**
  48663. * Mesh used as a pivot to rotate the attached mesh
  48664. */
  48665. private _anchorMesh;
  48666. private _existingMeshScale;
  48667. private _dragMesh;
  48668. private pointerDragBehavior;
  48669. private coloredMaterial;
  48670. private hoverColoredMaterial;
  48671. /**
  48672. * Sets the color of the bounding box gizmo
  48673. * @param color the color to set
  48674. */
  48675. setColor(color: Color3): void;
  48676. /**
  48677. * Creates an BoundingBoxGizmo
  48678. * @param gizmoLayer The utility layer the gizmo will be added to
  48679. * @param color The color of the gizmo
  48680. */
  48681. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48682. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48683. private _selectNode;
  48684. /**
  48685. * Updates the bounding box information for the Gizmo
  48686. */
  48687. updateBoundingBox(): void;
  48688. private _updateRotationSpheres;
  48689. private _updateScaleBoxes;
  48690. /**
  48691. * Enables rotation on the specified axis and disables rotation on the others
  48692. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48693. */
  48694. setEnabledRotationAxis(axis: string): void;
  48695. /**
  48696. * Enables/disables scaling
  48697. * @param enable if scaling should be enabled
  48698. */
  48699. setEnabledScaling(enable: boolean): void;
  48700. private _updateDummy;
  48701. /**
  48702. * Enables a pointer drag behavior on the bounding box of the gizmo
  48703. */
  48704. enableDragBehavior(): void;
  48705. /**
  48706. * Disposes of the gizmo
  48707. */
  48708. dispose(): void;
  48709. /**
  48710. * 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)
  48711. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48712. * @returns the bounding box mesh with the passed in mesh as a child
  48713. */
  48714. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48715. /**
  48716. * CustomMeshes are not supported by this gizmo
  48717. * @param mesh The mesh to replace the default mesh of the gizmo
  48718. */
  48719. setCustomMesh(mesh: Mesh): void;
  48720. }
  48721. }
  48722. declare module BABYLON {
  48723. /**
  48724. * Single plane rotation gizmo
  48725. */
  48726. export class PlaneRotationGizmo extends Gizmo {
  48727. /**
  48728. * Drag behavior responsible for the gizmos dragging interactions
  48729. */
  48730. dragBehavior: PointerDragBehavior;
  48731. private _pointerObserver;
  48732. /**
  48733. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48734. */
  48735. snapDistance: number;
  48736. /**
  48737. * Event that fires each time the gizmo snaps to a new location.
  48738. * * snapDistance is the the change in distance
  48739. */
  48740. onSnapObservable: Observable<{
  48741. snapDistance: number;
  48742. }>;
  48743. private _isEnabled;
  48744. private _parent;
  48745. /**
  48746. * Creates a PlaneRotationGizmo
  48747. * @param gizmoLayer The utility layer the gizmo will be added to
  48748. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48749. * @param color The color of the gizmo
  48750. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48751. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48752. */
  48753. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48754. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48755. /**
  48756. * If the gizmo is enabled
  48757. */
  48758. set isEnabled(value: boolean);
  48759. get isEnabled(): boolean;
  48760. /**
  48761. * Disposes of the gizmo
  48762. */
  48763. dispose(): void;
  48764. }
  48765. }
  48766. declare module BABYLON {
  48767. /**
  48768. * Gizmo that enables rotating a mesh along 3 axis
  48769. */
  48770. export class RotationGizmo extends Gizmo {
  48771. /**
  48772. * Internal gizmo used for interactions on the x axis
  48773. */
  48774. xGizmo: PlaneRotationGizmo;
  48775. /**
  48776. * Internal gizmo used for interactions on the y axis
  48777. */
  48778. yGizmo: PlaneRotationGizmo;
  48779. /**
  48780. * Internal gizmo used for interactions on the z axis
  48781. */
  48782. zGizmo: PlaneRotationGizmo;
  48783. /** Fires an event when any of it's sub gizmos are dragged */
  48784. onDragStartObservable: Observable<unknown>;
  48785. /** Fires an event when any of it's sub gizmos are released from dragging */
  48786. onDragEndObservable: Observable<unknown>;
  48787. private _meshAttached;
  48788. get attachedMesh(): Nullable<AbstractMesh>;
  48789. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48790. /**
  48791. * Creates a RotationGizmo
  48792. * @param gizmoLayer The utility layer the gizmo will be added to
  48793. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48794. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48795. */
  48796. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48797. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48798. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48799. /**
  48800. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48801. */
  48802. set snapDistance(value: number);
  48803. get snapDistance(): number;
  48804. /**
  48805. * Ratio for the scale of the gizmo (Default: 1)
  48806. */
  48807. set scaleRatio(value: number);
  48808. get scaleRatio(): number;
  48809. /**
  48810. * Disposes of the gizmo
  48811. */
  48812. dispose(): void;
  48813. /**
  48814. * CustomMeshes are not supported by this gizmo
  48815. * @param mesh The mesh to replace the default mesh of the gizmo
  48816. */
  48817. setCustomMesh(mesh: Mesh): void;
  48818. }
  48819. }
  48820. declare module BABYLON {
  48821. /**
  48822. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48823. */
  48824. export class GizmoManager implements IDisposable {
  48825. private scene;
  48826. /**
  48827. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48828. */
  48829. gizmos: {
  48830. positionGizmo: Nullable<PositionGizmo>;
  48831. rotationGizmo: Nullable<RotationGizmo>;
  48832. scaleGizmo: Nullable<ScaleGizmo>;
  48833. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48834. };
  48835. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48836. clearGizmoOnEmptyPointerEvent: boolean;
  48837. /** Fires an event when the manager is attached to a mesh */
  48838. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48839. private _gizmosEnabled;
  48840. private _pointerObserver;
  48841. private _attachedMesh;
  48842. private _boundingBoxColor;
  48843. private _defaultUtilityLayer;
  48844. private _defaultKeepDepthUtilityLayer;
  48845. /**
  48846. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48847. */
  48848. boundingBoxDragBehavior: SixDofDragBehavior;
  48849. /**
  48850. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48851. */
  48852. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48853. /**
  48854. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48855. */
  48856. usePointerToAttachGizmos: boolean;
  48857. /**
  48858. * Utility layer that the bounding box gizmo belongs to
  48859. */
  48860. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48861. /**
  48862. * Utility layer that all gizmos besides bounding box belong to
  48863. */
  48864. get utilityLayer(): UtilityLayerRenderer;
  48865. /**
  48866. * Instatiates a gizmo manager
  48867. * @param scene the scene to overlay the gizmos on top of
  48868. */
  48869. constructor(scene: Scene);
  48870. /**
  48871. * Attaches a set of gizmos to the specified mesh
  48872. * @param mesh The mesh the gizmo's should be attached to
  48873. */
  48874. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48875. /**
  48876. * If the position gizmo is enabled
  48877. */
  48878. set positionGizmoEnabled(value: boolean);
  48879. get positionGizmoEnabled(): boolean;
  48880. /**
  48881. * If the rotation gizmo is enabled
  48882. */
  48883. set rotationGizmoEnabled(value: boolean);
  48884. get rotationGizmoEnabled(): boolean;
  48885. /**
  48886. * If the scale gizmo is enabled
  48887. */
  48888. set scaleGizmoEnabled(value: boolean);
  48889. get scaleGizmoEnabled(): boolean;
  48890. /**
  48891. * If the boundingBox gizmo is enabled
  48892. */
  48893. set boundingBoxGizmoEnabled(value: boolean);
  48894. get boundingBoxGizmoEnabled(): boolean;
  48895. /**
  48896. * Disposes of the gizmo manager
  48897. */
  48898. dispose(): void;
  48899. }
  48900. }
  48901. declare module BABYLON {
  48902. /**
  48903. * A directional light is defined by a direction (what a surprise!).
  48904. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48905. * 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.
  48906. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48907. */
  48908. export class DirectionalLight extends ShadowLight {
  48909. private _shadowFrustumSize;
  48910. /**
  48911. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48912. */
  48913. get shadowFrustumSize(): number;
  48914. /**
  48915. * Specifies a fix frustum size for the shadow generation.
  48916. */
  48917. set shadowFrustumSize(value: number);
  48918. private _shadowOrthoScale;
  48919. /**
  48920. * Gets the shadow projection scale against the optimal computed one.
  48921. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48922. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48923. */
  48924. get shadowOrthoScale(): number;
  48925. /**
  48926. * Sets the shadow projection scale against the optimal computed one.
  48927. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48928. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48929. */
  48930. set shadowOrthoScale(value: number);
  48931. /**
  48932. * Automatically compute the projection matrix to best fit (including all the casters)
  48933. * on each frame.
  48934. */
  48935. autoUpdateExtends: boolean;
  48936. /**
  48937. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48938. * on each frame. autoUpdateExtends must be set to true for this to work
  48939. */
  48940. autoCalcShadowZBounds: boolean;
  48941. private _orthoLeft;
  48942. private _orthoRight;
  48943. private _orthoTop;
  48944. private _orthoBottom;
  48945. /**
  48946. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48947. * The directional light is emitted from everywhere in the given direction.
  48948. * It can cast shadows.
  48949. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48950. * @param name The friendly name of the light
  48951. * @param direction The direction of the light
  48952. * @param scene The scene the light belongs to
  48953. */
  48954. constructor(name: string, direction: Vector3, scene: Scene);
  48955. /**
  48956. * Returns the string "DirectionalLight".
  48957. * @return The class name
  48958. */
  48959. getClassName(): string;
  48960. /**
  48961. * Returns the integer 1.
  48962. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48963. */
  48964. getTypeID(): number;
  48965. /**
  48966. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48967. * Returns the DirectionalLight Shadow projection matrix.
  48968. */
  48969. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48970. /**
  48971. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48972. * Returns the DirectionalLight Shadow projection matrix.
  48973. */
  48974. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48975. /**
  48976. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48977. * Returns the DirectionalLight Shadow projection matrix.
  48978. */
  48979. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48980. protected _buildUniformLayout(): void;
  48981. /**
  48982. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48983. * @param effect The effect to update
  48984. * @param lightIndex The index of the light in the effect to update
  48985. * @returns The directional light
  48986. */
  48987. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48988. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48989. /**
  48990. * Gets the minZ used for shadow according to both the scene and the light.
  48991. *
  48992. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48993. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48994. * @param activeCamera The camera we are returning the min for
  48995. * @returns the depth min z
  48996. */
  48997. getDepthMinZ(activeCamera: Camera): number;
  48998. /**
  48999. * Gets the maxZ used for shadow according to both the scene and the light.
  49000. *
  49001. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49002. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49003. * @param activeCamera The camera we are returning the max for
  49004. * @returns the depth max z
  49005. */
  49006. getDepthMaxZ(activeCamera: Camera): number;
  49007. /**
  49008. * Prepares the list of defines specific to the light type.
  49009. * @param defines the list of defines
  49010. * @param lightIndex defines the index of the light for the effect
  49011. */
  49012. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49013. }
  49014. }
  49015. declare module BABYLON {
  49016. /**
  49017. * Class containing static functions to help procedurally build meshes
  49018. */
  49019. export class HemisphereBuilder {
  49020. /**
  49021. * Creates a hemisphere mesh
  49022. * @param name defines the name of the mesh
  49023. * @param options defines the options used to create the mesh
  49024. * @param scene defines the hosting scene
  49025. * @returns the hemisphere mesh
  49026. */
  49027. static CreateHemisphere(name: string, options: {
  49028. segments?: number;
  49029. diameter?: number;
  49030. sideOrientation?: number;
  49031. }, scene: any): Mesh;
  49032. }
  49033. }
  49034. declare module BABYLON {
  49035. /**
  49036. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49037. * These values define a cone of light starting from the position, emitting toward the direction.
  49038. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49039. * and the exponent defines the speed of the decay of the light with distance (reach).
  49040. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49041. */
  49042. export class SpotLight extends ShadowLight {
  49043. private _angle;
  49044. private _innerAngle;
  49045. private _cosHalfAngle;
  49046. private _lightAngleScale;
  49047. private _lightAngleOffset;
  49048. /**
  49049. * Gets the cone angle of the spot light in Radians.
  49050. */
  49051. get angle(): number;
  49052. /**
  49053. * Sets the cone angle of the spot light in Radians.
  49054. */
  49055. set angle(value: number);
  49056. /**
  49057. * Only used in gltf falloff mode, this defines the angle where
  49058. * the directional falloff will start before cutting at angle which could be seen
  49059. * as outer angle.
  49060. */
  49061. get innerAngle(): number;
  49062. /**
  49063. * Only used in gltf falloff mode, this defines the angle where
  49064. * the directional falloff will start before cutting at angle which could be seen
  49065. * as outer angle.
  49066. */
  49067. set innerAngle(value: number);
  49068. private _shadowAngleScale;
  49069. /**
  49070. * Allows scaling the angle of the light for shadow generation only.
  49071. */
  49072. get shadowAngleScale(): number;
  49073. /**
  49074. * Allows scaling the angle of the light for shadow generation only.
  49075. */
  49076. set shadowAngleScale(value: number);
  49077. /**
  49078. * The light decay speed with the distance from the emission spot.
  49079. */
  49080. exponent: number;
  49081. private _projectionTextureMatrix;
  49082. /**
  49083. * Allows reading the projecton texture
  49084. */
  49085. get projectionTextureMatrix(): Matrix;
  49086. protected _projectionTextureLightNear: number;
  49087. /**
  49088. * Gets the near clip of the Spotlight for texture projection.
  49089. */
  49090. get projectionTextureLightNear(): number;
  49091. /**
  49092. * Sets the near clip of the Spotlight for texture projection.
  49093. */
  49094. set projectionTextureLightNear(value: number);
  49095. protected _projectionTextureLightFar: number;
  49096. /**
  49097. * Gets the far clip of the Spotlight for texture projection.
  49098. */
  49099. get projectionTextureLightFar(): number;
  49100. /**
  49101. * Sets the far clip of the Spotlight for texture projection.
  49102. */
  49103. set projectionTextureLightFar(value: number);
  49104. protected _projectionTextureUpDirection: Vector3;
  49105. /**
  49106. * Gets the Up vector of the Spotlight for texture projection.
  49107. */
  49108. get projectionTextureUpDirection(): Vector3;
  49109. /**
  49110. * Sets the Up vector of the Spotlight for texture projection.
  49111. */
  49112. set projectionTextureUpDirection(value: Vector3);
  49113. private _projectionTexture;
  49114. /**
  49115. * Gets the projection texture of the light.
  49116. */
  49117. get projectionTexture(): Nullable<BaseTexture>;
  49118. /**
  49119. * Sets the projection texture of the light.
  49120. */
  49121. set projectionTexture(value: Nullable<BaseTexture>);
  49122. private _projectionTextureViewLightDirty;
  49123. private _projectionTextureProjectionLightDirty;
  49124. private _projectionTextureDirty;
  49125. private _projectionTextureViewTargetVector;
  49126. private _projectionTextureViewLightMatrix;
  49127. private _projectionTextureProjectionLightMatrix;
  49128. private _projectionTextureScalingMatrix;
  49129. /**
  49130. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49131. * It can cast shadows.
  49132. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49133. * @param name The light friendly name
  49134. * @param position The position of the spot light in the scene
  49135. * @param direction The direction of the light in the scene
  49136. * @param angle The cone angle of the light in Radians
  49137. * @param exponent The light decay speed with the distance from the emission spot
  49138. * @param scene The scene the lights belongs to
  49139. */
  49140. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49141. /**
  49142. * Returns the string "SpotLight".
  49143. * @returns the class name
  49144. */
  49145. getClassName(): string;
  49146. /**
  49147. * Returns the integer 2.
  49148. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49149. */
  49150. getTypeID(): number;
  49151. /**
  49152. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49153. */
  49154. protected _setDirection(value: Vector3): void;
  49155. /**
  49156. * Overrides the position setter to recompute the projection texture view light Matrix.
  49157. */
  49158. protected _setPosition(value: Vector3): void;
  49159. /**
  49160. * 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.
  49161. * Returns the SpotLight.
  49162. */
  49163. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49164. protected _computeProjectionTextureViewLightMatrix(): void;
  49165. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49166. /**
  49167. * Main function for light texture projection matrix computing.
  49168. */
  49169. protected _computeProjectionTextureMatrix(): void;
  49170. protected _buildUniformLayout(): void;
  49171. private _computeAngleValues;
  49172. /**
  49173. * Sets the passed Effect "effect" with the Light textures.
  49174. * @param effect The effect to update
  49175. * @param lightIndex The index of the light in the effect to update
  49176. * @returns The light
  49177. */
  49178. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49179. /**
  49180. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49181. * @param effect The effect to update
  49182. * @param lightIndex The index of the light in the effect to update
  49183. * @returns The spot light
  49184. */
  49185. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49186. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49187. /**
  49188. * Disposes the light and the associated resources.
  49189. */
  49190. dispose(): void;
  49191. /**
  49192. * Prepares the list of defines specific to the light type.
  49193. * @param defines the list of defines
  49194. * @param lightIndex defines the index of the light for the effect
  49195. */
  49196. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49197. }
  49198. }
  49199. declare module BABYLON {
  49200. /**
  49201. * Gizmo that enables viewing a light
  49202. */
  49203. export class LightGizmo extends Gizmo {
  49204. private _lightMesh;
  49205. private _material;
  49206. private _cachedPosition;
  49207. private _cachedForward;
  49208. private _attachedMeshParent;
  49209. /**
  49210. * Creates a LightGizmo
  49211. * @param gizmoLayer The utility layer the gizmo will be added to
  49212. */
  49213. constructor(gizmoLayer?: UtilityLayerRenderer);
  49214. private _light;
  49215. /**
  49216. * The light that the gizmo is attached to
  49217. */
  49218. set light(light: Nullable<Light>);
  49219. get light(): Nullable<Light>;
  49220. /**
  49221. * Gets the material used to render the light gizmo
  49222. */
  49223. get material(): StandardMaterial;
  49224. /**
  49225. * @hidden
  49226. * Updates the gizmo to match the attached mesh's position/rotation
  49227. */
  49228. protected _update(): void;
  49229. private static _Scale;
  49230. /**
  49231. * Creates the lines for a light mesh
  49232. */
  49233. private static _CreateLightLines;
  49234. /**
  49235. * Disposes of the light gizmo
  49236. */
  49237. dispose(): void;
  49238. private static _CreateHemisphericLightMesh;
  49239. private static _CreatePointLightMesh;
  49240. private static _CreateSpotLightMesh;
  49241. private static _CreateDirectionalLightMesh;
  49242. }
  49243. }
  49244. declare module BABYLON {
  49245. /** @hidden */
  49246. export var backgroundFragmentDeclaration: {
  49247. name: string;
  49248. shader: string;
  49249. };
  49250. }
  49251. declare module BABYLON {
  49252. /** @hidden */
  49253. export var backgroundUboDeclaration: {
  49254. name: string;
  49255. shader: string;
  49256. };
  49257. }
  49258. declare module BABYLON {
  49259. /** @hidden */
  49260. export var backgroundPixelShader: {
  49261. name: string;
  49262. shader: string;
  49263. };
  49264. }
  49265. declare module BABYLON {
  49266. /** @hidden */
  49267. export var backgroundVertexDeclaration: {
  49268. name: string;
  49269. shader: string;
  49270. };
  49271. }
  49272. declare module BABYLON {
  49273. /** @hidden */
  49274. export var backgroundVertexShader: {
  49275. name: string;
  49276. shader: string;
  49277. };
  49278. }
  49279. declare module BABYLON {
  49280. /**
  49281. * Background material used to create an efficient environement around your scene.
  49282. */
  49283. export class BackgroundMaterial extends PushMaterial {
  49284. /**
  49285. * Standard reflectance value at parallel view angle.
  49286. */
  49287. static StandardReflectance0: number;
  49288. /**
  49289. * Standard reflectance value at grazing angle.
  49290. */
  49291. static StandardReflectance90: number;
  49292. protected _primaryColor: Color3;
  49293. /**
  49294. * Key light Color (multiply against the environement texture)
  49295. */
  49296. primaryColor: Color3;
  49297. protected __perceptualColor: Nullable<Color3>;
  49298. /**
  49299. * Experimental Internal Use Only.
  49300. *
  49301. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49302. * This acts as a helper to set the primary color to a more "human friendly" value.
  49303. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49304. * output color as close as possible from the chosen value.
  49305. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49306. * part of lighting setup.)
  49307. */
  49308. get _perceptualColor(): Nullable<Color3>;
  49309. set _perceptualColor(value: Nullable<Color3>);
  49310. protected _primaryColorShadowLevel: float;
  49311. /**
  49312. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49313. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49314. */
  49315. get primaryColorShadowLevel(): float;
  49316. set primaryColorShadowLevel(value: float);
  49317. protected _primaryColorHighlightLevel: float;
  49318. /**
  49319. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49320. * The primary color is used at the level chosen to define what the white area would look.
  49321. */
  49322. get primaryColorHighlightLevel(): float;
  49323. set primaryColorHighlightLevel(value: float);
  49324. protected _reflectionTexture: Nullable<BaseTexture>;
  49325. /**
  49326. * Reflection Texture used in the material.
  49327. * Should be author in a specific way for the best result (refer to the documentation).
  49328. */
  49329. reflectionTexture: Nullable<BaseTexture>;
  49330. protected _reflectionBlur: float;
  49331. /**
  49332. * Reflection Texture level of blur.
  49333. *
  49334. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49335. * texture twice.
  49336. */
  49337. reflectionBlur: float;
  49338. protected _diffuseTexture: Nullable<BaseTexture>;
  49339. /**
  49340. * Diffuse Texture used in the material.
  49341. * Should be author in a specific way for the best result (refer to the documentation).
  49342. */
  49343. diffuseTexture: Nullable<BaseTexture>;
  49344. protected _shadowLights: Nullable<IShadowLight[]>;
  49345. /**
  49346. * Specify the list of lights casting shadow on the material.
  49347. * All scene shadow lights will be included if null.
  49348. */
  49349. shadowLights: Nullable<IShadowLight[]>;
  49350. protected _shadowLevel: float;
  49351. /**
  49352. * Helps adjusting the shadow to a softer level if required.
  49353. * 0 means black shadows and 1 means no shadows.
  49354. */
  49355. shadowLevel: float;
  49356. protected _sceneCenter: Vector3;
  49357. /**
  49358. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49359. * It is usually zero but might be interesting to modify according to your setup.
  49360. */
  49361. sceneCenter: Vector3;
  49362. protected _opacityFresnel: boolean;
  49363. /**
  49364. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49365. * This helps ensuring a nice transition when the camera goes under the ground.
  49366. */
  49367. opacityFresnel: boolean;
  49368. protected _reflectionFresnel: boolean;
  49369. /**
  49370. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49371. * This helps adding a mirror texture on the ground.
  49372. */
  49373. reflectionFresnel: boolean;
  49374. protected _reflectionFalloffDistance: number;
  49375. /**
  49376. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49377. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49378. */
  49379. reflectionFalloffDistance: number;
  49380. protected _reflectionAmount: number;
  49381. /**
  49382. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49383. */
  49384. reflectionAmount: number;
  49385. protected _reflectionReflectance0: number;
  49386. /**
  49387. * This specifies the weight of the reflection at grazing angle.
  49388. */
  49389. reflectionReflectance0: number;
  49390. protected _reflectionReflectance90: number;
  49391. /**
  49392. * This specifies the weight of the reflection at a perpendicular point of view.
  49393. */
  49394. reflectionReflectance90: number;
  49395. /**
  49396. * Sets the reflection reflectance fresnel values according to the default standard
  49397. * empirically know to work well :-)
  49398. */
  49399. set reflectionStandardFresnelWeight(value: number);
  49400. protected _useRGBColor: boolean;
  49401. /**
  49402. * Helps to directly use the maps channels instead of their level.
  49403. */
  49404. useRGBColor: boolean;
  49405. protected _enableNoise: boolean;
  49406. /**
  49407. * This helps reducing the banding effect that could occur on the background.
  49408. */
  49409. enableNoise: boolean;
  49410. /**
  49411. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49412. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49413. * Recommended to be keep at 1.0 except for special cases.
  49414. */
  49415. get fovMultiplier(): number;
  49416. set fovMultiplier(value: number);
  49417. private _fovMultiplier;
  49418. /**
  49419. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49420. */
  49421. useEquirectangularFOV: boolean;
  49422. private _maxSimultaneousLights;
  49423. /**
  49424. * Number of Simultaneous lights allowed on the material.
  49425. */
  49426. maxSimultaneousLights: int;
  49427. /**
  49428. * Default configuration related to image processing available in the Background Material.
  49429. */
  49430. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49431. /**
  49432. * Keep track of the image processing observer to allow dispose and replace.
  49433. */
  49434. private _imageProcessingObserver;
  49435. /**
  49436. * Attaches a new image processing configuration to the PBR Material.
  49437. * @param configuration (if null the scene configuration will be use)
  49438. */
  49439. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49440. /**
  49441. * Gets the image processing configuration used either in this material.
  49442. */
  49443. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49444. /**
  49445. * Sets the Default image processing configuration used either in the this material.
  49446. *
  49447. * If sets to null, the scene one is in use.
  49448. */
  49449. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49450. /**
  49451. * Gets wether the color curves effect is enabled.
  49452. */
  49453. get cameraColorCurvesEnabled(): boolean;
  49454. /**
  49455. * Sets wether the color curves effect is enabled.
  49456. */
  49457. set cameraColorCurvesEnabled(value: boolean);
  49458. /**
  49459. * Gets wether the color grading effect is enabled.
  49460. */
  49461. get cameraColorGradingEnabled(): boolean;
  49462. /**
  49463. * Gets wether the color grading effect is enabled.
  49464. */
  49465. set cameraColorGradingEnabled(value: boolean);
  49466. /**
  49467. * Gets wether tonemapping is enabled or not.
  49468. */
  49469. get cameraToneMappingEnabled(): boolean;
  49470. /**
  49471. * Sets wether tonemapping is enabled or not
  49472. */
  49473. set cameraToneMappingEnabled(value: boolean);
  49474. /**
  49475. * The camera exposure used on this material.
  49476. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49477. * This corresponds to a photographic exposure.
  49478. */
  49479. get cameraExposure(): float;
  49480. /**
  49481. * The camera exposure used on this material.
  49482. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49483. * This corresponds to a photographic exposure.
  49484. */
  49485. set cameraExposure(value: float);
  49486. /**
  49487. * Gets The camera contrast used on this material.
  49488. */
  49489. get cameraContrast(): float;
  49490. /**
  49491. * Sets The camera contrast used on this material.
  49492. */
  49493. set cameraContrast(value: float);
  49494. /**
  49495. * Gets the Color Grading 2D Lookup Texture.
  49496. */
  49497. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49498. /**
  49499. * Sets the Color Grading 2D Lookup Texture.
  49500. */
  49501. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49502. /**
  49503. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49504. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49505. * 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;
  49506. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49507. */
  49508. get cameraColorCurves(): Nullable<ColorCurves>;
  49509. /**
  49510. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49511. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49512. * 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;
  49513. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49514. */
  49515. set cameraColorCurves(value: Nullable<ColorCurves>);
  49516. /**
  49517. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49518. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49519. */
  49520. switchToBGR: boolean;
  49521. private _renderTargets;
  49522. private _reflectionControls;
  49523. private _white;
  49524. private _primaryShadowColor;
  49525. private _primaryHighlightColor;
  49526. /**
  49527. * Instantiates a Background Material in the given scene
  49528. * @param name The friendly name of the material
  49529. * @param scene The scene to add the material to
  49530. */
  49531. constructor(name: string, scene: Scene);
  49532. /**
  49533. * Gets a boolean indicating that current material needs to register RTT
  49534. */
  49535. get hasRenderTargetTextures(): boolean;
  49536. /**
  49537. * The entire material has been created in order to prevent overdraw.
  49538. * @returns false
  49539. */
  49540. needAlphaTesting(): boolean;
  49541. /**
  49542. * The entire material has been created in order to prevent overdraw.
  49543. * @returns true if blending is enable
  49544. */
  49545. needAlphaBlending(): boolean;
  49546. /**
  49547. * Checks wether the material is ready to be rendered for a given mesh.
  49548. * @param mesh The mesh to render
  49549. * @param subMesh The submesh to check against
  49550. * @param useInstances Specify wether or not the material is used with instances
  49551. * @returns true if all the dependencies are ready (Textures, Effects...)
  49552. */
  49553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49554. /**
  49555. * Compute the primary color according to the chosen perceptual color.
  49556. */
  49557. private _computePrimaryColorFromPerceptualColor;
  49558. /**
  49559. * Compute the highlights and shadow colors according to their chosen levels.
  49560. */
  49561. private _computePrimaryColors;
  49562. /**
  49563. * Build the uniform buffer used in the material.
  49564. */
  49565. buildUniformLayout(): void;
  49566. /**
  49567. * Unbind the material.
  49568. */
  49569. unbind(): void;
  49570. /**
  49571. * Bind only the world matrix to the material.
  49572. * @param world The world matrix to bind.
  49573. */
  49574. bindOnlyWorldMatrix(world: Matrix): void;
  49575. /**
  49576. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49577. * @param world The world matrix to bind.
  49578. * @param subMesh The submesh to bind for.
  49579. */
  49580. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49581. /**
  49582. * Checks to see if a texture is used in the material.
  49583. * @param texture - Base texture to use.
  49584. * @returns - Boolean specifying if a texture is used in the material.
  49585. */
  49586. hasTexture(texture: BaseTexture): boolean;
  49587. /**
  49588. * Dispose the material.
  49589. * @param forceDisposeEffect Force disposal of the associated effect.
  49590. * @param forceDisposeTextures Force disposal of the associated textures.
  49591. */
  49592. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49593. /**
  49594. * Clones the material.
  49595. * @param name The cloned name.
  49596. * @returns The cloned material.
  49597. */
  49598. clone(name: string): BackgroundMaterial;
  49599. /**
  49600. * Serializes the current material to its JSON representation.
  49601. * @returns The JSON representation.
  49602. */
  49603. serialize(): any;
  49604. /**
  49605. * Gets the class name of the material
  49606. * @returns "BackgroundMaterial"
  49607. */
  49608. getClassName(): string;
  49609. /**
  49610. * Parse a JSON input to create back a background material.
  49611. * @param source The JSON data to parse
  49612. * @param scene The scene to create the parsed material in
  49613. * @param rootUrl The root url of the assets the material depends upon
  49614. * @returns the instantiated BackgroundMaterial.
  49615. */
  49616. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49617. }
  49618. }
  49619. declare module BABYLON {
  49620. /**
  49621. * Represents the different options available during the creation of
  49622. * a Environment helper.
  49623. *
  49624. * This can control the default ground, skybox and image processing setup of your scene.
  49625. */
  49626. export interface IEnvironmentHelperOptions {
  49627. /**
  49628. * Specifies whether or not to create a ground.
  49629. * True by default.
  49630. */
  49631. createGround: boolean;
  49632. /**
  49633. * Specifies the ground size.
  49634. * 15 by default.
  49635. */
  49636. groundSize: number;
  49637. /**
  49638. * The texture used on the ground for the main color.
  49639. * Comes from the BabylonJS CDN by default.
  49640. *
  49641. * Remarks: Can be either a texture or a url.
  49642. */
  49643. groundTexture: string | BaseTexture;
  49644. /**
  49645. * The color mixed in the ground texture by default.
  49646. * BabylonJS clearColor by default.
  49647. */
  49648. groundColor: Color3;
  49649. /**
  49650. * Specifies the ground opacity.
  49651. * 1 by default.
  49652. */
  49653. groundOpacity: number;
  49654. /**
  49655. * Enables the ground to receive shadows.
  49656. * True by default.
  49657. */
  49658. enableGroundShadow: boolean;
  49659. /**
  49660. * Helps preventing the shadow to be fully black on the ground.
  49661. * 0.5 by default.
  49662. */
  49663. groundShadowLevel: number;
  49664. /**
  49665. * Creates a mirror texture attach to the ground.
  49666. * false by default.
  49667. */
  49668. enableGroundMirror: boolean;
  49669. /**
  49670. * Specifies the ground mirror size ratio.
  49671. * 0.3 by default as the default kernel is 64.
  49672. */
  49673. groundMirrorSizeRatio: number;
  49674. /**
  49675. * Specifies the ground mirror blur kernel size.
  49676. * 64 by default.
  49677. */
  49678. groundMirrorBlurKernel: number;
  49679. /**
  49680. * Specifies the ground mirror visibility amount.
  49681. * 1 by default
  49682. */
  49683. groundMirrorAmount: number;
  49684. /**
  49685. * Specifies the ground mirror reflectance weight.
  49686. * This uses the standard weight of the background material to setup the fresnel effect
  49687. * of the mirror.
  49688. * 1 by default.
  49689. */
  49690. groundMirrorFresnelWeight: number;
  49691. /**
  49692. * Specifies the ground mirror Falloff distance.
  49693. * This can helps reducing the size of the reflection.
  49694. * 0 by Default.
  49695. */
  49696. groundMirrorFallOffDistance: number;
  49697. /**
  49698. * Specifies the ground mirror texture type.
  49699. * Unsigned Int by Default.
  49700. */
  49701. groundMirrorTextureType: number;
  49702. /**
  49703. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49704. * the shown objects.
  49705. */
  49706. groundYBias: number;
  49707. /**
  49708. * Specifies whether or not to create a skybox.
  49709. * True by default.
  49710. */
  49711. createSkybox: boolean;
  49712. /**
  49713. * Specifies the skybox size.
  49714. * 20 by default.
  49715. */
  49716. skyboxSize: number;
  49717. /**
  49718. * The texture used on the skybox for the main color.
  49719. * Comes from the BabylonJS CDN by default.
  49720. *
  49721. * Remarks: Can be either a texture or a url.
  49722. */
  49723. skyboxTexture: string | BaseTexture;
  49724. /**
  49725. * The color mixed in the skybox texture by default.
  49726. * BabylonJS clearColor by default.
  49727. */
  49728. skyboxColor: Color3;
  49729. /**
  49730. * The background rotation around the Y axis of the scene.
  49731. * This helps aligning the key lights of your scene with the background.
  49732. * 0 by default.
  49733. */
  49734. backgroundYRotation: number;
  49735. /**
  49736. * Compute automatically the size of the elements to best fit with the scene.
  49737. */
  49738. sizeAuto: boolean;
  49739. /**
  49740. * Default position of the rootMesh if autoSize is not true.
  49741. */
  49742. rootPosition: Vector3;
  49743. /**
  49744. * Sets up the image processing in the scene.
  49745. * true by default.
  49746. */
  49747. setupImageProcessing: boolean;
  49748. /**
  49749. * The texture used as your environment texture in the scene.
  49750. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49751. *
  49752. * Remarks: Can be either a texture or a url.
  49753. */
  49754. environmentTexture: string | BaseTexture;
  49755. /**
  49756. * The value of the exposure to apply to the scene.
  49757. * 0.6 by default if setupImageProcessing is true.
  49758. */
  49759. cameraExposure: number;
  49760. /**
  49761. * The value of the contrast to apply to the scene.
  49762. * 1.6 by default if setupImageProcessing is true.
  49763. */
  49764. cameraContrast: number;
  49765. /**
  49766. * Specifies whether or not tonemapping should be enabled in the scene.
  49767. * true by default if setupImageProcessing is true.
  49768. */
  49769. toneMappingEnabled: boolean;
  49770. }
  49771. /**
  49772. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49773. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49774. * It also helps with the default setup of your imageProcessing configuration.
  49775. */
  49776. export class EnvironmentHelper {
  49777. /**
  49778. * Default ground texture URL.
  49779. */
  49780. private static _groundTextureCDNUrl;
  49781. /**
  49782. * Default skybox texture URL.
  49783. */
  49784. private static _skyboxTextureCDNUrl;
  49785. /**
  49786. * Default environment texture URL.
  49787. */
  49788. private static _environmentTextureCDNUrl;
  49789. /**
  49790. * Creates the default options for the helper.
  49791. */
  49792. private static _getDefaultOptions;
  49793. private _rootMesh;
  49794. /**
  49795. * Gets the root mesh created by the helper.
  49796. */
  49797. get rootMesh(): Mesh;
  49798. private _skybox;
  49799. /**
  49800. * Gets the skybox created by the helper.
  49801. */
  49802. get skybox(): Nullable<Mesh>;
  49803. private _skyboxTexture;
  49804. /**
  49805. * Gets the skybox texture created by the helper.
  49806. */
  49807. get skyboxTexture(): Nullable<BaseTexture>;
  49808. private _skyboxMaterial;
  49809. /**
  49810. * Gets the skybox material created by the helper.
  49811. */
  49812. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49813. private _ground;
  49814. /**
  49815. * Gets the ground mesh created by the helper.
  49816. */
  49817. get ground(): Nullable<Mesh>;
  49818. private _groundTexture;
  49819. /**
  49820. * Gets the ground texture created by the helper.
  49821. */
  49822. get groundTexture(): Nullable<BaseTexture>;
  49823. private _groundMirror;
  49824. /**
  49825. * Gets the ground mirror created by the helper.
  49826. */
  49827. get groundMirror(): Nullable<MirrorTexture>;
  49828. /**
  49829. * Gets the ground mirror render list to helps pushing the meshes
  49830. * you wish in the ground reflection.
  49831. */
  49832. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49833. private _groundMaterial;
  49834. /**
  49835. * Gets the ground material created by the helper.
  49836. */
  49837. get groundMaterial(): Nullable<BackgroundMaterial>;
  49838. /**
  49839. * Stores the creation options.
  49840. */
  49841. private readonly _scene;
  49842. private _options;
  49843. /**
  49844. * This observable will be notified with any error during the creation of the environment,
  49845. * mainly texture creation errors.
  49846. */
  49847. onErrorObservable: Observable<{
  49848. message?: string;
  49849. exception?: any;
  49850. }>;
  49851. /**
  49852. * constructor
  49853. * @param options Defines the options we want to customize the helper
  49854. * @param scene The scene to add the material to
  49855. */
  49856. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49857. /**
  49858. * Updates the background according to the new options
  49859. * @param options
  49860. */
  49861. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49862. /**
  49863. * Sets the primary color of all the available elements.
  49864. * @param color the main color to affect to the ground and the background
  49865. */
  49866. setMainColor(color: Color3): void;
  49867. /**
  49868. * Setup the image processing according to the specified options.
  49869. */
  49870. private _setupImageProcessing;
  49871. /**
  49872. * Setup the environment texture according to the specified options.
  49873. */
  49874. private _setupEnvironmentTexture;
  49875. /**
  49876. * Setup the background according to the specified options.
  49877. */
  49878. private _setupBackground;
  49879. /**
  49880. * Get the scene sizes according to the setup.
  49881. */
  49882. private _getSceneSize;
  49883. /**
  49884. * Setup the ground according to the specified options.
  49885. */
  49886. private _setupGround;
  49887. /**
  49888. * Setup the ground material according to the specified options.
  49889. */
  49890. private _setupGroundMaterial;
  49891. /**
  49892. * Setup the ground diffuse texture according to the specified options.
  49893. */
  49894. private _setupGroundDiffuseTexture;
  49895. /**
  49896. * Setup the ground mirror texture according to the specified options.
  49897. */
  49898. private _setupGroundMirrorTexture;
  49899. /**
  49900. * Setup the ground to receive the mirror texture.
  49901. */
  49902. private _setupMirrorInGroundMaterial;
  49903. /**
  49904. * Setup the skybox according to the specified options.
  49905. */
  49906. private _setupSkybox;
  49907. /**
  49908. * Setup the skybox material according to the specified options.
  49909. */
  49910. private _setupSkyboxMaterial;
  49911. /**
  49912. * Setup the skybox reflection texture according to the specified options.
  49913. */
  49914. private _setupSkyboxReflectionTexture;
  49915. private _errorHandler;
  49916. /**
  49917. * Dispose all the elements created by the Helper.
  49918. */
  49919. dispose(): void;
  49920. }
  49921. }
  49922. declare module BABYLON {
  49923. /**
  49924. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49925. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49926. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49927. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49928. */
  49929. export class PhotoDome extends TransformNode {
  49930. /**
  49931. * Define the image as a Monoscopic panoramic 360 image.
  49932. */
  49933. static readonly MODE_MONOSCOPIC: number;
  49934. /**
  49935. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49936. */
  49937. static readonly MODE_TOPBOTTOM: number;
  49938. /**
  49939. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49940. */
  49941. static readonly MODE_SIDEBYSIDE: number;
  49942. private _useDirectMapping;
  49943. /**
  49944. * The texture being displayed on the sphere
  49945. */
  49946. protected _photoTexture: Texture;
  49947. /**
  49948. * Gets or sets the texture being displayed on the sphere
  49949. */
  49950. get photoTexture(): Texture;
  49951. set photoTexture(value: Texture);
  49952. /**
  49953. * Observable raised when an error occured while loading the 360 image
  49954. */
  49955. onLoadErrorObservable: Observable<string>;
  49956. /**
  49957. * The skybox material
  49958. */
  49959. protected _material: BackgroundMaterial;
  49960. /**
  49961. * The surface used for the skybox
  49962. */
  49963. protected _mesh: Mesh;
  49964. /**
  49965. * Gets the mesh used for the skybox.
  49966. */
  49967. get mesh(): Mesh;
  49968. /**
  49969. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49970. * Also see the options.resolution property.
  49971. */
  49972. get fovMultiplier(): number;
  49973. set fovMultiplier(value: number);
  49974. private _imageMode;
  49975. /**
  49976. * Gets or set the current video mode for the video. It can be:
  49977. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49978. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49979. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49980. */
  49981. get imageMode(): number;
  49982. set imageMode(value: number);
  49983. /**
  49984. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49985. * @param name Element's name, child elements will append suffixes for their own names.
  49986. * @param urlsOfPhoto defines the url of the photo to display
  49987. * @param options defines an object containing optional or exposed sub element properties
  49988. * @param onError defines a callback called when an error occured while loading the texture
  49989. */
  49990. constructor(name: string, urlOfPhoto: string, options: {
  49991. resolution?: number;
  49992. size?: number;
  49993. useDirectMapping?: boolean;
  49994. faceForward?: boolean;
  49995. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49996. private _onBeforeCameraRenderObserver;
  49997. private _changeImageMode;
  49998. /**
  49999. * Releases resources associated with this node.
  50000. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50001. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50002. */
  50003. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50004. }
  50005. }
  50006. declare module BABYLON {
  50007. /**
  50008. * Class used to host RGBD texture specific utilities
  50009. */
  50010. export class RGBDTextureTools {
  50011. /**
  50012. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50013. * @param texture the texture to expand.
  50014. */
  50015. static ExpandRGBDTexture(texture: Texture): void;
  50016. }
  50017. }
  50018. declare module BABYLON {
  50019. /**
  50020. * Class used to host texture specific utilities
  50021. */
  50022. export class BRDFTextureTools {
  50023. /**
  50024. * Prevents texture cache collision
  50025. */
  50026. private static _instanceNumber;
  50027. /**
  50028. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50029. * @param scene defines the hosting scene
  50030. * @returns the environment BRDF texture
  50031. */
  50032. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50033. private static _environmentBRDFBase64Texture;
  50034. }
  50035. }
  50036. declare module BABYLON {
  50037. /**
  50038. * @hidden
  50039. */
  50040. export interface IMaterialClearCoatDefines {
  50041. CLEARCOAT: boolean;
  50042. CLEARCOAT_DEFAULTIOR: boolean;
  50043. CLEARCOAT_TEXTURE: boolean;
  50044. CLEARCOAT_TEXTUREDIRECTUV: number;
  50045. CLEARCOAT_BUMP: boolean;
  50046. CLEARCOAT_BUMPDIRECTUV: number;
  50047. CLEARCOAT_TINT: boolean;
  50048. CLEARCOAT_TINT_TEXTURE: boolean;
  50049. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50050. /** @hidden */
  50051. _areTexturesDirty: boolean;
  50052. }
  50053. /**
  50054. * Define the code related to the clear coat parameters of the pbr material.
  50055. */
  50056. export class PBRClearCoatConfiguration {
  50057. /**
  50058. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50059. * The default fits with a polyurethane material.
  50060. */
  50061. private static readonly _DefaultIndexOfRefraction;
  50062. private _isEnabled;
  50063. /**
  50064. * Defines if the clear coat is enabled in the material.
  50065. */
  50066. isEnabled: boolean;
  50067. /**
  50068. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50069. */
  50070. intensity: number;
  50071. /**
  50072. * Defines the clear coat layer roughness.
  50073. */
  50074. roughness: number;
  50075. private _indexOfRefraction;
  50076. /**
  50077. * Defines the index of refraction of the clear coat.
  50078. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50079. * The default fits with a polyurethane material.
  50080. * Changing the default value is more performance intensive.
  50081. */
  50082. indexOfRefraction: number;
  50083. private _texture;
  50084. /**
  50085. * Stores the clear coat values in a texture.
  50086. */
  50087. texture: Nullable<BaseTexture>;
  50088. private _bumpTexture;
  50089. /**
  50090. * Define the clear coat specific bump texture.
  50091. */
  50092. bumpTexture: Nullable<BaseTexture>;
  50093. private _isTintEnabled;
  50094. /**
  50095. * Defines if the clear coat tint is enabled in the material.
  50096. */
  50097. isTintEnabled: boolean;
  50098. /**
  50099. * Defines the clear coat tint of the material.
  50100. * This is only use if tint is enabled
  50101. */
  50102. tintColor: Color3;
  50103. /**
  50104. * Defines the distance at which the tint color should be found in the
  50105. * clear coat media.
  50106. * This is only use if tint is enabled
  50107. */
  50108. tintColorAtDistance: number;
  50109. /**
  50110. * Defines the clear coat layer thickness.
  50111. * This is only use if tint is enabled
  50112. */
  50113. tintThickness: number;
  50114. private _tintTexture;
  50115. /**
  50116. * Stores the clear tint values in a texture.
  50117. * rgb is tint
  50118. * a is a thickness factor
  50119. */
  50120. tintTexture: Nullable<BaseTexture>;
  50121. /** @hidden */
  50122. private _internalMarkAllSubMeshesAsTexturesDirty;
  50123. /** @hidden */
  50124. _markAllSubMeshesAsTexturesDirty(): void;
  50125. /**
  50126. * Instantiate a new istance of clear coat configuration.
  50127. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50128. */
  50129. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50130. /**
  50131. * Gets wehter the submesh is ready to be used or not.
  50132. * @param defines the list of "defines" to update.
  50133. * @param scene defines the scene the material belongs to.
  50134. * @param engine defines the engine the material belongs to.
  50135. * @param disableBumpMap defines wether the material disables bump or not.
  50136. * @returns - boolean indicating that the submesh is ready or not.
  50137. */
  50138. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50139. /**
  50140. * Checks to see if a texture is used in the material.
  50141. * @param defines the list of "defines" to update.
  50142. * @param scene defines the scene to the material belongs to.
  50143. */
  50144. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50145. /**
  50146. * Binds the material data.
  50147. * @param uniformBuffer defines the Uniform buffer to fill in.
  50148. * @param scene defines the scene the material belongs to.
  50149. * @param engine defines the engine the material belongs to.
  50150. * @param disableBumpMap defines wether the material disables bump or not.
  50151. * @param isFrozen defines wether the material is frozen or not.
  50152. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50153. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50154. */
  50155. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50156. /**
  50157. * Checks to see if a texture is used in the material.
  50158. * @param texture - Base texture to use.
  50159. * @returns - Boolean specifying if a texture is used in the material.
  50160. */
  50161. hasTexture(texture: BaseTexture): boolean;
  50162. /**
  50163. * Returns an array of the actively used textures.
  50164. * @param activeTextures Array of BaseTextures
  50165. */
  50166. getActiveTextures(activeTextures: BaseTexture[]): void;
  50167. /**
  50168. * Returns the animatable textures.
  50169. * @param animatables Array of animatable textures.
  50170. */
  50171. getAnimatables(animatables: IAnimatable[]): void;
  50172. /**
  50173. * Disposes the resources of the material.
  50174. * @param forceDisposeTextures - Forces the disposal of all textures.
  50175. */
  50176. dispose(forceDisposeTextures?: boolean): void;
  50177. /**
  50178. * Get the current class name of the texture useful for serialization or dynamic coding.
  50179. * @returns "PBRClearCoatConfiguration"
  50180. */
  50181. getClassName(): string;
  50182. /**
  50183. * Add fallbacks to the effect fallbacks list.
  50184. * @param defines defines the Base texture to use.
  50185. * @param fallbacks defines the current fallback list.
  50186. * @param currentRank defines the current fallback rank.
  50187. * @returns the new fallback rank.
  50188. */
  50189. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50190. /**
  50191. * Add the required uniforms to the current list.
  50192. * @param uniforms defines the current uniform list.
  50193. */
  50194. static AddUniforms(uniforms: string[]): void;
  50195. /**
  50196. * Add the required samplers to the current list.
  50197. * @param samplers defines the current sampler list.
  50198. */
  50199. static AddSamplers(samplers: string[]): void;
  50200. /**
  50201. * Add the required uniforms to the current buffer.
  50202. * @param uniformBuffer defines the current uniform buffer.
  50203. */
  50204. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50205. /**
  50206. * Makes a duplicate of the current configuration into another one.
  50207. * @param clearCoatConfiguration define the config where to copy the info
  50208. */
  50209. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50210. /**
  50211. * Serializes this clear coat configuration.
  50212. * @returns - An object with the serialized config.
  50213. */
  50214. serialize(): any;
  50215. /**
  50216. * Parses a anisotropy Configuration from a serialized object.
  50217. * @param source - Serialized object.
  50218. * @param scene Defines the scene we are parsing for
  50219. * @param rootUrl Defines the rootUrl to load from
  50220. */
  50221. parse(source: any, scene: Scene, rootUrl: string): void;
  50222. }
  50223. }
  50224. declare module BABYLON {
  50225. /**
  50226. * @hidden
  50227. */
  50228. export interface IMaterialAnisotropicDefines {
  50229. ANISOTROPIC: boolean;
  50230. ANISOTROPIC_TEXTURE: boolean;
  50231. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50232. MAINUV1: boolean;
  50233. _areTexturesDirty: boolean;
  50234. _needUVs: boolean;
  50235. }
  50236. /**
  50237. * Define the code related to the anisotropic parameters of the pbr material.
  50238. */
  50239. export class PBRAnisotropicConfiguration {
  50240. private _isEnabled;
  50241. /**
  50242. * Defines if the anisotropy is enabled in the material.
  50243. */
  50244. isEnabled: boolean;
  50245. /**
  50246. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50247. */
  50248. intensity: number;
  50249. /**
  50250. * Defines if the effect is along the tangents, bitangents or in between.
  50251. * By default, the effect is "strectching" the highlights along the tangents.
  50252. */
  50253. direction: Vector2;
  50254. private _texture;
  50255. /**
  50256. * Stores the anisotropy values in a texture.
  50257. * rg is direction (like normal from -1 to 1)
  50258. * b is a intensity
  50259. */
  50260. texture: Nullable<BaseTexture>;
  50261. /** @hidden */
  50262. private _internalMarkAllSubMeshesAsTexturesDirty;
  50263. /** @hidden */
  50264. _markAllSubMeshesAsTexturesDirty(): void;
  50265. /**
  50266. * Instantiate a new istance of anisotropy configuration.
  50267. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50268. */
  50269. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50270. /**
  50271. * Specifies that the submesh is ready to be used.
  50272. * @param defines the list of "defines" to update.
  50273. * @param scene defines the scene the material belongs to.
  50274. * @returns - boolean indicating that the submesh is ready or not.
  50275. */
  50276. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50277. /**
  50278. * Checks to see if a texture is used in the material.
  50279. * @param defines the list of "defines" to update.
  50280. * @param mesh the mesh we are preparing the defines for.
  50281. * @param scene defines the scene the material belongs to.
  50282. */
  50283. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50284. /**
  50285. * Binds the material data.
  50286. * @param uniformBuffer defines the Uniform buffer to fill in.
  50287. * @param scene defines the scene the material belongs to.
  50288. * @param isFrozen defines wether the material is frozen or not.
  50289. */
  50290. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50291. /**
  50292. * Checks to see if a texture is used in the material.
  50293. * @param texture - Base texture to use.
  50294. * @returns - Boolean specifying if a texture is used in the material.
  50295. */
  50296. hasTexture(texture: BaseTexture): boolean;
  50297. /**
  50298. * Returns an array of the actively used textures.
  50299. * @param activeTextures Array of BaseTextures
  50300. */
  50301. getActiveTextures(activeTextures: BaseTexture[]): void;
  50302. /**
  50303. * Returns the animatable textures.
  50304. * @param animatables Array of animatable textures.
  50305. */
  50306. getAnimatables(animatables: IAnimatable[]): void;
  50307. /**
  50308. * Disposes the resources of the material.
  50309. * @param forceDisposeTextures - Forces the disposal of all textures.
  50310. */
  50311. dispose(forceDisposeTextures?: boolean): void;
  50312. /**
  50313. * Get the current class name of the texture useful for serialization or dynamic coding.
  50314. * @returns "PBRAnisotropicConfiguration"
  50315. */
  50316. getClassName(): string;
  50317. /**
  50318. * Add fallbacks to the effect fallbacks list.
  50319. * @param defines defines the Base texture to use.
  50320. * @param fallbacks defines the current fallback list.
  50321. * @param currentRank defines the current fallback rank.
  50322. * @returns the new fallback rank.
  50323. */
  50324. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50325. /**
  50326. * Add the required uniforms to the current list.
  50327. * @param uniforms defines the current uniform list.
  50328. */
  50329. static AddUniforms(uniforms: string[]): void;
  50330. /**
  50331. * Add the required uniforms to the current buffer.
  50332. * @param uniformBuffer defines the current uniform buffer.
  50333. */
  50334. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50335. /**
  50336. * Add the required samplers to the current list.
  50337. * @param samplers defines the current sampler list.
  50338. */
  50339. static AddSamplers(samplers: string[]): void;
  50340. /**
  50341. * Makes a duplicate of the current configuration into another one.
  50342. * @param anisotropicConfiguration define the config where to copy the info
  50343. */
  50344. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50345. /**
  50346. * Serializes this anisotropy configuration.
  50347. * @returns - An object with the serialized config.
  50348. */
  50349. serialize(): any;
  50350. /**
  50351. * Parses a anisotropy Configuration from a serialized object.
  50352. * @param source - Serialized object.
  50353. * @param scene Defines the scene we are parsing for
  50354. * @param rootUrl Defines the rootUrl to load from
  50355. */
  50356. parse(source: any, scene: Scene, rootUrl: string): void;
  50357. }
  50358. }
  50359. declare module BABYLON {
  50360. /**
  50361. * @hidden
  50362. */
  50363. export interface IMaterialBRDFDefines {
  50364. BRDF_V_HEIGHT_CORRELATED: boolean;
  50365. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50366. SPHERICAL_HARMONICS: boolean;
  50367. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50368. /** @hidden */
  50369. _areMiscDirty: boolean;
  50370. }
  50371. /**
  50372. * Define the code related to the BRDF parameters of the pbr material.
  50373. */
  50374. export class PBRBRDFConfiguration {
  50375. /**
  50376. * Default value used for the energy conservation.
  50377. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50378. */
  50379. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50380. /**
  50381. * Default value used for the Smith Visibility Height Correlated mode.
  50382. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50383. */
  50384. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50385. /**
  50386. * Default value used for the IBL diffuse part.
  50387. * This can help switching back to the polynomials mode globally which is a tiny bit
  50388. * less GPU intensive at the drawback of a lower quality.
  50389. */
  50390. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50391. /**
  50392. * Default value used for activating energy conservation for the specular workflow.
  50393. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50394. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50395. */
  50396. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50397. private _useEnergyConservation;
  50398. /**
  50399. * Defines if the material uses energy conservation.
  50400. */
  50401. useEnergyConservation: boolean;
  50402. private _useSmithVisibilityHeightCorrelated;
  50403. /**
  50404. * LEGACY Mode set to false
  50405. * Defines if the material uses height smith correlated visibility term.
  50406. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50407. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50408. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50409. * Not relying on height correlated will also disable energy conservation.
  50410. */
  50411. useSmithVisibilityHeightCorrelated: boolean;
  50412. private _useSphericalHarmonics;
  50413. /**
  50414. * LEGACY Mode set to false
  50415. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50416. * diffuse part of the IBL.
  50417. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50418. * to the ground truth.
  50419. */
  50420. useSphericalHarmonics: boolean;
  50421. private _useSpecularGlossinessInputEnergyConservation;
  50422. /**
  50423. * Defines if the material uses energy conservation, when the specular workflow is active.
  50424. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50425. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50426. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50427. */
  50428. useSpecularGlossinessInputEnergyConservation: boolean;
  50429. /** @hidden */
  50430. private _internalMarkAllSubMeshesAsMiscDirty;
  50431. /** @hidden */
  50432. _markAllSubMeshesAsMiscDirty(): void;
  50433. /**
  50434. * Instantiate a new istance of clear coat configuration.
  50435. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50436. */
  50437. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50438. /**
  50439. * Checks to see if a texture is used in the material.
  50440. * @param defines the list of "defines" to update.
  50441. */
  50442. prepareDefines(defines: IMaterialBRDFDefines): void;
  50443. /**
  50444. * Get the current class name of the texture useful for serialization or dynamic coding.
  50445. * @returns "PBRClearCoatConfiguration"
  50446. */
  50447. getClassName(): string;
  50448. /**
  50449. * Makes a duplicate of the current configuration into another one.
  50450. * @param brdfConfiguration define the config where to copy the info
  50451. */
  50452. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50453. /**
  50454. * Serializes this BRDF configuration.
  50455. * @returns - An object with the serialized config.
  50456. */
  50457. serialize(): any;
  50458. /**
  50459. * Parses a anisotropy Configuration from a serialized object.
  50460. * @param source - Serialized object.
  50461. * @param scene Defines the scene we are parsing for
  50462. * @param rootUrl Defines the rootUrl to load from
  50463. */
  50464. parse(source: any, scene: Scene, rootUrl: string): void;
  50465. }
  50466. }
  50467. declare module BABYLON {
  50468. /**
  50469. * @hidden
  50470. */
  50471. export interface IMaterialSheenDefines {
  50472. SHEEN: boolean;
  50473. SHEEN_TEXTURE: boolean;
  50474. SHEEN_TEXTUREDIRECTUV: number;
  50475. SHEEN_LINKWITHALBEDO: boolean;
  50476. SHEEN_ROUGHNESS: boolean;
  50477. SHEEN_ALBEDOSCALING: boolean;
  50478. /** @hidden */
  50479. _areTexturesDirty: boolean;
  50480. }
  50481. /**
  50482. * Define the code related to the Sheen parameters of the pbr material.
  50483. */
  50484. export class PBRSheenConfiguration {
  50485. private _isEnabled;
  50486. /**
  50487. * Defines if the material uses sheen.
  50488. */
  50489. isEnabled: boolean;
  50490. private _linkSheenWithAlbedo;
  50491. /**
  50492. * Defines if the sheen is linked to the sheen color.
  50493. */
  50494. linkSheenWithAlbedo: boolean;
  50495. /**
  50496. * Defines the sheen intensity.
  50497. */
  50498. intensity: number;
  50499. /**
  50500. * Defines the sheen color.
  50501. */
  50502. color: Color3;
  50503. private _texture;
  50504. /**
  50505. * Stores the sheen tint values in a texture.
  50506. * rgb is tint
  50507. * a is a intensity
  50508. */
  50509. texture: Nullable<BaseTexture>;
  50510. private _roughness;
  50511. /**
  50512. * Defines the sheen roughness.
  50513. * It is not taken into account if linkSheenWithAlbedo is true.
  50514. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50515. */
  50516. roughness: Nullable<number>;
  50517. private _albedoScaling;
  50518. /**
  50519. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50520. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50521. * making it easier to setup and tweak the effect
  50522. */
  50523. albedoScaling: boolean;
  50524. /** @hidden */
  50525. private _internalMarkAllSubMeshesAsTexturesDirty;
  50526. /** @hidden */
  50527. _markAllSubMeshesAsTexturesDirty(): void;
  50528. /**
  50529. * Instantiate a new istance of clear coat configuration.
  50530. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50531. */
  50532. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50533. /**
  50534. * Specifies that the submesh is ready to be used.
  50535. * @param defines the list of "defines" to update.
  50536. * @param scene defines the scene the material belongs to.
  50537. * @returns - boolean indicating that the submesh is ready or not.
  50538. */
  50539. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50540. /**
  50541. * Checks to see if a texture is used in the material.
  50542. * @param defines the list of "defines" to update.
  50543. * @param scene defines the scene the material belongs to.
  50544. */
  50545. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50546. /**
  50547. * Binds the material data.
  50548. * @param uniformBuffer defines the Uniform buffer to fill in.
  50549. * @param scene defines the scene the material belongs to.
  50550. * @param isFrozen defines wether the material is frozen or not.
  50551. */
  50552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50553. /**
  50554. * Checks to see if a texture is used in the material.
  50555. * @param texture - Base texture to use.
  50556. * @returns - Boolean specifying if a texture is used in the material.
  50557. */
  50558. hasTexture(texture: BaseTexture): boolean;
  50559. /**
  50560. * Returns an array of the actively used textures.
  50561. * @param activeTextures Array of BaseTextures
  50562. */
  50563. getActiveTextures(activeTextures: BaseTexture[]): void;
  50564. /**
  50565. * Returns the animatable textures.
  50566. * @param animatables Array of animatable textures.
  50567. */
  50568. getAnimatables(animatables: IAnimatable[]): void;
  50569. /**
  50570. * Disposes the resources of the material.
  50571. * @param forceDisposeTextures - Forces the disposal of all textures.
  50572. */
  50573. dispose(forceDisposeTextures?: boolean): void;
  50574. /**
  50575. * Get the current class name of the texture useful for serialization or dynamic coding.
  50576. * @returns "PBRSheenConfiguration"
  50577. */
  50578. getClassName(): string;
  50579. /**
  50580. * Add fallbacks to the effect fallbacks list.
  50581. * @param defines defines the Base texture to use.
  50582. * @param fallbacks defines the current fallback list.
  50583. * @param currentRank defines the current fallback rank.
  50584. * @returns the new fallback rank.
  50585. */
  50586. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50587. /**
  50588. * Add the required uniforms to the current list.
  50589. * @param uniforms defines the current uniform list.
  50590. */
  50591. static AddUniforms(uniforms: string[]): void;
  50592. /**
  50593. * Add the required uniforms to the current buffer.
  50594. * @param uniformBuffer defines the current uniform buffer.
  50595. */
  50596. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50597. /**
  50598. * Add the required samplers to the current list.
  50599. * @param samplers defines the current sampler list.
  50600. */
  50601. static AddSamplers(samplers: string[]): void;
  50602. /**
  50603. * Makes a duplicate of the current configuration into another one.
  50604. * @param sheenConfiguration define the config where to copy the info
  50605. */
  50606. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50607. /**
  50608. * Serializes this BRDF configuration.
  50609. * @returns - An object with the serialized config.
  50610. */
  50611. serialize(): any;
  50612. /**
  50613. * Parses a anisotropy Configuration from a serialized object.
  50614. * @param source - Serialized object.
  50615. * @param scene Defines the scene we are parsing for
  50616. * @param rootUrl Defines the rootUrl to load from
  50617. */
  50618. parse(source: any, scene: Scene, rootUrl: string): void;
  50619. }
  50620. }
  50621. declare module BABYLON {
  50622. /**
  50623. * @hidden
  50624. */
  50625. export interface IMaterialSubSurfaceDefines {
  50626. SUBSURFACE: boolean;
  50627. SS_REFRACTION: boolean;
  50628. SS_TRANSLUCENCY: boolean;
  50629. SS_SCATERRING: boolean;
  50630. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50631. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50632. SS_REFRACTIONMAP_3D: boolean;
  50633. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50634. SS_LODINREFRACTIONALPHA: boolean;
  50635. SS_GAMMAREFRACTION: boolean;
  50636. SS_RGBDREFRACTION: boolean;
  50637. SS_LINEARSPECULARREFRACTION: boolean;
  50638. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50639. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50640. /** @hidden */
  50641. _areTexturesDirty: boolean;
  50642. }
  50643. /**
  50644. * Define the code related to the sub surface parameters of the pbr material.
  50645. */
  50646. export class PBRSubSurfaceConfiguration {
  50647. private _isRefractionEnabled;
  50648. /**
  50649. * Defines if the refraction is enabled in the material.
  50650. */
  50651. isRefractionEnabled: boolean;
  50652. private _isTranslucencyEnabled;
  50653. /**
  50654. * Defines if the translucency is enabled in the material.
  50655. */
  50656. isTranslucencyEnabled: boolean;
  50657. private _isScatteringEnabled;
  50658. /**
  50659. * Defines the refraction intensity of the material.
  50660. * The refraction when enabled replaces the Diffuse part of the material.
  50661. * The intensity helps transitionning between diffuse and refraction.
  50662. */
  50663. refractionIntensity: number;
  50664. /**
  50665. * Defines the translucency intensity of the material.
  50666. * When translucency has been enabled, this defines how much of the "translucency"
  50667. * is addded to the diffuse part of the material.
  50668. */
  50669. translucencyIntensity: number;
  50670. /**
  50671. * Defines the scattering intensity of the material.
  50672. * When scattering has been enabled, this defines how much of the "scattered light"
  50673. * is addded to the diffuse part of the material.
  50674. */
  50675. scatteringIntensity: number;
  50676. private _thicknessTexture;
  50677. /**
  50678. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50679. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50680. * 0 would mean minimumThickness
  50681. * 1 would mean maximumThickness
  50682. * The other channels might be use as a mask to vary the different effects intensity.
  50683. */
  50684. thicknessTexture: Nullable<BaseTexture>;
  50685. private _refractionTexture;
  50686. /**
  50687. * Defines the texture to use for refraction.
  50688. */
  50689. refractionTexture: Nullable<BaseTexture>;
  50690. private _indexOfRefraction;
  50691. /**
  50692. * Defines the index of refraction used in the material.
  50693. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50694. */
  50695. indexOfRefraction: number;
  50696. private _invertRefractionY;
  50697. /**
  50698. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50699. */
  50700. invertRefractionY: boolean;
  50701. private _linkRefractionWithTransparency;
  50702. /**
  50703. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50704. * Materials half opaque for instance using refraction could benefit from this control.
  50705. */
  50706. linkRefractionWithTransparency: boolean;
  50707. /**
  50708. * Defines the minimum thickness stored in the thickness map.
  50709. * If no thickness map is defined, this value will be used to simulate thickness.
  50710. */
  50711. minimumThickness: number;
  50712. /**
  50713. * Defines the maximum thickness stored in the thickness map.
  50714. */
  50715. maximumThickness: number;
  50716. /**
  50717. * Defines the volume tint of the material.
  50718. * This is used for both translucency and scattering.
  50719. */
  50720. tintColor: Color3;
  50721. /**
  50722. * Defines the distance at which the tint color should be found in the media.
  50723. * This is used for refraction only.
  50724. */
  50725. tintColorAtDistance: number;
  50726. /**
  50727. * Defines how far each channel transmit through the media.
  50728. * It is defined as a color to simplify it selection.
  50729. */
  50730. diffusionDistance: Color3;
  50731. private _useMaskFromThicknessTexture;
  50732. /**
  50733. * Stores the intensity of the different subsurface effects in the thickness texture.
  50734. * * the green channel is the translucency intensity.
  50735. * * the blue channel is the scattering intensity.
  50736. * * the alpha channel is the refraction intensity.
  50737. */
  50738. useMaskFromThicknessTexture: boolean;
  50739. /** @hidden */
  50740. private _internalMarkAllSubMeshesAsTexturesDirty;
  50741. /** @hidden */
  50742. _markAllSubMeshesAsTexturesDirty(): void;
  50743. /**
  50744. * Instantiate a new istance of sub surface configuration.
  50745. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50746. */
  50747. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50748. /**
  50749. * Gets wehter the submesh is ready to be used or not.
  50750. * @param defines the list of "defines" to update.
  50751. * @param scene defines the scene the material belongs to.
  50752. * @returns - boolean indicating that the submesh is ready or not.
  50753. */
  50754. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50755. /**
  50756. * Checks to see if a texture is used in the material.
  50757. * @param defines the list of "defines" to update.
  50758. * @param scene defines the scene to the material belongs to.
  50759. */
  50760. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50761. /**
  50762. * Binds the material data.
  50763. * @param uniformBuffer defines the Uniform buffer to fill in.
  50764. * @param scene defines the scene the material belongs to.
  50765. * @param engine defines the engine the material belongs to.
  50766. * @param isFrozen defines wether the material is frozen or not.
  50767. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50768. */
  50769. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50770. /**
  50771. * Unbinds the material from the mesh.
  50772. * @param activeEffect defines the effect that should be unbound from.
  50773. * @returns true if unbound, otherwise false
  50774. */
  50775. unbind(activeEffect: Effect): boolean;
  50776. /**
  50777. * Returns the texture used for refraction or null if none is used.
  50778. * @param scene defines the scene the material belongs to.
  50779. * @returns - Refraction texture if present. If no refraction texture and refraction
  50780. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50781. */
  50782. private _getRefractionTexture;
  50783. /**
  50784. * Returns true if alpha blending should be disabled.
  50785. */
  50786. get disableAlphaBlending(): boolean;
  50787. /**
  50788. * Fills the list of render target textures.
  50789. * @param renderTargets the list of render targets to update
  50790. */
  50791. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50792. /**
  50793. * Checks to see if a texture is used in the material.
  50794. * @param texture - Base texture to use.
  50795. * @returns - Boolean specifying if a texture is used in the material.
  50796. */
  50797. hasTexture(texture: BaseTexture): boolean;
  50798. /**
  50799. * Gets a boolean indicating that current material needs to register RTT
  50800. * @returns true if this uses a render target otherwise false.
  50801. */
  50802. hasRenderTargetTextures(): boolean;
  50803. /**
  50804. * Returns an array of the actively used textures.
  50805. * @param activeTextures Array of BaseTextures
  50806. */
  50807. getActiveTextures(activeTextures: BaseTexture[]): void;
  50808. /**
  50809. * Returns the animatable textures.
  50810. * @param animatables Array of animatable textures.
  50811. */
  50812. getAnimatables(animatables: IAnimatable[]): void;
  50813. /**
  50814. * Disposes the resources of the material.
  50815. * @param forceDisposeTextures - Forces the disposal of all textures.
  50816. */
  50817. dispose(forceDisposeTextures?: boolean): void;
  50818. /**
  50819. * Get the current class name of the texture useful for serialization or dynamic coding.
  50820. * @returns "PBRSubSurfaceConfiguration"
  50821. */
  50822. getClassName(): string;
  50823. /**
  50824. * Add fallbacks to the effect fallbacks list.
  50825. * @param defines defines the Base texture to use.
  50826. * @param fallbacks defines the current fallback list.
  50827. * @param currentRank defines the current fallback rank.
  50828. * @returns the new fallback rank.
  50829. */
  50830. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50831. /**
  50832. * Add the required uniforms to the current list.
  50833. * @param uniforms defines the current uniform list.
  50834. */
  50835. static AddUniforms(uniforms: string[]): void;
  50836. /**
  50837. * Add the required samplers to the current list.
  50838. * @param samplers defines the current sampler list.
  50839. */
  50840. static AddSamplers(samplers: string[]): void;
  50841. /**
  50842. * Add the required uniforms to the current buffer.
  50843. * @param uniformBuffer defines the current uniform buffer.
  50844. */
  50845. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50846. /**
  50847. * Makes a duplicate of the current configuration into another one.
  50848. * @param configuration define the config where to copy the info
  50849. */
  50850. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50851. /**
  50852. * Serializes this Sub Surface configuration.
  50853. * @returns - An object with the serialized config.
  50854. */
  50855. serialize(): any;
  50856. /**
  50857. * Parses a anisotropy Configuration from a serialized object.
  50858. * @param source - Serialized object.
  50859. * @param scene Defines the scene we are parsing for
  50860. * @param rootUrl Defines the rootUrl to load from
  50861. */
  50862. parse(source: any, scene: Scene, rootUrl: string): void;
  50863. }
  50864. }
  50865. declare module BABYLON {
  50866. /** @hidden */
  50867. export var pbrFragmentDeclaration: {
  50868. name: string;
  50869. shader: string;
  50870. };
  50871. }
  50872. declare module BABYLON {
  50873. /** @hidden */
  50874. export var pbrUboDeclaration: {
  50875. name: string;
  50876. shader: string;
  50877. };
  50878. }
  50879. declare module BABYLON {
  50880. /** @hidden */
  50881. export var pbrFragmentExtraDeclaration: {
  50882. name: string;
  50883. shader: string;
  50884. };
  50885. }
  50886. declare module BABYLON {
  50887. /** @hidden */
  50888. export var pbrFragmentSamplersDeclaration: {
  50889. name: string;
  50890. shader: string;
  50891. };
  50892. }
  50893. declare module BABYLON {
  50894. /** @hidden */
  50895. export var pbrHelperFunctions: {
  50896. name: string;
  50897. shader: string;
  50898. };
  50899. }
  50900. declare module BABYLON {
  50901. /** @hidden */
  50902. export var harmonicsFunctions: {
  50903. name: string;
  50904. shader: string;
  50905. };
  50906. }
  50907. declare module BABYLON {
  50908. /** @hidden */
  50909. export var pbrDirectLightingSetupFunctions: {
  50910. name: string;
  50911. shader: string;
  50912. };
  50913. }
  50914. declare module BABYLON {
  50915. /** @hidden */
  50916. export var pbrDirectLightingFalloffFunctions: {
  50917. name: string;
  50918. shader: string;
  50919. };
  50920. }
  50921. declare module BABYLON {
  50922. /** @hidden */
  50923. export var pbrBRDFFunctions: {
  50924. name: string;
  50925. shader: string;
  50926. };
  50927. }
  50928. declare module BABYLON {
  50929. /** @hidden */
  50930. export var pbrDirectLightingFunctions: {
  50931. name: string;
  50932. shader: string;
  50933. };
  50934. }
  50935. declare module BABYLON {
  50936. /** @hidden */
  50937. export var pbrIBLFunctions: {
  50938. name: string;
  50939. shader: string;
  50940. };
  50941. }
  50942. declare module BABYLON {
  50943. /** @hidden */
  50944. export var pbrDebug: {
  50945. name: string;
  50946. shader: string;
  50947. };
  50948. }
  50949. declare module BABYLON {
  50950. /** @hidden */
  50951. export var pbrPixelShader: {
  50952. name: string;
  50953. shader: string;
  50954. };
  50955. }
  50956. declare module BABYLON {
  50957. /** @hidden */
  50958. export var pbrVertexDeclaration: {
  50959. name: string;
  50960. shader: string;
  50961. };
  50962. }
  50963. declare module BABYLON {
  50964. /** @hidden */
  50965. export var pbrVertexShader: {
  50966. name: string;
  50967. shader: string;
  50968. };
  50969. }
  50970. declare module BABYLON {
  50971. /**
  50972. * Manages the defines for the PBR Material.
  50973. * @hidden
  50974. */
  50975. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50976. PBR: boolean;
  50977. MAINUV1: boolean;
  50978. MAINUV2: boolean;
  50979. UV1: boolean;
  50980. UV2: boolean;
  50981. ALBEDO: boolean;
  50982. GAMMAALBEDO: boolean;
  50983. ALBEDODIRECTUV: number;
  50984. VERTEXCOLOR: boolean;
  50985. AMBIENT: boolean;
  50986. AMBIENTDIRECTUV: number;
  50987. AMBIENTINGRAYSCALE: boolean;
  50988. OPACITY: boolean;
  50989. VERTEXALPHA: boolean;
  50990. OPACITYDIRECTUV: number;
  50991. OPACITYRGB: boolean;
  50992. ALPHATEST: boolean;
  50993. DEPTHPREPASS: boolean;
  50994. ALPHABLEND: boolean;
  50995. ALPHAFROMALBEDO: boolean;
  50996. ALPHATESTVALUE: string;
  50997. SPECULAROVERALPHA: boolean;
  50998. RADIANCEOVERALPHA: boolean;
  50999. ALPHAFRESNEL: boolean;
  51000. LINEARALPHAFRESNEL: boolean;
  51001. PREMULTIPLYALPHA: boolean;
  51002. EMISSIVE: boolean;
  51003. EMISSIVEDIRECTUV: number;
  51004. REFLECTIVITY: boolean;
  51005. REFLECTIVITYDIRECTUV: number;
  51006. SPECULARTERM: boolean;
  51007. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51008. MICROSURFACEAUTOMATIC: boolean;
  51009. LODBASEDMICROSFURACE: boolean;
  51010. MICROSURFACEMAP: boolean;
  51011. MICROSURFACEMAPDIRECTUV: number;
  51012. METALLICWORKFLOW: boolean;
  51013. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51014. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51015. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51016. AOSTOREINMETALMAPRED: boolean;
  51017. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51018. ENVIRONMENTBRDF: boolean;
  51019. ENVIRONMENTBRDF_RGBD: boolean;
  51020. NORMAL: boolean;
  51021. TANGENT: boolean;
  51022. BUMP: boolean;
  51023. BUMPDIRECTUV: number;
  51024. OBJECTSPACE_NORMALMAP: boolean;
  51025. PARALLAX: boolean;
  51026. PARALLAXOCCLUSION: boolean;
  51027. NORMALXYSCALE: boolean;
  51028. LIGHTMAP: boolean;
  51029. LIGHTMAPDIRECTUV: number;
  51030. USELIGHTMAPASSHADOWMAP: boolean;
  51031. GAMMALIGHTMAP: boolean;
  51032. RGBDLIGHTMAP: boolean;
  51033. REFLECTION: boolean;
  51034. REFLECTIONMAP_3D: boolean;
  51035. REFLECTIONMAP_SPHERICAL: boolean;
  51036. REFLECTIONMAP_PLANAR: boolean;
  51037. REFLECTIONMAP_CUBIC: boolean;
  51038. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51039. REFLECTIONMAP_PROJECTION: boolean;
  51040. REFLECTIONMAP_SKYBOX: boolean;
  51041. REFLECTIONMAP_EXPLICIT: boolean;
  51042. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51043. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51044. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51045. INVERTCUBICMAP: boolean;
  51046. USESPHERICALFROMREFLECTIONMAP: boolean;
  51047. USEIRRADIANCEMAP: boolean;
  51048. SPHERICAL_HARMONICS: boolean;
  51049. USESPHERICALINVERTEX: boolean;
  51050. REFLECTIONMAP_OPPOSITEZ: boolean;
  51051. LODINREFLECTIONALPHA: boolean;
  51052. GAMMAREFLECTION: boolean;
  51053. RGBDREFLECTION: boolean;
  51054. LINEARSPECULARREFLECTION: boolean;
  51055. RADIANCEOCCLUSION: boolean;
  51056. HORIZONOCCLUSION: boolean;
  51057. INSTANCES: boolean;
  51058. NUM_BONE_INFLUENCERS: number;
  51059. BonesPerMesh: number;
  51060. BONETEXTURE: boolean;
  51061. NONUNIFORMSCALING: boolean;
  51062. MORPHTARGETS: boolean;
  51063. MORPHTARGETS_NORMAL: boolean;
  51064. MORPHTARGETS_TANGENT: boolean;
  51065. MORPHTARGETS_UV: boolean;
  51066. NUM_MORPH_INFLUENCERS: number;
  51067. IMAGEPROCESSING: boolean;
  51068. VIGNETTE: boolean;
  51069. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51070. VIGNETTEBLENDMODEOPAQUE: boolean;
  51071. TONEMAPPING: boolean;
  51072. TONEMAPPING_ACES: boolean;
  51073. CONTRAST: boolean;
  51074. COLORCURVES: boolean;
  51075. COLORGRADING: boolean;
  51076. COLORGRADING3D: boolean;
  51077. SAMPLER3DGREENDEPTH: boolean;
  51078. SAMPLER3DBGRMAP: boolean;
  51079. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51080. EXPOSURE: boolean;
  51081. MULTIVIEW: boolean;
  51082. USEPHYSICALLIGHTFALLOFF: boolean;
  51083. USEGLTFLIGHTFALLOFF: boolean;
  51084. TWOSIDEDLIGHTING: boolean;
  51085. SHADOWFLOAT: boolean;
  51086. CLIPPLANE: boolean;
  51087. CLIPPLANE2: boolean;
  51088. CLIPPLANE3: boolean;
  51089. CLIPPLANE4: boolean;
  51090. CLIPPLANE5: boolean;
  51091. CLIPPLANE6: boolean;
  51092. POINTSIZE: boolean;
  51093. FOG: boolean;
  51094. LOGARITHMICDEPTH: boolean;
  51095. FORCENORMALFORWARD: boolean;
  51096. SPECULARAA: boolean;
  51097. CLEARCOAT: boolean;
  51098. CLEARCOAT_DEFAULTIOR: boolean;
  51099. CLEARCOAT_TEXTURE: boolean;
  51100. CLEARCOAT_TEXTUREDIRECTUV: number;
  51101. CLEARCOAT_BUMP: boolean;
  51102. CLEARCOAT_BUMPDIRECTUV: number;
  51103. CLEARCOAT_TINT: boolean;
  51104. CLEARCOAT_TINT_TEXTURE: boolean;
  51105. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51106. ANISOTROPIC: boolean;
  51107. ANISOTROPIC_TEXTURE: boolean;
  51108. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51109. BRDF_V_HEIGHT_CORRELATED: boolean;
  51110. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51111. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51112. SHEEN: boolean;
  51113. SHEEN_TEXTURE: boolean;
  51114. SHEEN_TEXTUREDIRECTUV: number;
  51115. SHEEN_LINKWITHALBEDO: boolean;
  51116. SHEEN_ROUGHNESS: boolean;
  51117. SHEEN_ALBEDOSCALING: boolean;
  51118. SUBSURFACE: boolean;
  51119. SS_REFRACTION: boolean;
  51120. SS_TRANSLUCENCY: boolean;
  51121. SS_SCATERRING: boolean;
  51122. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51123. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51124. SS_REFRACTIONMAP_3D: boolean;
  51125. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51126. SS_LODINREFRACTIONALPHA: boolean;
  51127. SS_GAMMAREFRACTION: boolean;
  51128. SS_RGBDREFRACTION: boolean;
  51129. SS_LINEARSPECULARREFRACTION: boolean;
  51130. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51131. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51132. UNLIT: boolean;
  51133. DEBUGMODE: number;
  51134. /**
  51135. * Initializes the PBR Material defines.
  51136. */
  51137. constructor();
  51138. /**
  51139. * Resets the PBR Material defines.
  51140. */
  51141. reset(): void;
  51142. }
  51143. /**
  51144. * The Physically based material base class of BJS.
  51145. *
  51146. * This offers the main features of a standard PBR material.
  51147. * For more information, please refer to the documentation :
  51148. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51149. */
  51150. export abstract class PBRBaseMaterial extends PushMaterial {
  51151. /**
  51152. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51153. */
  51154. static readonly PBRMATERIAL_OPAQUE: number;
  51155. /**
  51156. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51157. */
  51158. static readonly PBRMATERIAL_ALPHATEST: number;
  51159. /**
  51160. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51161. */
  51162. static readonly PBRMATERIAL_ALPHABLEND: number;
  51163. /**
  51164. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51165. * They are also discarded below the alpha cutoff threshold to improve performances.
  51166. */
  51167. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51168. /**
  51169. * Defines the default value of how much AO map is occluding the analytical lights
  51170. * (point spot...).
  51171. */
  51172. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51173. /**
  51174. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51175. */
  51176. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51177. /**
  51178. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51179. * to enhance interoperability with other engines.
  51180. */
  51181. static readonly LIGHTFALLOFF_GLTF: number;
  51182. /**
  51183. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51184. * to enhance interoperability with other materials.
  51185. */
  51186. static readonly LIGHTFALLOFF_STANDARD: number;
  51187. /**
  51188. * Intensity of the direct lights e.g. the four lights available in your scene.
  51189. * This impacts both the direct diffuse and specular highlights.
  51190. */
  51191. protected _directIntensity: number;
  51192. /**
  51193. * Intensity of the emissive part of the material.
  51194. * This helps controlling the emissive effect without modifying the emissive color.
  51195. */
  51196. protected _emissiveIntensity: number;
  51197. /**
  51198. * Intensity of the environment e.g. how much the environment will light the object
  51199. * either through harmonics for rough material or through the refelction for shiny ones.
  51200. */
  51201. protected _environmentIntensity: number;
  51202. /**
  51203. * This is a special control allowing the reduction of the specular highlights coming from the
  51204. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51205. */
  51206. protected _specularIntensity: number;
  51207. /**
  51208. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51209. */
  51210. private _lightingInfos;
  51211. /**
  51212. * Debug Control allowing disabling the bump map on this material.
  51213. */
  51214. protected _disableBumpMap: boolean;
  51215. /**
  51216. * AKA Diffuse Texture in standard nomenclature.
  51217. */
  51218. protected _albedoTexture: Nullable<BaseTexture>;
  51219. /**
  51220. * AKA Occlusion Texture in other nomenclature.
  51221. */
  51222. protected _ambientTexture: Nullable<BaseTexture>;
  51223. /**
  51224. * AKA Occlusion Texture Intensity in other nomenclature.
  51225. */
  51226. protected _ambientTextureStrength: number;
  51227. /**
  51228. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51229. * 1 means it completely occludes it
  51230. * 0 mean it has no impact
  51231. */
  51232. protected _ambientTextureImpactOnAnalyticalLights: number;
  51233. /**
  51234. * Stores the alpha values in a texture.
  51235. */
  51236. protected _opacityTexture: Nullable<BaseTexture>;
  51237. /**
  51238. * Stores the reflection values in a texture.
  51239. */
  51240. protected _reflectionTexture: Nullable<BaseTexture>;
  51241. /**
  51242. * Stores the emissive values in a texture.
  51243. */
  51244. protected _emissiveTexture: Nullable<BaseTexture>;
  51245. /**
  51246. * AKA Specular texture in other nomenclature.
  51247. */
  51248. protected _reflectivityTexture: Nullable<BaseTexture>;
  51249. /**
  51250. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51251. */
  51252. protected _metallicTexture: Nullable<BaseTexture>;
  51253. /**
  51254. * Specifies the metallic scalar of the metallic/roughness workflow.
  51255. * Can also be used to scale the metalness values of the metallic texture.
  51256. */
  51257. protected _metallic: Nullable<number>;
  51258. /**
  51259. * Specifies the roughness scalar of the metallic/roughness workflow.
  51260. * Can also be used to scale the roughness values of the metallic texture.
  51261. */
  51262. protected _roughness: Nullable<number>;
  51263. /**
  51264. * Specifies the an F0 factor to help configuring the material F0.
  51265. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51266. * to 0.5 the previously hard coded value stays the same.
  51267. * Can also be used to scale the F0 values of the metallic texture.
  51268. */
  51269. protected _metallicF0Factor: number;
  51270. /**
  51271. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51272. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51273. * your expectation as it multiplies with the texture data.
  51274. */
  51275. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51276. /**
  51277. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51278. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51279. */
  51280. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51281. /**
  51282. * Stores surface normal data used to displace a mesh in a texture.
  51283. */
  51284. protected _bumpTexture: Nullable<BaseTexture>;
  51285. /**
  51286. * Stores the pre-calculated light information of a mesh in a texture.
  51287. */
  51288. protected _lightmapTexture: Nullable<BaseTexture>;
  51289. /**
  51290. * The color of a material in ambient lighting.
  51291. */
  51292. protected _ambientColor: Color3;
  51293. /**
  51294. * AKA Diffuse Color in other nomenclature.
  51295. */
  51296. protected _albedoColor: Color3;
  51297. /**
  51298. * AKA Specular Color in other nomenclature.
  51299. */
  51300. protected _reflectivityColor: Color3;
  51301. /**
  51302. * The color applied when light is reflected from a material.
  51303. */
  51304. protected _reflectionColor: Color3;
  51305. /**
  51306. * The color applied when light is emitted from a material.
  51307. */
  51308. protected _emissiveColor: Color3;
  51309. /**
  51310. * AKA Glossiness in other nomenclature.
  51311. */
  51312. protected _microSurface: number;
  51313. /**
  51314. * Specifies that the material will use the light map as a show map.
  51315. */
  51316. protected _useLightmapAsShadowmap: boolean;
  51317. /**
  51318. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51319. * makes the reflect vector face the model (under horizon).
  51320. */
  51321. protected _useHorizonOcclusion: boolean;
  51322. /**
  51323. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51324. * too much the area relying on ambient texture to define their ambient occlusion.
  51325. */
  51326. protected _useRadianceOcclusion: boolean;
  51327. /**
  51328. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51329. */
  51330. protected _useAlphaFromAlbedoTexture: boolean;
  51331. /**
  51332. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51333. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51334. */
  51335. protected _useSpecularOverAlpha: boolean;
  51336. /**
  51337. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51338. */
  51339. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51340. /**
  51341. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51342. */
  51343. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51344. /**
  51345. * Specifies if the metallic texture contains the roughness information in its green channel.
  51346. */
  51347. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51348. /**
  51349. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51350. */
  51351. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51352. /**
  51353. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51354. */
  51355. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51356. /**
  51357. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51358. */
  51359. protected _useAmbientInGrayScale: boolean;
  51360. /**
  51361. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51362. * The material will try to infer what glossiness each pixel should be.
  51363. */
  51364. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51365. /**
  51366. * Defines the falloff type used in this material.
  51367. * It by default is Physical.
  51368. */
  51369. protected _lightFalloff: number;
  51370. /**
  51371. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51372. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51373. */
  51374. protected _useRadianceOverAlpha: boolean;
  51375. /**
  51376. * Allows using an object space normal map (instead of tangent space).
  51377. */
  51378. protected _useObjectSpaceNormalMap: boolean;
  51379. /**
  51380. * Allows using the bump map in parallax mode.
  51381. */
  51382. protected _useParallax: boolean;
  51383. /**
  51384. * Allows using the bump map in parallax occlusion mode.
  51385. */
  51386. protected _useParallaxOcclusion: boolean;
  51387. /**
  51388. * Controls the scale bias of the parallax mode.
  51389. */
  51390. protected _parallaxScaleBias: number;
  51391. /**
  51392. * If sets to true, disables all the lights affecting the material.
  51393. */
  51394. protected _disableLighting: boolean;
  51395. /**
  51396. * Number of Simultaneous lights allowed on the material.
  51397. */
  51398. protected _maxSimultaneousLights: number;
  51399. /**
  51400. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51401. */
  51402. protected _invertNormalMapX: boolean;
  51403. /**
  51404. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51405. */
  51406. protected _invertNormalMapY: boolean;
  51407. /**
  51408. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51409. */
  51410. protected _twoSidedLighting: boolean;
  51411. /**
  51412. * Defines the alpha limits in alpha test mode.
  51413. */
  51414. protected _alphaCutOff: number;
  51415. /**
  51416. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51417. */
  51418. protected _forceAlphaTest: boolean;
  51419. /**
  51420. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51421. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51422. */
  51423. protected _useAlphaFresnel: boolean;
  51424. /**
  51425. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51426. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51427. */
  51428. protected _useLinearAlphaFresnel: boolean;
  51429. /**
  51430. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51431. * from cos thetav and roughness:
  51432. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51433. */
  51434. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51435. /**
  51436. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51437. */
  51438. protected _forceIrradianceInFragment: boolean;
  51439. /**
  51440. * Force normal to face away from face.
  51441. */
  51442. protected _forceNormalForward: boolean;
  51443. /**
  51444. * Enables specular anti aliasing in the PBR shader.
  51445. * It will both interacts on the Geometry for analytical and IBL lighting.
  51446. * It also prefilter the roughness map based on the bump values.
  51447. */
  51448. protected _enableSpecularAntiAliasing: boolean;
  51449. /**
  51450. * Default configuration related to image processing available in the PBR Material.
  51451. */
  51452. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51453. /**
  51454. * Keep track of the image processing observer to allow dispose and replace.
  51455. */
  51456. private _imageProcessingObserver;
  51457. /**
  51458. * Attaches a new image processing configuration to the PBR Material.
  51459. * @param configuration
  51460. */
  51461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51462. /**
  51463. * Stores the available render targets.
  51464. */
  51465. private _renderTargets;
  51466. /**
  51467. * Sets the global ambient color for the material used in lighting calculations.
  51468. */
  51469. private _globalAmbientColor;
  51470. /**
  51471. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51472. */
  51473. private _useLogarithmicDepth;
  51474. /**
  51475. * If set to true, no lighting calculations will be applied.
  51476. */
  51477. private _unlit;
  51478. private _debugMode;
  51479. /**
  51480. * @hidden
  51481. * This is reserved for the inspector.
  51482. * Defines the material debug mode.
  51483. * It helps seeing only some components of the material while troubleshooting.
  51484. */
  51485. debugMode: number;
  51486. /**
  51487. * @hidden
  51488. * This is reserved for the inspector.
  51489. * Specify from where on screen the debug mode should start.
  51490. * The value goes from -1 (full screen) to 1 (not visible)
  51491. * It helps with side by side comparison against the final render
  51492. * This defaults to -1
  51493. */
  51494. private debugLimit;
  51495. /**
  51496. * @hidden
  51497. * This is reserved for the inspector.
  51498. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51499. * You can use the factor to better multiply the final value.
  51500. */
  51501. private debugFactor;
  51502. /**
  51503. * Defines the clear coat layer parameters for the material.
  51504. */
  51505. readonly clearCoat: PBRClearCoatConfiguration;
  51506. /**
  51507. * Defines the anisotropic parameters for the material.
  51508. */
  51509. readonly anisotropy: PBRAnisotropicConfiguration;
  51510. /**
  51511. * Defines the BRDF parameters for the material.
  51512. */
  51513. readonly brdf: PBRBRDFConfiguration;
  51514. /**
  51515. * Defines the Sheen parameters for the material.
  51516. */
  51517. readonly sheen: PBRSheenConfiguration;
  51518. /**
  51519. * Defines the SubSurface parameters for the material.
  51520. */
  51521. readonly subSurface: PBRSubSurfaceConfiguration;
  51522. /**
  51523. * Custom callback helping to override the default shader used in the material.
  51524. */
  51525. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51526. protected _rebuildInParallel: boolean;
  51527. /**
  51528. * Instantiates a new PBRMaterial instance.
  51529. *
  51530. * @param name The material name
  51531. * @param scene The scene the material will be use in.
  51532. */
  51533. constructor(name: string, scene: Scene);
  51534. /**
  51535. * Gets a boolean indicating that current material needs to register RTT
  51536. */
  51537. get hasRenderTargetTextures(): boolean;
  51538. /**
  51539. * Gets the name of the material class.
  51540. */
  51541. getClassName(): string;
  51542. /**
  51543. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51544. */
  51545. get useLogarithmicDepth(): boolean;
  51546. /**
  51547. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51548. */
  51549. set useLogarithmicDepth(value: boolean);
  51550. /**
  51551. * Returns true if alpha blending should be disabled.
  51552. */
  51553. protected get _disableAlphaBlending(): boolean;
  51554. /**
  51555. * Specifies whether or not this material should be rendered in alpha blend mode.
  51556. */
  51557. needAlphaBlending(): boolean;
  51558. /**
  51559. * Specifies whether or not this material should be rendered in alpha test mode.
  51560. */
  51561. needAlphaTesting(): boolean;
  51562. /**
  51563. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51564. */
  51565. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51566. /**
  51567. * Gets the texture used for the alpha test.
  51568. */
  51569. getAlphaTestTexture(): Nullable<BaseTexture>;
  51570. /**
  51571. * Specifies that the submesh is ready to be used.
  51572. * @param mesh - BJS mesh.
  51573. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51574. * @param useInstances - Specifies that instances should be used.
  51575. * @returns - boolean indicating that the submesh is ready or not.
  51576. */
  51577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51578. /**
  51579. * Specifies if the material uses metallic roughness workflow.
  51580. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51581. */
  51582. isMetallicWorkflow(): boolean;
  51583. private _prepareEffect;
  51584. private _prepareDefines;
  51585. /**
  51586. * Force shader compilation
  51587. */
  51588. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51589. /**
  51590. * Initializes the uniform buffer layout for the shader.
  51591. */
  51592. buildUniformLayout(): void;
  51593. /**
  51594. * Unbinds the material from the mesh
  51595. */
  51596. unbind(): void;
  51597. /**
  51598. * Binds the submesh data.
  51599. * @param world - The world matrix.
  51600. * @param mesh - The BJS mesh.
  51601. * @param subMesh - A submesh of the BJS mesh.
  51602. */
  51603. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51604. /**
  51605. * Returns the animatable textures.
  51606. * @returns - Array of animatable textures.
  51607. */
  51608. getAnimatables(): IAnimatable[];
  51609. /**
  51610. * Returns the texture used for reflections.
  51611. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51612. */
  51613. private _getReflectionTexture;
  51614. /**
  51615. * Returns an array of the actively used textures.
  51616. * @returns - Array of BaseTextures
  51617. */
  51618. getActiveTextures(): BaseTexture[];
  51619. /**
  51620. * Checks to see if a texture is used in the material.
  51621. * @param texture - Base texture to use.
  51622. * @returns - Boolean specifying if a texture is used in the material.
  51623. */
  51624. hasTexture(texture: BaseTexture): boolean;
  51625. /**
  51626. * Disposes the resources of the material.
  51627. * @param forceDisposeEffect - Forces the disposal of effects.
  51628. * @param forceDisposeTextures - Forces the disposal of all textures.
  51629. */
  51630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51631. }
  51632. }
  51633. declare module BABYLON {
  51634. /**
  51635. * The Physically based material of BJS.
  51636. *
  51637. * This offers the main features of a standard PBR material.
  51638. * For more information, please refer to the documentation :
  51639. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51640. */
  51641. export class PBRMaterial extends PBRBaseMaterial {
  51642. /**
  51643. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51644. */
  51645. static readonly PBRMATERIAL_OPAQUE: number;
  51646. /**
  51647. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51648. */
  51649. static readonly PBRMATERIAL_ALPHATEST: number;
  51650. /**
  51651. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51652. */
  51653. static readonly PBRMATERIAL_ALPHABLEND: number;
  51654. /**
  51655. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51656. * They are also discarded below the alpha cutoff threshold to improve performances.
  51657. */
  51658. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51659. /**
  51660. * Defines the default value of how much AO map is occluding the analytical lights
  51661. * (point spot...).
  51662. */
  51663. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51664. /**
  51665. * Intensity of the direct lights e.g. the four lights available in your scene.
  51666. * This impacts both the direct diffuse and specular highlights.
  51667. */
  51668. directIntensity: number;
  51669. /**
  51670. * Intensity of the emissive part of the material.
  51671. * This helps controlling the emissive effect without modifying the emissive color.
  51672. */
  51673. emissiveIntensity: number;
  51674. /**
  51675. * Intensity of the environment e.g. how much the environment will light the object
  51676. * either through harmonics for rough material or through the refelction for shiny ones.
  51677. */
  51678. environmentIntensity: number;
  51679. /**
  51680. * This is a special control allowing the reduction of the specular highlights coming from the
  51681. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51682. */
  51683. specularIntensity: number;
  51684. /**
  51685. * Debug Control allowing disabling the bump map on this material.
  51686. */
  51687. disableBumpMap: boolean;
  51688. /**
  51689. * AKA Diffuse Texture in standard nomenclature.
  51690. */
  51691. albedoTexture: BaseTexture;
  51692. /**
  51693. * AKA Occlusion Texture in other nomenclature.
  51694. */
  51695. ambientTexture: BaseTexture;
  51696. /**
  51697. * AKA Occlusion Texture Intensity in other nomenclature.
  51698. */
  51699. ambientTextureStrength: number;
  51700. /**
  51701. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51702. * 1 means it completely occludes it
  51703. * 0 mean it has no impact
  51704. */
  51705. ambientTextureImpactOnAnalyticalLights: number;
  51706. /**
  51707. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51708. */
  51709. opacityTexture: BaseTexture;
  51710. /**
  51711. * Stores the reflection values in a texture.
  51712. */
  51713. reflectionTexture: Nullable<BaseTexture>;
  51714. /**
  51715. * Stores the emissive values in a texture.
  51716. */
  51717. emissiveTexture: BaseTexture;
  51718. /**
  51719. * AKA Specular texture in other nomenclature.
  51720. */
  51721. reflectivityTexture: BaseTexture;
  51722. /**
  51723. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51724. */
  51725. metallicTexture: BaseTexture;
  51726. /**
  51727. * Specifies the metallic scalar of the metallic/roughness workflow.
  51728. * Can also be used to scale the metalness values of the metallic texture.
  51729. */
  51730. metallic: Nullable<number>;
  51731. /**
  51732. * Specifies the roughness scalar of the metallic/roughness workflow.
  51733. * Can also be used to scale the roughness values of the metallic texture.
  51734. */
  51735. roughness: Nullable<number>;
  51736. /**
  51737. * Specifies the an F0 factor to help configuring the material F0.
  51738. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51739. * to 0.5 the previously hard coded value stays the same.
  51740. * Can also be used to scale the F0 values of the metallic texture.
  51741. */
  51742. metallicF0Factor: number;
  51743. /**
  51744. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51745. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51746. * your expectation as it multiplies with the texture data.
  51747. */
  51748. useMetallicF0FactorFromMetallicTexture: boolean;
  51749. /**
  51750. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51751. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51752. */
  51753. microSurfaceTexture: BaseTexture;
  51754. /**
  51755. * Stores surface normal data used to displace a mesh in a texture.
  51756. */
  51757. bumpTexture: BaseTexture;
  51758. /**
  51759. * Stores the pre-calculated light information of a mesh in a texture.
  51760. */
  51761. lightmapTexture: BaseTexture;
  51762. /**
  51763. * Stores the refracted light information in a texture.
  51764. */
  51765. get refractionTexture(): Nullable<BaseTexture>;
  51766. set refractionTexture(value: Nullable<BaseTexture>);
  51767. /**
  51768. * The color of a material in ambient lighting.
  51769. */
  51770. ambientColor: Color3;
  51771. /**
  51772. * AKA Diffuse Color in other nomenclature.
  51773. */
  51774. albedoColor: Color3;
  51775. /**
  51776. * AKA Specular Color in other nomenclature.
  51777. */
  51778. reflectivityColor: Color3;
  51779. /**
  51780. * The color reflected from the material.
  51781. */
  51782. reflectionColor: Color3;
  51783. /**
  51784. * The color emitted from the material.
  51785. */
  51786. emissiveColor: Color3;
  51787. /**
  51788. * AKA Glossiness in other nomenclature.
  51789. */
  51790. microSurface: number;
  51791. /**
  51792. * source material index of refraction (IOR)' / 'destination material IOR.
  51793. */
  51794. get indexOfRefraction(): number;
  51795. set indexOfRefraction(value: number);
  51796. /**
  51797. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51798. */
  51799. get invertRefractionY(): boolean;
  51800. set invertRefractionY(value: boolean);
  51801. /**
  51802. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51803. * Materials half opaque for instance using refraction could benefit from this control.
  51804. */
  51805. get linkRefractionWithTransparency(): boolean;
  51806. set linkRefractionWithTransparency(value: boolean);
  51807. /**
  51808. * If true, the light map contains occlusion information instead of lighting info.
  51809. */
  51810. useLightmapAsShadowmap: boolean;
  51811. /**
  51812. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51813. */
  51814. useAlphaFromAlbedoTexture: boolean;
  51815. /**
  51816. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51817. */
  51818. forceAlphaTest: boolean;
  51819. /**
  51820. * Defines the alpha limits in alpha test mode.
  51821. */
  51822. alphaCutOff: number;
  51823. /**
  51824. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51825. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51826. */
  51827. useSpecularOverAlpha: boolean;
  51828. /**
  51829. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51830. */
  51831. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51832. /**
  51833. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51834. */
  51835. useRoughnessFromMetallicTextureAlpha: boolean;
  51836. /**
  51837. * Specifies if the metallic texture contains the roughness information in its green channel.
  51838. */
  51839. useRoughnessFromMetallicTextureGreen: boolean;
  51840. /**
  51841. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51842. */
  51843. useMetallnessFromMetallicTextureBlue: boolean;
  51844. /**
  51845. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51846. */
  51847. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51848. /**
  51849. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51850. */
  51851. useAmbientInGrayScale: boolean;
  51852. /**
  51853. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51854. * The material will try to infer what glossiness each pixel should be.
  51855. */
  51856. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51857. /**
  51858. * BJS is using an harcoded light falloff based on a manually sets up range.
  51859. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51860. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51861. */
  51862. get usePhysicalLightFalloff(): boolean;
  51863. /**
  51864. * BJS is using an harcoded light falloff based on a manually sets up range.
  51865. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51866. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51867. */
  51868. set usePhysicalLightFalloff(value: boolean);
  51869. /**
  51870. * In order to support the falloff compatibility with gltf, a special mode has been added
  51871. * to reproduce the gltf light falloff.
  51872. */
  51873. get useGLTFLightFalloff(): boolean;
  51874. /**
  51875. * In order to support the falloff compatibility with gltf, a special mode has been added
  51876. * to reproduce the gltf light falloff.
  51877. */
  51878. set useGLTFLightFalloff(value: boolean);
  51879. /**
  51880. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51881. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51882. */
  51883. useRadianceOverAlpha: boolean;
  51884. /**
  51885. * Allows using an object space normal map (instead of tangent space).
  51886. */
  51887. useObjectSpaceNormalMap: boolean;
  51888. /**
  51889. * Allows using the bump map in parallax mode.
  51890. */
  51891. useParallax: boolean;
  51892. /**
  51893. * Allows using the bump map in parallax occlusion mode.
  51894. */
  51895. useParallaxOcclusion: boolean;
  51896. /**
  51897. * Controls the scale bias of the parallax mode.
  51898. */
  51899. parallaxScaleBias: number;
  51900. /**
  51901. * If sets to true, disables all the lights affecting the material.
  51902. */
  51903. disableLighting: boolean;
  51904. /**
  51905. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51906. */
  51907. forceIrradianceInFragment: boolean;
  51908. /**
  51909. * Number of Simultaneous lights allowed on the material.
  51910. */
  51911. maxSimultaneousLights: number;
  51912. /**
  51913. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51914. */
  51915. invertNormalMapX: boolean;
  51916. /**
  51917. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51918. */
  51919. invertNormalMapY: boolean;
  51920. /**
  51921. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51922. */
  51923. twoSidedLighting: boolean;
  51924. /**
  51925. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51926. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51927. */
  51928. useAlphaFresnel: boolean;
  51929. /**
  51930. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51931. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51932. */
  51933. useLinearAlphaFresnel: boolean;
  51934. /**
  51935. * Let user defines the brdf lookup texture used for IBL.
  51936. * A default 8bit version is embedded but you could point at :
  51937. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51938. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51939. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51940. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51941. */
  51942. environmentBRDFTexture: Nullable<BaseTexture>;
  51943. /**
  51944. * Force normal to face away from face.
  51945. */
  51946. forceNormalForward: boolean;
  51947. /**
  51948. * Enables specular anti aliasing in the PBR shader.
  51949. * It will both interacts on the Geometry for analytical and IBL lighting.
  51950. * It also prefilter the roughness map based on the bump values.
  51951. */
  51952. enableSpecularAntiAliasing: boolean;
  51953. /**
  51954. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51955. * makes the reflect vector face the model (under horizon).
  51956. */
  51957. useHorizonOcclusion: boolean;
  51958. /**
  51959. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51960. * too much the area relying on ambient texture to define their ambient occlusion.
  51961. */
  51962. useRadianceOcclusion: boolean;
  51963. /**
  51964. * If set to true, no lighting calculations will be applied.
  51965. */
  51966. unlit: boolean;
  51967. /**
  51968. * Gets the image processing configuration used either in this material.
  51969. */
  51970. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51971. /**
  51972. * Sets the Default image processing configuration used either in the this material.
  51973. *
  51974. * If sets to null, the scene one is in use.
  51975. */
  51976. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51977. /**
  51978. * Gets wether the color curves effect is enabled.
  51979. */
  51980. get cameraColorCurvesEnabled(): boolean;
  51981. /**
  51982. * Sets wether the color curves effect is enabled.
  51983. */
  51984. set cameraColorCurvesEnabled(value: boolean);
  51985. /**
  51986. * Gets wether the color grading effect is enabled.
  51987. */
  51988. get cameraColorGradingEnabled(): boolean;
  51989. /**
  51990. * Gets wether the color grading effect is enabled.
  51991. */
  51992. set cameraColorGradingEnabled(value: boolean);
  51993. /**
  51994. * Gets wether tonemapping is enabled or not.
  51995. */
  51996. get cameraToneMappingEnabled(): boolean;
  51997. /**
  51998. * Sets wether tonemapping is enabled or not
  51999. */
  52000. set cameraToneMappingEnabled(value: boolean);
  52001. /**
  52002. * The camera exposure used on this material.
  52003. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52004. * This corresponds to a photographic exposure.
  52005. */
  52006. get cameraExposure(): number;
  52007. /**
  52008. * The camera exposure used on this material.
  52009. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52010. * This corresponds to a photographic exposure.
  52011. */
  52012. set cameraExposure(value: number);
  52013. /**
  52014. * Gets The camera contrast used on this material.
  52015. */
  52016. get cameraContrast(): number;
  52017. /**
  52018. * Sets The camera contrast used on this material.
  52019. */
  52020. set cameraContrast(value: number);
  52021. /**
  52022. * Gets the Color Grading 2D Lookup Texture.
  52023. */
  52024. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52025. /**
  52026. * Sets the Color Grading 2D Lookup Texture.
  52027. */
  52028. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52029. /**
  52030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52032. * 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;
  52033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52034. */
  52035. get cameraColorCurves(): Nullable<ColorCurves>;
  52036. /**
  52037. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52038. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52039. * 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;
  52040. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52041. */
  52042. set cameraColorCurves(value: Nullable<ColorCurves>);
  52043. /**
  52044. * Instantiates a new PBRMaterial instance.
  52045. *
  52046. * @param name The material name
  52047. * @param scene The scene the material will be use in.
  52048. */
  52049. constructor(name: string, scene: Scene);
  52050. /**
  52051. * Returns the name of this material class.
  52052. */
  52053. getClassName(): string;
  52054. /**
  52055. * Makes a duplicate of the current material.
  52056. * @param name - name to use for the new material.
  52057. */
  52058. clone(name: string): PBRMaterial;
  52059. /**
  52060. * Serializes this PBR Material.
  52061. * @returns - An object with the serialized material.
  52062. */
  52063. serialize(): any;
  52064. /**
  52065. * Parses a PBR Material from a serialized object.
  52066. * @param source - Serialized object.
  52067. * @param scene - BJS scene instance.
  52068. * @param rootUrl - url for the scene object
  52069. * @returns - PBRMaterial
  52070. */
  52071. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52072. }
  52073. }
  52074. declare module BABYLON {
  52075. /**
  52076. * Direct draw surface info
  52077. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52078. */
  52079. export interface DDSInfo {
  52080. /**
  52081. * Width of the texture
  52082. */
  52083. width: number;
  52084. /**
  52085. * Width of the texture
  52086. */
  52087. height: number;
  52088. /**
  52089. * Number of Mipmaps for the texture
  52090. * @see https://en.wikipedia.org/wiki/Mipmap
  52091. */
  52092. mipmapCount: number;
  52093. /**
  52094. * If the textures format is a known fourCC format
  52095. * @see https://www.fourcc.org/
  52096. */
  52097. isFourCC: boolean;
  52098. /**
  52099. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52100. */
  52101. isRGB: boolean;
  52102. /**
  52103. * If the texture is a lumincance format
  52104. */
  52105. isLuminance: boolean;
  52106. /**
  52107. * If this is a cube texture
  52108. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52109. */
  52110. isCube: boolean;
  52111. /**
  52112. * If the texture is a compressed format eg. FOURCC_DXT1
  52113. */
  52114. isCompressed: boolean;
  52115. /**
  52116. * The dxgiFormat of the texture
  52117. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52118. */
  52119. dxgiFormat: number;
  52120. /**
  52121. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52122. */
  52123. textureType: number;
  52124. /**
  52125. * Sphericle polynomial created for the dds texture
  52126. */
  52127. sphericalPolynomial?: SphericalPolynomial;
  52128. }
  52129. /**
  52130. * Class used to provide DDS decompression tools
  52131. */
  52132. export class DDSTools {
  52133. /**
  52134. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52135. */
  52136. static StoreLODInAlphaChannel: boolean;
  52137. /**
  52138. * Gets DDS information from an array buffer
  52139. * @param data defines the array buffer view to read data from
  52140. * @returns the DDS information
  52141. */
  52142. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52143. private static _FloatView;
  52144. private static _Int32View;
  52145. private static _ToHalfFloat;
  52146. private static _FromHalfFloat;
  52147. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52148. private static _GetHalfFloatRGBAArrayBuffer;
  52149. private static _GetFloatRGBAArrayBuffer;
  52150. private static _GetFloatAsUIntRGBAArrayBuffer;
  52151. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52152. private static _GetRGBAArrayBuffer;
  52153. private static _ExtractLongWordOrder;
  52154. private static _GetRGBArrayBuffer;
  52155. private static _GetLuminanceArrayBuffer;
  52156. /**
  52157. * Uploads DDS Levels to a Babylon Texture
  52158. * @hidden
  52159. */
  52160. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52161. }
  52162. interface ThinEngine {
  52163. /**
  52164. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52165. * @param rootUrl defines the url where the file to load is located
  52166. * @param scene defines the current scene
  52167. * @param lodScale defines scale to apply to the mip map selection
  52168. * @param lodOffset defines offset to apply to the mip map selection
  52169. * @param onLoad defines an optional callback raised when the texture is loaded
  52170. * @param onError defines an optional callback raised if there is an issue to load the texture
  52171. * @param format defines the format of the data
  52172. * @param forcedExtension defines the extension to use to pick the right loader
  52173. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52174. * @returns the cube texture as an InternalTexture
  52175. */
  52176. 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;
  52177. }
  52178. }
  52179. declare module BABYLON {
  52180. /**
  52181. * Implementation of the DDS Texture Loader.
  52182. * @hidden
  52183. */
  52184. export class _DDSTextureLoader implements IInternalTextureLoader {
  52185. /**
  52186. * Defines wether the loader supports cascade loading the different faces.
  52187. */
  52188. readonly supportCascades: boolean;
  52189. /**
  52190. * This returns if the loader support the current file information.
  52191. * @param extension defines the file extension of the file being loaded
  52192. * @returns true if the loader can load the specified file
  52193. */
  52194. canLoad(extension: string): boolean;
  52195. /**
  52196. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52197. * @param data contains the texture data
  52198. * @param texture defines the BabylonJS internal texture
  52199. * @param createPolynomials will be true if polynomials have been requested
  52200. * @param onLoad defines the callback to trigger once the texture is ready
  52201. * @param onError defines the callback to trigger in case of error
  52202. */
  52203. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52204. /**
  52205. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52206. * @param data contains the texture data
  52207. * @param texture defines the BabylonJS internal texture
  52208. * @param callback defines the method to call once ready to upload
  52209. */
  52210. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52211. }
  52212. }
  52213. declare module BABYLON {
  52214. /**
  52215. * Implementation of the ENV Texture Loader.
  52216. * @hidden
  52217. */
  52218. export class _ENVTextureLoader implements IInternalTextureLoader {
  52219. /**
  52220. * Defines wether the loader supports cascade loading the different faces.
  52221. */
  52222. readonly supportCascades: boolean;
  52223. /**
  52224. * This returns if the loader support the current file information.
  52225. * @param extension defines the file extension of the file being loaded
  52226. * @returns true if the loader can load the specified file
  52227. */
  52228. canLoad(extension: string): boolean;
  52229. /**
  52230. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52231. * @param data contains the texture data
  52232. * @param texture defines the BabylonJS internal texture
  52233. * @param createPolynomials will be true if polynomials have been requested
  52234. * @param onLoad defines the callback to trigger once the texture is ready
  52235. * @param onError defines the callback to trigger in case of error
  52236. */
  52237. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52238. /**
  52239. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52240. * @param data contains the texture data
  52241. * @param texture defines the BabylonJS internal texture
  52242. * @param callback defines the method to call once ready to upload
  52243. */
  52244. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52245. }
  52246. }
  52247. declare module BABYLON {
  52248. /**
  52249. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52250. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52251. */
  52252. export class KhronosTextureContainer {
  52253. /** contents of the KTX container file */
  52254. data: ArrayBufferView;
  52255. private static HEADER_LEN;
  52256. private static COMPRESSED_2D;
  52257. private static COMPRESSED_3D;
  52258. private static TEX_2D;
  52259. private static TEX_3D;
  52260. /**
  52261. * Gets the openGL type
  52262. */
  52263. glType: number;
  52264. /**
  52265. * Gets the openGL type size
  52266. */
  52267. glTypeSize: number;
  52268. /**
  52269. * Gets the openGL format
  52270. */
  52271. glFormat: number;
  52272. /**
  52273. * Gets the openGL internal format
  52274. */
  52275. glInternalFormat: number;
  52276. /**
  52277. * Gets the base internal format
  52278. */
  52279. glBaseInternalFormat: number;
  52280. /**
  52281. * Gets image width in pixel
  52282. */
  52283. pixelWidth: number;
  52284. /**
  52285. * Gets image height in pixel
  52286. */
  52287. pixelHeight: number;
  52288. /**
  52289. * Gets image depth in pixels
  52290. */
  52291. pixelDepth: number;
  52292. /**
  52293. * Gets the number of array elements
  52294. */
  52295. numberOfArrayElements: number;
  52296. /**
  52297. * Gets the number of faces
  52298. */
  52299. numberOfFaces: number;
  52300. /**
  52301. * Gets the number of mipmap levels
  52302. */
  52303. numberOfMipmapLevels: number;
  52304. /**
  52305. * Gets the bytes of key value data
  52306. */
  52307. bytesOfKeyValueData: number;
  52308. /**
  52309. * Gets the load type
  52310. */
  52311. loadType: number;
  52312. /**
  52313. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52314. */
  52315. isInvalid: boolean;
  52316. /**
  52317. * Creates a new KhronosTextureContainer
  52318. * @param data contents of the KTX container file
  52319. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52320. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52321. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52322. */
  52323. constructor(
  52324. /** contents of the KTX container file */
  52325. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52326. /**
  52327. * Uploads KTX content to a Babylon Texture.
  52328. * It is assumed that the texture has already been created & is currently bound
  52329. * @hidden
  52330. */
  52331. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52332. private _upload2DCompressedLevels;
  52333. /**
  52334. * Checks if the given data starts with a KTX file identifier.
  52335. * @param data the data to check
  52336. * @returns true if the data is a KTX file or false otherwise
  52337. */
  52338. static IsValid(data: ArrayBufferView): boolean;
  52339. }
  52340. }
  52341. declare module BABYLON {
  52342. /**
  52343. * Class for loading KTX2 files
  52344. * !!! Experimental Extension Subject to Changes !!!
  52345. * @hidden
  52346. */
  52347. export class KhronosTextureContainer2 {
  52348. private static _ModulePromise;
  52349. private static _TranscodeFormat;
  52350. constructor(engine: ThinEngine);
  52351. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52352. private _determineTranscodeFormat;
  52353. /**
  52354. * Checks if the given data starts with a KTX2 file identifier.
  52355. * @param data the data to check
  52356. * @returns true if the data is a KTX2 file or false otherwise
  52357. */
  52358. static IsValid(data: ArrayBufferView): boolean;
  52359. }
  52360. }
  52361. declare module BABYLON {
  52362. /**
  52363. * Implementation of the KTX Texture Loader.
  52364. * @hidden
  52365. */
  52366. export class _KTXTextureLoader implements IInternalTextureLoader {
  52367. /**
  52368. * Defines wether the loader supports cascade loading the different faces.
  52369. */
  52370. readonly supportCascades: boolean;
  52371. /**
  52372. * This returns if the loader support the current file information.
  52373. * @param extension defines the file extension of the file being loaded
  52374. * @returns true if the loader can load the specified file
  52375. */
  52376. canLoad(extension: string): boolean;
  52377. /**
  52378. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52379. * @param data contains the texture data
  52380. * @param texture defines the BabylonJS internal texture
  52381. * @param createPolynomials will be true if polynomials have been requested
  52382. * @param onLoad defines the callback to trigger once the texture is ready
  52383. * @param onError defines the callback to trigger in case of error
  52384. */
  52385. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52386. /**
  52387. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52388. * @param data contains the texture data
  52389. * @param texture defines the BabylonJS internal texture
  52390. * @param callback defines the method to call once ready to upload
  52391. */
  52392. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52393. }
  52394. }
  52395. declare module BABYLON {
  52396. /** @hidden */
  52397. export var _forceSceneHelpersToBundle: boolean;
  52398. interface Scene {
  52399. /**
  52400. * Creates a default light for the scene.
  52401. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52402. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52403. */
  52404. createDefaultLight(replace?: boolean): void;
  52405. /**
  52406. * Creates a default camera for the scene.
  52407. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52408. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52409. * @param replace has default false, when true replaces the active camera in the scene
  52410. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52411. */
  52412. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52413. /**
  52414. * Creates a default camera and a default light.
  52415. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52416. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52417. * @param replace has the default false, when true replaces the active camera/light in the scene
  52418. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52419. */
  52420. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52421. /**
  52422. * Creates a new sky box
  52423. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52424. * @param environmentTexture defines the texture to use as environment texture
  52425. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52426. * @param scale defines the overall scale of the skybox
  52427. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52428. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52429. * @returns a new mesh holding the sky box
  52430. */
  52431. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52432. /**
  52433. * Creates a new environment
  52434. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52435. * @param options defines the options you can use to configure the environment
  52436. * @returns the new EnvironmentHelper
  52437. */
  52438. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52439. /**
  52440. * Creates a new VREXperienceHelper
  52441. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52442. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52443. * @returns a new VREXperienceHelper
  52444. */
  52445. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52446. /**
  52447. * Creates a new WebXRDefaultExperience
  52448. * @see http://doc.babylonjs.com/how_to/webxr
  52449. * @param options experience options
  52450. * @returns a promise for a new WebXRDefaultExperience
  52451. */
  52452. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52453. }
  52454. }
  52455. declare module BABYLON {
  52456. /**
  52457. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52458. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52459. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52460. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52461. */
  52462. export class VideoDome extends TransformNode {
  52463. /**
  52464. * Define the video source as a Monoscopic panoramic 360 video.
  52465. */
  52466. static readonly MODE_MONOSCOPIC: number;
  52467. /**
  52468. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52469. */
  52470. static readonly MODE_TOPBOTTOM: number;
  52471. /**
  52472. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52473. */
  52474. static readonly MODE_SIDEBYSIDE: number;
  52475. private _halfDome;
  52476. private _useDirectMapping;
  52477. /**
  52478. * The video texture being displayed on the sphere
  52479. */
  52480. protected _videoTexture: VideoTexture;
  52481. /**
  52482. * Gets the video texture being displayed on the sphere
  52483. */
  52484. get videoTexture(): VideoTexture;
  52485. /**
  52486. * The skybox material
  52487. */
  52488. protected _material: BackgroundMaterial;
  52489. /**
  52490. * The surface used for the skybox
  52491. */
  52492. protected _mesh: Mesh;
  52493. /**
  52494. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52495. */
  52496. private _halfDomeMask;
  52497. /**
  52498. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52499. * Also see the options.resolution property.
  52500. */
  52501. get fovMultiplier(): number;
  52502. set fovMultiplier(value: number);
  52503. private _videoMode;
  52504. /**
  52505. * Gets or set the current video mode for the video. It can be:
  52506. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52507. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52508. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52509. */
  52510. get videoMode(): number;
  52511. set videoMode(value: number);
  52512. /**
  52513. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52514. *
  52515. */
  52516. get halfDome(): boolean;
  52517. /**
  52518. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52519. */
  52520. set halfDome(enabled: boolean);
  52521. /**
  52522. * Oberserver used in Stereoscopic VR Mode.
  52523. */
  52524. private _onBeforeCameraRenderObserver;
  52525. /**
  52526. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52527. * @param name Element's name, child elements will append suffixes for their own names.
  52528. * @param urlsOrVideo defines the url(s) or the video element to use
  52529. * @param options An object containing optional or exposed sub element properties
  52530. */
  52531. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52532. resolution?: number;
  52533. clickToPlay?: boolean;
  52534. autoPlay?: boolean;
  52535. loop?: boolean;
  52536. size?: number;
  52537. poster?: string;
  52538. faceForward?: boolean;
  52539. useDirectMapping?: boolean;
  52540. halfDomeMode?: boolean;
  52541. }, scene: Scene);
  52542. private _changeVideoMode;
  52543. /**
  52544. * Releases resources associated with this node.
  52545. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52546. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52547. */
  52548. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52549. }
  52550. }
  52551. declare module BABYLON {
  52552. /**
  52553. * This class can be used to get instrumentation data from a Babylon engine
  52554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52555. */
  52556. export class EngineInstrumentation implements IDisposable {
  52557. /**
  52558. * Define the instrumented engine.
  52559. */
  52560. engine: Engine;
  52561. private _captureGPUFrameTime;
  52562. private _gpuFrameTimeToken;
  52563. private _gpuFrameTime;
  52564. private _captureShaderCompilationTime;
  52565. private _shaderCompilationTime;
  52566. private _onBeginFrameObserver;
  52567. private _onEndFrameObserver;
  52568. private _onBeforeShaderCompilationObserver;
  52569. private _onAfterShaderCompilationObserver;
  52570. /**
  52571. * Gets the perf counter used for GPU frame time
  52572. */
  52573. get gpuFrameTimeCounter(): PerfCounter;
  52574. /**
  52575. * Gets the GPU frame time capture status
  52576. */
  52577. get captureGPUFrameTime(): boolean;
  52578. /**
  52579. * Enable or disable the GPU frame time capture
  52580. */
  52581. set captureGPUFrameTime(value: boolean);
  52582. /**
  52583. * Gets the perf counter used for shader compilation time
  52584. */
  52585. get shaderCompilationTimeCounter(): PerfCounter;
  52586. /**
  52587. * Gets the shader compilation time capture status
  52588. */
  52589. get captureShaderCompilationTime(): boolean;
  52590. /**
  52591. * Enable or disable the shader compilation time capture
  52592. */
  52593. set captureShaderCompilationTime(value: boolean);
  52594. /**
  52595. * Instantiates a new engine instrumentation.
  52596. * This class can be used to get instrumentation data from a Babylon engine
  52597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52598. * @param engine Defines the engine to instrument
  52599. */
  52600. constructor(
  52601. /**
  52602. * Define the instrumented engine.
  52603. */
  52604. engine: Engine);
  52605. /**
  52606. * Dispose and release associated resources.
  52607. */
  52608. dispose(): void;
  52609. }
  52610. }
  52611. declare module BABYLON {
  52612. /**
  52613. * This class can be used to get instrumentation data from a Babylon engine
  52614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52615. */
  52616. export class SceneInstrumentation implements IDisposable {
  52617. /**
  52618. * Defines the scene to instrument
  52619. */
  52620. scene: Scene;
  52621. private _captureActiveMeshesEvaluationTime;
  52622. private _activeMeshesEvaluationTime;
  52623. private _captureRenderTargetsRenderTime;
  52624. private _renderTargetsRenderTime;
  52625. private _captureFrameTime;
  52626. private _frameTime;
  52627. private _captureRenderTime;
  52628. private _renderTime;
  52629. private _captureInterFrameTime;
  52630. private _interFrameTime;
  52631. private _captureParticlesRenderTime;
  52632. private _particlesRenderTime;
  52633. private _captureSpritesRenderTime;
  52634. private _spritesRenderTime;
  52635. private _capturePhysicsTime;
  52636. private _physicsTime;
  52637. private _captureAnimationsTime;
  52638. private _animationsTime;
  52639. private _captureCameraRenderTime;
  52640. private _cameraRenderTime;
  52641. private _onBeforeActiveMeshesEvaluationObserver;
  52642. private _onAfterActiveMeshesEvaluationObserver;
  52643. private _onBeforeRenderTargetsRenderObserver;
  52644. private _onAfterRenderTargetsRenderObserver;
  52645. private _onAfterRenderObserver;
  52646. private _onBeforeDrawPhaseObserver;
  52647. private _onAfterDrawPhaseObserver;
  52648. private _onBeforeAnimationsObserver;
  52649. private _onBeforeParticlesRenderingObserver;
  52650. private _onAfterParticlesRenderingObserver;
  52651. private _onBeforeSpritesRenderingObserver;
  52652. private _onAfterSpritesRenderingObserver;
  52653. private _onBeforePhysicsObserver;
  52654. private _onAfterPhysicsObserver;
  52655. private _onAfterAnimationsObserver;
  52656. private _onBeforeCameraRenderObserver;
  52657. private _onAfterCameraRenderObserver;
  52658. /**
  52659. * Gets the perf counter used for active meshes evaluation time
  52660. */
  52661. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52662. /**
  52663. * Gets the active meshes evaluation time capture status
  52664. */
  52665. get captureActiveMeshesEvaluationTime(): boolean;
  52666. /**
  52667. * Enable or disable the active meshes evaluation time capture
  52668. */
  52669. set captureActiveMeshesEvaluationTime(value: boolean);
  52670. /**
  52671. * Gets the perf counter used for render targets render time
  52672. */
  52673. get renderTargetsRenderTimeCounter(): PerfCounter;
  52674. /**
  52675. * Gets the render targets render time capture status
  52676. */
  52677. get captureRenderTargetsRenderTime(): boolean;
  52678. /**
  52679. * Enable or disable the render targets render time capture
  52680. */
  52681. set captureRenderTargetsRenderTime(value: boolean);
  52682. /**
  52683. * Gets the perf counter used for particles render time
  52684. */
  52685. get particlesRenderTimeCounter(): PerfCounter;
  52686. /**
  52687. * Gets the particles render time capture status
  52688. */
  52689. get captureParticlesRenderTime(): boolean;
  52690. /**
  52691. * Enable or disable the particles render time capture
  52692. */
  52693. set captureParticlesRenderTime(value: boolean);
  52694. /**
  52695. * Gets the perf counter used for sprites render time
  52696. */
  52697. get spritesRenderTimeCounter(): PerfCounter;
  52698. /**
  52699. * Gets the sprites render time capture status
  52700. */
  52701. get captureSpritesRenderTime(): boolean;
  52702. /**
  52703. * Enable or disable the sprites render time capture
  52704. */
  52705. set captureSpritesRenderTime(value: boolean);
  52706. /**
  52707. * Gets the perf counter used for physics time
  52708. */
  52709. get physicsTimeCounter(): PerfCounter;
  52710. /**
  52711. * Gets the physics time capture status
  52712. */
  52713. get capturePhysicsTime(): boolean;
  52714. /**
  52715. * Enable or disable the physics time capture
  52716. */
  52717. set capturePhysicsTime(value: boolean);
  52718. /**
  52719. * Gets the perf counter used for animations time
  52720. */
  52721. get animationsTimeCounter(): PerfCounter;
  52722. /**
  52723. * Gets the animations time capture status
  52724. */
  52725. get captureAnimationsTime(): boolean;
  52726. /**
  52727. * Enable or disable the animations time capture
  52728. */
  52729. set captureAnimationsTime(value: boolean);
  52730. /**
  52731. * Gets the perf counter used for frame time capture
  52732. */
  52733. get frameTimeCounter(): PerfCounter;
  52734. /**
  52735. * Gets the frame time capture status
  52736. */
  52737. get captureFrameTime(): boolean;
  52738. /**
  52739. * Enable or disable the frame time capture
  52740. */
  52741. set captureFrameTime(value: boolean);
  52742. /**
  52743. * Gets the perf counter used for inter-frames time capture
  52744. */
  52745. get interFrameTimeCounter(): PerfCounter;
  52746. /**
  52747. * Gets the inter-frames time capture status
  52748. */
  52749. get captureInterFrameTime(): boolean;
  52750. /**
  52751. * Enable or disable the inter-frames time capture
  52752. */
  52753. set captureInterFrameTime(value: boolean);
  52754. /**
  52755. * Gets the perf counter used for render time capture
  52756. */
  52757. get renderTimeCounter(): PerfCounter;
  52758. /**
  52759. * Gets the render time capture status
  52760. */
  52761. get captureRenderTime(): boolean;
  52762. /**
  52763. * Enable or disable the render time capture
  52764. */
  52765. set captureRenderTime(value: boolean);
  52766. /**
  52767. * Gets the perf counter used for camera render time capture
  52768. */
  52769. get cameraRenderTimeCounter(): PerfCounter;
  52770. /**
  52771. * Gets the camera render time capture status
  52772. */
  52773. get captureCameraRenderTime(): boolean;
  52774. /**
  52775. * Enable or disable the camera render time capture
  52776. */
  52777. set captureCameraRenderTime(value: boolean);
  52778. /**
  52779. * Gets the perf counter used for draw calls
  52780. */
  52781. get drawCallsCounter(): PerfCounter;
  52782. /**
  52783. * Instantiates a new scene instrumentation.
  52784. * This class can be used to get instrumentation data from a Babylon engine
  52785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52786. * @param scene Defines the scene to instrument
  52787. */
  52788. constructor(
  52789. /**
  52790. * Defines the scene to instrument
  52791. */
  52792. scene: Scene);
  52793. /**
  52794. * Dispose and release associated resources.
  52795. */
  52796. dispose(): void;
  52797. }
  52798. }
  52799. declare module BABYLON {
  52800. /** @hidden */
  52801. export var glowMapGenerationPixelShader: {
  52802. name: string;
  52803. shader: string;
  52804. };
  52805. }
  52806. declare module BABYLON {
  52807. /** @hidden */
  52808. export var glowMapGenerationVertexShader: {
  52809. name: string;
  52810. shader: string;
  52811. };
  52812. }
  52813. declare module BABYLON {
  52814. /**
  52815. * Effect layer options. This helps customizing the behaviour
  52816. * of the effect layer.
  52817. */
  52818. export interface IEffectLayerOptions {
  52819. /**
  52820. * Multiplication factor apply to the canvas size to compute the render target size
  52821. * used to generated the objects (the smaller the faster).
  52822. */
  52823. mainTextureRatio: number;
  52824. /**
  52825. * Enforces a fixed size texture to ensure effect stability across devices.
  52826. */
  52827. mainTextureFixedSize?: number;
  52828. /**
  52829. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52830. */
  52831. alphaBlendingMode: number;
  52832. /**
  52833. * The camera attached to the layer.
  52834. */
  52835. camera: Nullable<Camera>;
  52836. /**
  52837. * The rendering group to draw the layer in.
  52838. */
  52839. renderingGroupId: number;
  52840. }
  52841. /**
  52842. * The effect layer Helps adding post process effect blended with the main pass.
  52843. *
  52844. * This can be for instance use to generate glow or higlight effects on the scene.
  52845. *
  52846. * The effect layer class can not be used directly and is intented to inherited from to be
  52847. * customized per effects.
  52848. */
  52849. export abstract class EffectLayer {
  52850. private _vertexBuffers;
  52851. private _indexBuffer;
  52852. private _cachedDefines;
  52853. private _effectLayerMapGenerationEffect;
  52854. private _effectLayerOptions;
  52855. private _mergeEffect;
  52856. protected _scene: Scene;
  52857. protected _engine: Engine;
  52858. protected _maxSize: number;
  52859. protected _mainTextureDesiredSize: ISize;
  52860. protected _mainTexture: RenderTargetTexture;
  52861. protected _shouldRender: boolean;
  52862. protected _postProcesses: PostProcess[];
  52863. protected _textures: BaseTexture[];
  52864. protected _emissiveTextureAndColor: {
  52865. texture: Nullable<BaseTexture>;
  52866. color: Color4;
  52867. };
  52868. /**
  52869. * The name of the layer
  52870. */
  52871. name: string;
  52872. /**
  52873. * The clear color of the texture used to generate the glow map.
  52874. */
  52875. neutralColor: Color4;
  52876. /**
  52877. * Specifies whether the highlight layer is enabled or not.
  52878. */
  52879. isEnabled: boolean;
  52880. /**
  52881. * Gets the camera attached to the layer.
  52882. */
  52883. get camera(): Nullable<Camera>;
  52884. /**
  52885. * Gets the rendering group id the layer should render in.
  52886. */
  52887. get renderingGroupId(): number;
  52888. set renderingGroupId(renderingGroupId: number);
  52889. /**
  52890. * An event triggered when the effect layer has been disposed.
  52891. */
  52892. onDisposeObservable: Observable<EffectLayer>;
  52893. /**
  52894. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52895. */
  52896. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52897. /**
  52898. * An event triggered when the generated texture is being merged in the scene.
  52899. */
  52900. onBeforeComposeObservable: Observable<EffectLayer>;
  52901. /**
  52902. * An event triggered when the mesh is rendered into the effect render target.
  52903. */
  52904. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52905. /**
  52906. * An event triggered after the mesh has been rendered into the effect render target.
  52907. */
  52908. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52909. /**
  52910. * An event triggered when the generated texture has been merged in the scene.
  52911. */
  52912. onAfterComposeObservable: Observable<EffectLayer>;
  52913. /**
  52914. * An event triggered when the efffect layer changes its size.
  52915. */
  52916. onSizeChangedObservable: Observable<EffectLayer>;
  52917. /** @hidden */
  52918. static _SceneComponentInitialization: (scene: Scene) => void;
  52919. /**
  52920. * Instantiates a new effect Layer and references it in the scene.
  52921. * @param name The name of the layer
  52922. * @param scene The scene to use the layer in
  52923. */
  52924. constructor(
  52925. /** The Friendly of the effect in the scene */
  52926. name: string, scene: Scene);
  52927. /**
  52928. * Get the effect name of the layer.
  52929. * @return The effect name
  52930. */
  52931. abstract getEffectName(): string;
  52932. /**
  52933. * Checks for the readiness of the element composing the layer.
  52934. * @param subMesh the mesh to check for
  52935. * @param useInstances specify whether or not to use instances to render the mesh
  52936. * @return true if ready otherwise, false
  52937. */
  52938. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52939. /**
  52940. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52941. * @returns true if the effect requires stencil during the main canvas render pass.
  52942. */
  52943. abstract needStencil(): boolean;
  52944. /**
  52945. * Create the merge effect. This is the shader use to blit the information back
  52946. * to the main canvas at the end of the scene rendering.
  52947. * @returns The effect containing the shader used to merge the effect on the main canvas
  52948. */
  52949. protected abstract _createMergeEffect(): Effect;
  52950. /**
  52951. * Creates the render target textures and post processes used in the effect layer.
  52952. */
  52953. protected abstract _createTextureAndPostProcesses(): void;
  52954. /**
  52955. * Implementation specific of rendering the generating effect on the main canvas.
  52956. * @param effect The effect used to render through
  52957. */
  52958. protected abstract _internalRender(effect: Effect): void;
  52959. /**
  52960. * Sets the required values for both the emissive texture and and the main color.
  52961. */
  52962. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52963. /**
  52964. * Free any resources and references associated to a mesh.
  52965. * Internal use
  52966. * @param mesh The mesh to free.
  52967. */
  52968. abstract _disposeMesh(mesh: Mesh): void;
  52969. /**
  52970. * Serializes this layer (Glow or Highlight for example)
  52971. * @returns a serialized layer object
  52972. */
  52973. abstract serialize?(): any;
  52974. /**
  52975. * Initializes the effect layer with the required options.
  52976. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52977. */
  52978. protected _init(options: Partial<IEffectLayerOptions>): void;
  52979. /**
  52980. * Generates the index buffer of the full screen quad blending to the main canvas.
  52981. */
  52982. private _generateIndexBuffer;
  52983. /**
  52984. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52985. */
  52986. private _generateVertexBuffer;
  52987. /**
  52988. * Sets the main texture desired size which is the closest power of two
  52989. * of the engine canvas size.
  52990. */
  52991. private _setMainTextureSize;
  52992. /**
  52993. * Creates the main texture for the effect layer.
  52994. */
  52995. protected _createMainTexture(): void;
  52996. /**
  52997. * Adds specific effects defines.
  52998. * @param defines The defines to add specifics to.
  52999. */
  53000. protected _addCustomEffectDefines(defines: string[]): void;
  53001. /**
  53002. * Checks for the readiness of the element composing the layer.
  53003. * @param subMesh the mesh to check for
  53004. * @param useInstances specify whether or not to use instances to render the mesh
  53005. * @param emissiveTexture the associated emissive texture used to generate the glow
  53006. * @return true if ready otherwise, false
  53007. */
  53008. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53009. /**
  53010. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53011. */
  53012. render(): void;
  53013. /**
  53014. * Determine if a given mesh will be used in the current effect.
  53015. * @param mesh mesh to test
  53016. * @returns true if the mesh will be used
  53017. */
  53018. hasMesh(mesh: AbstractMesh): boolean;
  53019. /**
  53020. * Returns true if the layer contains information to display, otherwise false.
  53021. * @returns true if the glow layer should be rendered
  53022. */
  53023. shouldRender(): boolean;
  53024. /**
  53025. * Returns true if the mesh should render, otherwise false.
  53026. * @param mesh The mesh to render
  53027. * @returns true if it should render otherwise false
  53028. */
  53029. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53030. /**
  53031. * Returns true if the mesh can be rendered, otherwise false.
  53032. * @param mesh The mesh to render
  53033. * @param material The material used on the mesh
  53034. * @returns true if it can be rendered otherwise false
  53035. */
  53036. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53037. /**
  53038. * Returns true if the mesh should render, otherwise false.
  53039. * @param mesh The mesh to render
  53040. * @returns true if it should render otherwise false
  53041. */
  53042. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53043. /**
  53044. * Renders the submesh passed in parameter to the generation map.
  53045. */
  53046. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53047. /**
  53048. * Defines whether the current material of the mesh should be use to render the effect.
  53049. * @param mesh defines the current mesh to render
  53050. */
  53051. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53052. /**
  53053. * Rebuild the required buffers.
  53054. * @hidden Internal use only.
  53055. */
  53056. _rebuild(): void;
  53057. /**
  53058. * Dispose only the render target textures and post process.
  53059. */
  53060. private _disposeTextureAndPostProcesses;
  53061. /**
  53062. * Dispose the highlight layer and free resources.
  53063. */
  53064. dispose(): void;
  53065. /**
  53066. * Gets the class name of the effect layer
  53067. * @returns the string with the class name of the effect layer
  53068. */
  53069. getClassName(): string;
  53070. /**
  53071. * Creates an effect layer from parsed effect layer data
  53072. * @param parsedEffectLayer defines effect layer data
  53073. * @param scene defines the current scene
  53074. * @param rootUrl defines the root URL containing the effect layer information
  53075. * @returns a parsed effect Layer
  53076. */
  53077. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53078. }
  53079. }
  53080. declare module BABYLON {
  53081. interface AbstractScene {
  53082. /**
  53083. * The list of effect layers (highlights/glow) added to the scene
  53084. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53085. * @see http://doc.babylonjs.com/how_to/glow_layer
  53086. */
  53087. effectLayers: Array<EffectLayer>;
  53088. /**
  53089. * Removes the given effect layer from this scene.
  53090. * @param toRemove defines the effect layer to remove
  53091. * @returns the index of the removed effect layer
  53092. */
  53093. removeEffectLayer(toRemove: EffectLayer): number;
  53094. /**
  53095. * Adds the given effect layer to this scene
  53096. * @param newEffectLayer defines the effect layer to add
  53097. */
  53098. addEffectLayer(newEffectLayer: EffectLayer): void;
  53099. }
  53100. /**
  53101. * Defines the layer scene component responsible to manage any effect layers
  53102. * in a given scene.
  53103. */
  53104. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53105. /**
  53106. * The component name helpfull to identify the component in the list of scene components.
  53107. */
  53108. readonly name: string;
  53109. /**
  53110. * The scene the component belongs to.
  53111. */
  53112. scene: Scene;
  53113. private _engine;
  53114. private _renderEffects;
  53115. private _needStencil;
  53116. private _previousStencilState;
  53117. /**
  53118. * Creates a new instance of the component for the given scene
  53119. * @param scene Defines the scene to register the component in
  53120. */
  53121. constructor(scene: Scene);
  53122. /**
  53123. * Registers the component in a given scene
  53124. */
  53125. register(): void;
  53126. /**
  53127. * Rebuilds the elements related to this component in case of
  53128. * context lost for instance.
  53129. */
  53130. rebuild(): void;
  53131. /**
  53132. * Serializes the component data to the specified json object
  53133. * @param serializationObject The object to serialize to
  53134. */
  53135. serialize(serializationObject: any): void;
  53136. /**
  53137. * Adds all the elements from the container to the scene
  53138. * @param container the container holding the elements
  53139. */
  53140. addFromContainer(container: AbstractScene): void;
  53141. /**
  53142. * Removes all the elements in the container from the scene
  53143. * @param container contains the elements to remove
  53144. * @param dispose if the removed element should be disposed (default: false)
  53145. */
  53146. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53147. /**
  53148. * Disposes the component and the associated ressources.
  53149. */
  53150. dispose(): void;
  53151. private _isReadyForMesh;
  53152. private _renderMainTexture;
  53153. private _setStencil;
  53154. private _setStencilBack;
  53155. private _draw;
  53156. private _drawCamera;
  53157. private _drawRenderingGroup;
  53158. }
  53159. }
  53160. declare module BABYLON {
  53161. /** @hidden */
  53162. export var glowMapMergePixelShader: {
  53163. name: string;
  53164. shader: string;
  53165. };
  53166. }
  53167. declare module BABYLON {
  53168. /** @hidden */
  53169. export var glowMapMergeVertexShader: {
  53170. name: string;
  53171. shader: string;
  53172. };
  53173. }
  53174. declare module BABYLON {
  53175. interface AbstractScene {
  53176. /**
  53177. * Return a the first highlight layer of the scene with a given name.
  53178. * @param name The name of the highlight layer to look for.
  53179. * @return The highlight layer if found otherwise null.
  53180. */
  53181. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53182. }
  53183. /**
  53184. * Glow layer options. This helps customizing the behaviour
  53185. * of the glow layer.
  53186. */
  53187. export interface IGlowLayerOptions {
  53188. /**
  53189. * Multiplication factor apply to the canvas size to compute the render target size
  53190. * used to generated the glowing objects (the smaller the faster).
  53191. */
  53192. mainTextureRatio: number;
  53193. /**
  53194. * Enforces a fixed size texture to ensure resize independant blur.
  53195. */
  53196. mainTextureFixedSize?: number;
  53197. /**
  53198. * How big is the kernel of the blur texture.
  53199. */
  53200. blurKernelSize: number;
  53201. /**
  53202. * The camera attached to the layer.
  53203. */
  53204. camera: Nullable<Camera>;
  53205. /**
  53206. * Enable MSAA by chosing the number of samples.
  53207. */
  53208. mainTextureSamples?: number;
  53209. /**
  53210. * The rendering group to draw the layer in.
  53211. */
  53212. renderingGroupId: number;
  53213. }
  53214. /**
  53215. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53216. *
  53217. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53218. *
  53219. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53220. */
  53221. export class GlowLayer extends EffectLayer {
  53222. /**
  53223. * Effect Name of the layer.
  53224. */
  53225. static readonly EffectName: string;
  53226. /**
  53227. * The default blur kernel size used for the glow.
  53228. */
  53229. static DefaultBlurKernelSize: number;
  53230. /**
  53231. * The default texture size ratio used for the glow.
  53232. */
  53233. static DefaultTextureRatio: number;
  53234. /**
  53235. * Sets the kernel size of the blur.
  53236. */
  53237. set blurKernelSize(value: number);
  53238. /**
  53239. * Gets the kernel size of the blur.
  53240. */
  53241. get blurKernelSize(): number;
  53242. /**
  53243. * Sets the glow intensity.
  53244. */
  53245. set intensity(value: number);
  53246. /**
  53247. * Gets the glow intensity.
  53248. */
  53249. get intensity(): number;
  53250. private _options;
  53251. private _intensity;
  53252. private _horizontalBlurPostprocess1;
  53253. private _verticalBlurPostprocess1;
  53254. private _horizontalBlurPostprocess2;
  53255. private _verticalBlurPostprocess2;
  53256. private _blurTexture1;
  53257. private _blurTexture2;
  53258. private _postProcesses1;
  53259. private _postProcesses2;
  53260. private _includedOnlyMeshes;
  53261. private _excludedMeshes;
  53262. private _meshesUsingTheirOwnMaterials;
  53263. /**
  53264. * Callback used to let the user override the color selection on a per mesh basis
  53265. */
  53266. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53267. /**
  53268. * Callback used to let the user override the texture selection on a per mesh basis
  53269. */
  53270. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53271. /**
  53272. * Instantiates a new glow Layer and references it to the scene.
  53273. * @param name The name of the layer
  53274. * @param scene The scene to use the layer in
  53275. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53276. */
  53277. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53278. /**
  53279. * Get the effect name of the layer.
  53280. * @return The effect name
  53281. */
  53282. getEffectName(): string;
  53283. /**
  53284. * Create the merge effect. This is the shader use to blit the information back
  53285. * to the main canvas at the end of the scene rendering.
  53286. */
  53287. protected _createMergeEffect(): Effect;
  53288. /**
  53289. * Creates the render target textures and post processes used in the glow layer.
  53290. */
  53291. protected _createTextureAndPostProcesses(): void;
  53292. /**
  53293. * Checks for the readiness of the element composing the layer.
  53294. * @param subMesh the mesh to check for
  53295. * @param useInstances specify wether or not to use instances to render the mesh
  53296. * @param emissiveTexture the associated emissive texture used to generate the glow
  53297. * @return true if ready otherwise, false
  53298. */
  53299. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53300. /**
  53301. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53302. */
  53303. needStencil(): boolean;
  53304. /**
  53305. * Returns true if the mesh can be rendered, otherwise false.
  53306. * @param mesh The mesh to render
  53307. * @param material The material used on the mesh
  53308. * @returns true if it can be rendered otherwise false
  53309. */
  53310. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53311. /**
  53312. * Implementation specific of rendering the generating effect on the main canvas.
  53313. * @param effect The effect used to render through
  53314. */
  53315. protected _internalRender(effect: Effect): void;
  53316. /**
  53317. * Sets the required values for both the emissive texture and and the main color.
  53318. */
  53319. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53320. /**
  53321. * Returns true if the mesh should render, otherwise false.
  53322. * @param mesh The mesh to render
  53323. * @returns true if it should render otherwise false
  53324. */
  53325. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53326. /**
  53327. * Adds specific effects defines.
  53328. * @param defines The defines to add specifics to.
  53329. */
  53330. protected _addCustomEffectDefines(defines: string[]): void;
  53331. /**
  53332. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53333. * @param mesh The mesh to exclude from the glow layer
  53334. */
  53335. addExcludedMesh(mesh: Mesh): void;
  53336. /**
  53337. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53338. * @param mesh The mesh to remove
  53339. */
  53340. removeExcludedMesh(mesh: Mesh): void;
  53341. /**
  53342. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53343. * @param mesh The mesh to include in the glow layer
  53344. */
  53345. addIncludedOnlyMesh(mesh: Mesh): void;
  53346. /**
  53347. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53348. * @param mesh The mesh to remove
  53349. */
  53350. removeIncludedOnlyMesh(mesh: Mesh): void;
  53351. /**
  53352. * Determine if a given mesh will be used in the glow layer
  53353. * @param mesh The mesh to test
  53354. * @returns true if the mesh will be highlighted by the current glow layer
  53355. */
  53356. hasMesh(mesh: AbstractMesh): boolean;
  53357. /**
  53358. * Defines whether the current material of the mesh should be use to render the effect.
  53359. * @param mesh defines the current mesh to render
  53360. */
  53361. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53362. /**
  53363. * Add a mesh to be rendered through its own material and not with emissive only.
  53364. * @param mesh The mesh for which we need to use its material
  53365. */
  53366. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53367. /**
  53368. * Remove a mesh from being rendered through its own material and not with emissive only.
  53369. * @param mesh The mesh for which we need to not use its material
  53370. */
  53371. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53372. /**
  53373. * Free any resources and references associated to a mesh.
  53374. * Internal use
  53375. * @param mesh The mesh to free.
  53376. * @hidden
  53377. */
  53378. _disposeMesh(mesh: Mesh): void;
  53379. /**
  53380. * Gets the class name of the effect layer
  53381. * @returns the string with the class name of the effect layer
  53382. */
  53383. getClassName(): string;
  53384. /**
  53385. * Serializes this glow layer
  53386. * @returns a serialized glow layer object
  53387. */
  53388. serialize(): any;
  53389. /**
  53390. * Creates a Glow Layer from parsed glow layer data
  53391. * @param parsedGlowLayer defines glow layer data
  53392. * @param scene defines the current scene
  53393. * @param rootUrl defines the root URL containing the glow layer information
  53394. * @returns a parsed Glow Layer
  53395. */
  53396. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53397. }
  53398. }
  53399. declare module BABYLON {
  53400. /** @hidden */
  53401. export var glowBlurPostProcessPixelShader: {
  53402. name: string;
  53403. shader: string;
  53404. };
  53405. }
  53406. declare module BABYLON {
  53407. interface AbstractScene {
  53408. /**
  53409. * Return a the first highlight layer of the scene with a given name.
  53410. * @param name The name of the highlight layer to look for.
  53411. * @return The highlight layer if found otherwise null.
  53412. */
  53413. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53414. }
  53415. /**
  53416. * Highlight layer options. This helps customizing the behaviour
  53417. * of the highlight layer.
  53418. */
  53419. export interface IHighlightLayerOptions {
  53420. /**
  53421. * Multiplication factor apply to the canvas size to compute the render target size
  53422. * used to generated the glowing objects (the smaller the faster).
  53423. */
  53424. mainTextureRatio: number;
  53425. /**
  53426. * Enforces a fixed size texture to ensure resize independant blur.
  53427. */
  53428. mainTextureFixedSize?: number;
  53429. /**
  53430. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53431. * of the picture to blur (the smaller the faster).
  53432. */
  53433. blurTextureSizeRatio: number;
  53434. /**
  53435. * How big in texel of the blur texture is the vertical blur.
  53436. */
  53437. blurVerticalSize: number;
  53438. /**
  53439. * How big in texel of the blur texture is the horizontal blur.
  53440. */
  53441. blurHorizontalSize: number;
  53442. /**
  53443. * Alpha blending mode used to apply the blur. Default is combine.
  53444. */
  53445. alphaBlendingMode: number;
  53446. /**
  53447. * The camera attached to the layer.
  53448. */
  53449. camera: Nullable<Camera>;
  53450. /**
  53451. * Should we display highlight as a solid stroke?
  53452. */
  53453. isStroke?: boolean;
  53454. /**
  53455. * The rendering group to draw the layer in.
  53456. */
  53457. renderingGroupId: number;
  53458. }
  53459. /**
  53460. * The highlight layer Helps adding a glow effect around a mesh.
  53461. *
  53462. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53463. * glowy meshes to your scene.
  53464. *
  53465. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53466. */
  53467. export class HighlightLayer extends EffectLayer {
  53468. name: string;
  53469. /**
  53470. * Effect Name of the highlight layer.
  53471. */
  53472. static readonly EffectName: string;
  53473. /**
  53474. * The neutral color used during the preparation of the glow effect.
  53475. * This is black by default as the blend operation is a blend operation.
  53476. */
  53477. static NeutralColor: Color4;
  53478. /**
  53479. * Stencil value used for glowing meshes.
  53480. */
  53481. static GlowingMeshStencilReference: number;
  53482. /**
  53483. * Stencil value used for the other meshes in the scene.
  53484. */
  53485. static NormalMeshStencilReference: number;
  53486. /**
  53487. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53488. */
  53489. innerGlow: boolean;
  53490. /**
  53491. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53492. */
  53493. outerGlow: boolean;
  53494. /**
  53495. * Specifies the horizontal size of the blur.
  53496. */
  53497. set blurHorizontalSize(value: number);
  53498. /**
  53499. * Specifies the vertical size of the blur.
  53500. */
  53501. set blurVerticalSize(value: number);
  53502. /**
  53503. * Gets the horizontal size of the blur.
  53504. */
  53505. get blurHorizontalSize(): number;
  53506. /**
  53507. * Gets the vertical size of the blur.
  53508. */
  53509. get blurVerticalSize(): number;
  53510. /**
  53511. * An event triggered when the highlight layer is being blurred.
  53512. */
  53513. onBeforeBlurObservable: Observable<HighlightLayer>;
  53514. /**
  53515. * An event triggered when the highlight layer has been blurred.
  53516. */
  53517. onAfterBlurObservable: Observable<HighlightLayer>;
  53518. private _instanceGlowingMeshStencilReference;
  53519. private _options;
  53520. private _downSamplePostprocess;
  53521. private _horizontalBlurPostprocess;
  53522. private _verticalBlurPostprocess;
  53523. private _blurTexture;
  53524. private _meshes;
  53525. private _excludedMeshes;
  53526. /**
  53527. * Instantiates a new highlight Layer and references it to the scene..
  53528. * @param name The name of the layer
  53529. * @param scene The scene to use the layer in
  53530. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53531. */
  53532. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53533. /**
  53534. * Get the effect name of the layer.
  53535. * @return The effect name
  53536. */
  53537. getEffectName(): string;
  53538. /**
  53539. * Create the merge effect. This is the shader use to blit the information back
  53540. * to the main canvas at the end of the scene rendering.
  53541. */
  53542. protected _createMergeEffect(): Effect;
  53543. /**
  53544. * Creates the render target textures and post processes used in the highlight layer.
  53545. */
  53546. protected _createTextureAndPostProcesses(): void;
  53547. /**
  53548. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53549. */
  53550. needStencil(): boolean;
  53551. /**
  53552. * Checks for the readiness of the element composing the layer.
  53553. * @param subMesh the mesh to check for
  53554. * @param useInstances specify wether or not to use instances to render the mesh
  53555. * @param emissiveTexture the associated emissive texture used to generate the glow
  53556. * @return true if ready otherwise, false
  53557. */
  53558. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53559. /**
  53560. * Implementation specific of rendering the generating effect on the main canvas.
  53561. * @param effect The effect used to render through
  53562. */
  53563. protected _internalRender(effect: Effect): void;
  53564. /**
  53565. * Returns true if the layer contains information to display, otherwise false.
  53566. */
  53567. shouldRender(): boolean;
  53568. /**
  53569. * Returns true if the mesh should render, otherwise false.
  53570. * @param mesh The mesh to render
  53571. * @returns true if it should render otherwise false
  53572. */
  53573. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53574. /**
  53575. * Sets the required values for both the emissive texture and and the main color.
  53576. */
  53577. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53578. /**
  53579. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53580. * @param mesh The mesh to exclude from the highlight layer
  53581. */
  53582. addExcludedMesh(mesh: Mesh): void;
  53583. /**
  53584. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53585. * @param mesh The mesh to highlight
  53586. */
  53587. removeExcludedMesh(mesh: Mesh): void;
  53588. /**
  53589. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53590. * @param mesh mesh to test
  53591. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53592. */
  53593. hasMesh(mesh: AbstractMesh): boolean;
  53594. /**
  53595. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53596. * @param mesh The mesh to highlight
  53597. * @param color The color of the highlight
  53598. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53599. */
  53600. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53601. /**
  53602. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53603. * @param mesh The mesh to highlight
  53604. */
  53605. removeMesh(mesh: Mesh): void;
  53606. /**
  53607. * Remove all the meshes currently referenced in the highlight layer
  53608. */
  53609. removeAllMeshes(): void;
  53610. /**
  53611. * Force the stencil to the normal expected value for none glowing parts
  53612. */
  53613. private _defaultStencilReference;
  53614. /**
  53615. * Free any resources and references associated to a mesh.
  53616. * Internal use
  53617. * @param mesh The mesh to free.
  53618. * @hidden
  53619. */
  53620. _disposeMesh(mesh: Mesh): void;
  53621. /**
  53622. * Dispose the highlight layer and free resources.
  53623. */
  53624. dispose(): void;
  53625. /**
  53626. * Gets the class name of the effect layer
  53627. * @returns the string with the class name of the effect layer
  53628. */
  53629. getClassName(): string;
  53630. /**
  53631. * Serializes this Highlight layer
  53632. * @returns a serialized Highlight layer object
  53633. */
  53634. serialize(): any;
  53635. /**
  53636. * Creates a Highlight layer from parsed Highlight layer data
  53637. * @param parsedHightlightLayer defines the Highlight layer data
  53638. * @param scene defines the current scene
  53639. * @param rootUrl defines the root URL containing the Highlight layer information
  53640. * @returns a parsed Highlight layer
  53641. */
  53642. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53643. }
  53644. }
  53645. declare module BABYLON {
  53646. interface AbstractScene {
  53647. /**
  53648. * The list of layers (background and foreground) of the scene
  53649. */
  53650. layers: Array<Layer>;
  53651. }
  53652. /**
  53653. * Defines the layer scene component responsible to manage any layers
  53654. * in a given scene.
  53655. */
  53656. export class LayerSceneComponent implements ISceneComponent {
  53657. /**
  53658. * The component name helpfull to identify the component in the list of scene components.
  53659. */
  53660. readonly name: string;
  53661. /**
  53662. * The scene the component belongs to.
  53663. */
  53664. scene: Scene;
  53665. private _engine;
  53666. /**
  53667. * Creates a new instance of the component for the given scene
  53668. * @param scene Defines the scene to register the component in
  53669. */
  53670. constructor(scene: Scene);
  53671. /**
  53672. * Registers the component in a given scene
  53673. */
  53674. register(): void;
  53675. /**
  53676. * Rebuilds the elements related to this component in case of
  53677. * context lost for instance.
  53678. */
  53679. rebuild(): void;
  53680. /**
  53681. * Disposes the component and the associated ressources.
  53682. */
  53683. dispose(): void;
  53684. private _draw;
  53685. private _drawCameraPredicate;
  53686. private _drawCameraBackground;
  53687. private _drawCameraForeground;
  53688. private _drawRenderTargetPredicate;
  53689. private _drawRenderTargetBackground;
  53690. private _drawRenderTargetForeground;
  53691. /**
  53692. * Adds all the elements from the container to the scene
  53693. * @param container the container holding the elements
  53694. */
  53695. addFromContainer(container: AbstractScene): void;
  53696. /**
  53697. * Removes all the elements in the container from the scene
  53698. * @param container contains the elements to remove
  53699. * @param dispose if the removed element should be disposed (default: false)
  53700. */
  53701. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53702. }
  53703. }
  53704. declare module BABYLON {
  53705. /** @hidden */
  53706. export var layerPixelShader: {
  53707. name: string;
  53708. shader: string;
  53709. };
  53710. }
  53711. declare module BABYLON {
  53712. /** @hidden */
  53713. export var layerVertexShader: {
  53714. name: string;
  53715. shader: string;
  53716. };
  53717. }
  53718. declare module BABYLON {
  53719. /**
  53720. * This represents a full screen 2d layer.
  53721. * This can be useful to display a picture in the background of your scene for instance.
  53722. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53723. */
  53724. export class Layer {
  53725. /**
  53726. * Define the name of the layer.
  53727. */
  53728. name: string;
  53729. /**
  53730. * Define the texture the layer should display.
  53731. */
  53732. texture: Nullable<Texture>;
  53733. /**
  53734. * Is the layer in background or foreground.
  53735. */
  53736. isBackground: boolean;
  53737. /**
  53738. * Define the color of the layer (instead of texture).
  53739. */
  53740. color: Color4;
  53741. /**
  53742. * Define the scale of the layer in order to zoom in out of the texture.
  53743. */
  53744. scale: Vector2;
  53745. /**
  53746. * Define an offset for the layer in order to shift the texture.
  53747. */
  53748. offset: Vector2;
  53749. /**
  53750. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53751. */
  53752. alphaBlendingMode: number;
  53753. /**
  53754. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53755. * Alpha test will not mix with the background color in case of transparency.
  53756. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53757. */
  53758. alphaTest: boolean;
  53759. /**
  53760. * Define a mask to restrict the layer to only some of the scene cameras.
  53761. */
  53762. layerMask: number;
  53763. /**
  53764. * Define the list of render target the layer is visible into.
  53765. */
  53766. renderTargetTextures: RenderTargetTexture[];
  53767. /**
  53768. * Define if the layer is only used in renderTarget or if it also
  53769. * renders in the main frame buffer of the canvas.
  53770. */
  53771. renderOnlyInRenderTargetTextures: boolean;
  53772. private _scene;
  53773. private _vertexBuffers;
  53774. private _indexBuffer;
  53775. private _effect;
  53776. private _previousDefines;
  53777. /**
  53778. * An event triggered when the layer is disposed.
  53779. */
  53780. onDisposeObservable: Observable<Layer>;
  53781. private _onDisposeObserver;
  53782. /**
  53783. * Back compatibility with callback before the onDisposeObservable existed.
  53784. * The set callback will be triggered when the layer has been disposed.
  53785. */
  53786. set onDispose(callback: () => void);
  53787. /**
  53788. * An event triggered before rendering the scene
  53789. */
  53790. onBeforeRenderObservable: Observable<Layer>;
  53791. private _onBeforeRenderObserver;
  53792. /**
  53793. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53794. * The set callback will be triggered just before rendering the layer.
  53795. */
  53796. set onBeforeRender(callback: () => void);
  53797. /**
  53798. * An event triggered after rendering the scene
  53799. */
  53800. onAfterRenderObservable: Observable<Layer>;
  53801. private _onAfterRenderObserver;
  53802. /**
  53803. * Back compatibility with callback before the onAfterRenderObservable existed.
  53804. * The set callback will be triggered just after rendering the layer.
  53805. */
  53806. set onAfterRender(callback: () => void);
  53807. /**
  53808. * Instantiates a new layer.
  53809. * This represents a full screen 2d layer.
  53810. * This can be useful to display a picture in the background of your scene for instance.
  53811. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53812. * @param name Define the name of the layer in the scene
  53813. * @param imgUrl Define the url of the texture to display in the layer
  53814. * @param scene Define the scene the layer belongs to
  53815. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53816. * @param color Defines a color for the layer
  53817. */
  53818. constructor(
  53819. /**
  53820. * Define the name of the layer.
  53821. */
  53822. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53823. private _createIndexBuffer;
  53824. /** @hidden */
  53825. _rebuild(): void;
  53826. /**
  53827. * Renders the layer in the scene.
  53828. */
  53829. render(): void;
  53830. /**
  53831. * Disposes and releases the associated ressources.
  53832. */
  53833. dispose(): void;
  53834. }
  53835. }
  53836. declare module BABYLON {
  53837. /** @hidden */
  53838. export var lensFlarePixelShader: {
  53839. name: string;
  53840. shader: string;
  53841. };
  53842. }
  53843. declare module BABYLON {
  53844. /** @hidden */
  53845. export var lensFlareVertexShader: {
  53846. name: string;
  53847. shader: string;
  53848. };
  53849. }
  53850. declare module BABYLON {
  53851. /**
  53852. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53853. * It is usually composed of several `lensFlare`.
  53854. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53855. */
  53856. export class LensFlareSystem {
  53857. /**
  53858. * Define the name of the lens flare system
  53859. */
  53860. name: string;
  53861. /**
  53862. * List of lens flares used in this system.
  53863. */
  53864. lensFlares: LensFlare[];
  53865. /**
  53866. * Define a limit from the border the lens flare can be visible.
  53867. */
  53868. borderLimit: number;
  53869. /**
  53870. * Define a viewport border we do not want to see the lens flare in.
  53871. */
  53872. viewportBorder: number;
  53873. /**
  53874. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53875. */
  53876. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53877. /**
  53878. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53879. */
  53880. layerMask: number;
  53881. /**
  53882. * Define the id of the lens flare system in the scene.
  53883. * (equal to name by default)
  53884. */
  53885. id: string;
  53886. private _scene;
  53887. private _emitter;
  53888. private _vertexBuffers;
  53889. private _indexBuffer;
  53890. private _effect;
  53891. private _positionX;
  53892. private _positionY;
  53893. private _isEnabled;
  53894. /** @hidden */
  53895. static _SceneComponentInitialization: (scene: Scene) => void;
  53896. /**
  53897. * Instantiates a lens flare system.
  53898. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53899. * It is usually composed of several `lensFlare`.
  53900. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53901. * @param name Define the name of the lens flare system in the scene
  53902. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53903. * @param scene Define the scene the lens flare system belongs to
  53904. */
  53905. constructor(
  53906. /**
  53907. * Define the name of the lens flare system
  53908. */
  53909. name: string, emitter: any, scene: Scene);
  53910. /**
  53911. * Define if the lens flare system is enabled.
  53912. */
  53913. get isEnabled(): boolean;
  53914. set isEnabled(value: boolean);
  53915. /**
  53916. * Get the scene the effects belongs to.
  53917. * @returns the scene holding the lens flare system
  53918. */
  53919. getScene(): Scene;
  53920. /**
  53921. * Get the emitter of the lens flare system.
  53922. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53923. * @returns the emitter of the lens flare system
  53924. */
  53925. getEmitter(): any;
  53926. /**
  53927. * Set the emitter of the lens flare system.
  53928. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53929. * @param newEmitter Define the new emitter of the system
  53930. */
  53931. setEmitter(newEmitter: any): void;
  53932. /**
  53933. * Get the lens flare system emitter position.
  53934. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53935. * @returns the position
  53936. */
  53937. getEmitterPosition(): Vector3;
  53938. /**
  53939. * @hidden
  53940. */
  53941. computeEffectivePosition(globalViewport: Viewport): boolean;
  53942. /** @hidden */
  53943. _isVisible(): boolean;
  53944. /**
  53945. * @hidden
  53946. */
  53947. render(): boolean;
  53948. /**
  53949. * Dispose and release the lens flare with its associated resources.
  53950. */
  53951. dispose(): void;
  53952. /**
  53953. * Parse a lens flare system from a JSON repressentation
  53954. * @param parsedLensFlareSystem Define the JSON to parse
  53955. * @param scene Define the scene the parsed system should be instantiated in
  53956. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53957. * @returns the parsed system
  53958. */
  53959. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53960. /**
  53961. * Serialize the current Lens Flare System into a JSON representation.
  53962. * @returns the serialized JSON
  53963. */
  53964. serialize(): any;
  53965. }
  53966. }
  53967. declare module BABYLON {
  53968. /**
  53969. * This represents one of the lens effect in a `lensFlareSystem`.
  53970. * It controls one of the indiviual texture used in the effect.
  53971. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53972. */
  53973. export class LensFlare {
  53974. /**
  53975. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53976. */
  53977. size: number;
  53978. /**
  53979. * 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.
  53980. */
  53981. position: number;
  53982. /**
  53983. * Define the lens color.
  53984. */
  53985. color: Color3;
  53986. /**
  53987. * Define the lens texture.
  53988. */
  53989. texture: Nullable<Texture>;
  53990. /**
  53991. * Define the alpha mode to render this particular lens.
  53992. */
  53993. alphaMode: number;
  53994. private _system;
  53995. /**
  53996. * Creates a new Lens Flare.
  53997. * This represents one of the lens effect in a `lensFlareSystem`.
  53998. * It controls one of the indiviual texture used in the effect.
  53999. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54000. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54001. * @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.
  54002. * @param color Define the lens color
  54003. * @param imgUrl Define the lens texture url
  54004. * @param system Define the `lensFlareSystem` this flare is part of
  54005. * @returns The newly created Lens Flare
  54006. */
  54007. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54008. /**
  54009. * Instantiates a new Lens Flare.
  54010. * This represents one of the lens effect in a `lensFlareSystem`.
  54011. * It controls one of the indiviual texture used in the effect.
  54012. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54013. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54014. * @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.
  54015. * @param color Define the lens color
  54016. * @param imgUrl Define the lens texture url
  54017. * @param system Define the `lensFlareSystem` this flare is part of
  54018. */
  54019. constructor(
  54020. /**
  54021. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54022. */
  54023. size: number,
  54024. /**
  54025. * 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.
  54026. */
  54027. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54028. /**
  54029. * Dispose and release the lens flare with its associated resources.
  54030. */
  54031. dispose(): void;
  54032. }
  54033. }
  54034. declare module BABYLON {
  54035. interface AbstractScene {
  54036. /**
  54037. * The list of lens flare system added to the scene
  54038. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54039. */
  54040. lensFlareSystems: Array<LensFlareSystem>;
  54041. /**
  54042. * Removes the given lens flare system from this scene.
  54043. * @param toRemove The lens flare system to remove
  54044. * @returns The index of the removed lens flare system
  54045. */
  54046. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54047. /**
  54048. * Adds the given lens flare system to this scene
  54049. * @param newLensFlareSystem The lens flare system to add
  54050. */
  54051. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54052. /**
  54053. * Gets a lens flare system using its name
  54054. * @param name defines the name to look for
  54055. * @returns the lens flare system or null if not found
  54056. */
  54057. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54058. /**
  54059. * Gets a lens flare system using its id
  54060. * @param id defines the id to look for
  54061. * @returns the lens flare system or null if not found
  54062. */
  54063. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54064. }
  54065. /**
  54066. * Defines the lens flare scene component responsible to manage any lens flares
  54067. * in a given scene.
  54068. */
  54069. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54070. /**
  54071. * The component name helpfull to identify the component in the list of scene components.
  54072. */
  54073. readonly name: string;
  54074. /**
  54075. * The scene the component belongs to.
  54076. */
  54077. scene: Scene;
  54078. /**
  54079. * Creates a new instance of the component for the given scene
  54080. * @param scene Defines the scene to register the component in
  54081. */
  54082. constructor(scene: Scene);
  54083. /**
  54084. * Registers the component in a given scene
  54085. */
  54086. register(): void;
  54087. /**
  54088. * Rebuilds the elements related to this component in case of
  54089. * context lost for instance.
  54090. */
  54091. rebuild(): void;
  54092. /**
  54093. * Adds all the elements from the container to the scene
  54094. * @param container the container holding the elements
  54095. */
  54096. addFromContainer(container: AbstractScene): void;
  54097. /**
  54098. * Removes all the elements in the container from the scene
  54099. * @param container contains the elements to remove
  54100. * @param dispose if the removed element should be disposed (default: false)
  54101. */
  54102. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54103. /**
  54104. * Serializes the component data to the specified json object
  54105. * @param serializationObject The object to serialize to
  54106. */
  54107. serialize(serializationObject: any): void;
  54108. /**
  54109. * Disposes the component and the associated ressources.
  54110. */
  54111. dispose(): void;
  54112. private _draw;
  54113. }
  54114. }
  54115. declare module BABYLON {
  54116. /** @hidden */
  54117. export var depthPixelShader: {
  54118. name: string;
  54119. shader: string;
  54120. };
  54121. }
  54122. declare module BABYLON {
  54123. /** @hidden */
  54124. export var depthVertexShader: {
  54125. name: string;
  54126. shader: string;
  54127. };
  54128. }
  54129. declare module BABYLON {
  54130. /**
  54131. * This represents a depth renderer in Babylon.
  54132. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54133. */
  54134. export class DepthRenderer {
  54135. private _scene;
  54136. private _depthMap;
  54137. private _effect;
  54138. private readonly _storeNonLinearDepth;
  54139. private readonly _clearColor;
  54140. /** Get if the depth renderer is using packed depth or not */
  54141. readonly isPacked: boolean;
  54142. private _cachedDefines;
  54143. private _camera;
  54144. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54145. enabled: boolean;
  54146. /**
  54147. * Specifiess that the depth renderer will only be used within
  54148. * the camera it is created for.
  54149. * This can help forcing its rendering during the camera processing.
  54150. */
  54151. useOnlyInActiveCamera: boolean;
  54152. /** @hidden */
  54153. static _SceneComponentInitialization: (scene: Scene) => void;
  54154. /**
  54155. * Instantiates a depth renderer
  54156. * @param scene The scene the renderer belongs to
  54157. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54158. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54159. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54160. */
  54161. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54162. /**
  54163. * Creates the depth rendering effect and checks if the effect is ready.
  54164. * @param subMesh The submesh to be used to render the depth map of
  54165. * @param useInstances If multiple world instances should be used
  54166. * @returns if the depth renderer is ready to render the depth map
  54167. */
  54168. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54169. /**
  54170. * Gets the texture which the depth map will be written to.
  54171. * @returns The depth map texture
  54172. */
  54173. getDepthMap(): RenderTargetTexture;
  54174. /**
  54175. * Disposes of the depth renderer.
  54176. */
  54177. dispose(): void;
  54178. }
  54179. }
  54180. declare module BABYLON {
  54181. /** @hidden */
  54182. export var minmaxReduxPixelShader: {
  54183. name: string;
  54184. shader: string;
  54185. };
  54186. }
  54187. declare module BABYLON {
  54188. /**
  54189. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54190. * and maximum values from all values of the texture.
  54191. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54192. * The source values are read from the red channel of the texture.
  54193. */
  54194. export class MinMaxReducer {
  54195. /**
  54196. * Observable triggered when the computation has been performed
  54197. */
  54198. onAfterReductionPerformed: Observable<{
  54199. min: number;
  54200. max: number;
  54201. }>;
  54202. protected _camera: Camera;
  54203. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54204. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54205. protected _postProcessManager: PostProcessManager;
  54206. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54207. protected _forceFullscreenViewport: boolean;
  54208. /**
  54209. * Creates a min/max reducer
  54210. * @param camera The camera to use for the post processes
  54211. */
  54212. constructor(camera: Camera);
  54213. /**
  54214. * Gets the texture used to read the values from.
  54215. */
  54216. get sourceTexture(): Nullable<RenderTargetTexture>;
  54217. /**
  54218. * Sets the source texture to read the values from.
  54219. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54220. * because in such textures '1' value must not be taken into account to compute the maximum
  54221. * as this value is used to clear the texture.
  54222. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54223. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54224. * @param depthRedux Indicates if the texture is a depth texture or not
  54225. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54226. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54227. */
  54228. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54229. /**
  54230. * Defines the refresh rate of the computation.
  54231. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54232. */
  54233. get refreshRate(): number;
  54234. set refreshRate(value: number);
  54235. protected _activated: boolean;
  54236. /**
  54237. * Gets the activation status of the reducer
  54238. */
  54239. get activated(): boolean;
  54240. /**
  54241. * Activates the reduction computation.
  54242. * When activated, the observers registered in onAfterReductionPerformed are
  54243. * called after the compuation is performed
  54244. */
  54245. activate(): void;
  54246. /**
  54247. * Deactivates the reduction computation.
  54248. */
  54249. deactivate(): void;
  54250. /**
  54251. * Disposes the min/max reducer
  54252. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54253. */
  54254. dispose(disposeAll?: boolean): void;
  54255. }
  54256. }
  54257. declare module BABYLON {
  54258. /**
  54259. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54260. */
  54261. export class DepthReducer extends MinMaxReducer {
  54262. private _depthRenderer;
  54263. private _depthRendererId;
  54264. /**
  54265. * Gets the depth renderer used for the computation.
  54266. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54267. */
  54268. get depthRenderer(): Nullable<DepthRenderer>;
  54269. /**
  54270. * Creates a depth reducer
  54271. * @param camera The camera used to render the depth texture
  54272. */
  54273. constructor(camera: Camera);
  54274. /**
  54275. * Sets the depth renderer to use to generate the depth map
  54276. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54277. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54278. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54279. */
  54280. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54281. /** @hidden */
  54282. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54283. /**
  54284. * Activates the reduction computation.
  54285. * When activated, the observers registered in onAfterReductionPerformed are
  54286. * called after the compuation is performed
  54287. */
  54288. activate(): void;
  54289. /**
  54290. * Deactivates the reduction computation.
  54291. */
  54292. deactivate(): void;
  54293. /**
  54294. * Disposes the depth reducer
  54295. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54296. */
  54297. dispose(disposeAll?: boolean): void;
  54298. }
  54299. }
  54300. declare module BABYLON {
  54301. /**
  54302. * A CSM implementation allowing casting shadows on large scenes.
  54303. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54304. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54305. */
  54306. export class CascadedShadowGenerator extends ShadowGenerator {
  54307. private static readonly frustumCornersNDCSpace;
  54308. /**
  54309. * Name of the CSM class
  54310. */
  54311. static CLASSNAME: string;
  54312. /**
  54313. * Defines the default number of cascades used by the CSM.
  54314. */
  54315. static readonly DEFAULT_CASCADES_COUNT: number;
  54316. /**
  54317. * Defines the minimum number of cascades used by the CSM.
  54318. */
  54319. static readonly MIN_CASCADES_COUNT: number;
  54320. /**
  54321. * Defines the maximum number of cascades used by the CSM.
  54322. */
  54323. static readonly MAX_CASCADES_COUNT: number;
  54324. protected _validateFilter(filter: number): number;
  54325. /**
  54326. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54327. */
  54328. penumbraDarkness: number;
  54329. private _numCascades;
  54330. /**
  54331. * Gets or set the number of cascades used by the CSM.
  54332. */
  54333. get numCascades(): number;
  54334. set numCascades(value: number);
  54335. /**
  54336. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54337. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54338. */
  54339. stabilizeCascades: boolean;
  54340. private _freezeShadowCastersBoundingInfo;
  54341. private _freezeShadowCastersBoundingInfoObservable;
  54342. /**
  54343. * Enables or disables the shadow casters bounding info computation.
  54344. * If your shadow casters don't move, you can disable this feature.
  54345. * If it is enabled, the bounding box computation is done every frame.
  54346. */
  54347. get freezeShadowCastersBoundingInfo(): boolean;
  54348. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54349. private _scbiMin;
  54350. private _scbiMax;
  54351. protected _computeShadowCastersBoundingInfo(): void;
  54352. protected _shadowCastersBoundingInfo: BoundingInfo;
  54353. /**
  54354. * Gets or sets the shadow casters bounding info.
  54355. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54356. * so that the system won't overwrite the bounds you provide
  54357. */
  54358. get shadowCastersBoundingInfo(): BoundingInfo;
  54359. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54360. protected _breaksAreDirty: boolean;
  54361. protected _minDistance: number;
  54362. protected _maxDistance: number;
  54363. /**
  54364. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54365. *
  54366. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54367. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54368. * @param min minimal distance for the breaks (default to 0.)
  54369. * @param max maximal distance for the breaks (default to 1.)
  54370. */
  54371. setMinMaxDistance(min: number, max: number): void;
  54372. /** Gets the minimal distance used in the cascade break computation */
  54373. get minDistance(): number;
  54374. /** Gets the maximal distance used in the cascade break computation */
  54375. get maxDistance(): number;
  54376. /**
  54377. * Gets the class name of that object
  54378. * @returns "CascadedShadowGenerator"
  54379. */
  54380. getClassName(): string;
  54381. private _cascadeMinExtents;
  54382. private _cascadeMaxExtents;
  54383. /**
  54384. * Gets a cascade minimum extents
  54385. * @param cascadeIndex index of the cascade
  54386. * @returns the minimum cascade extents
  54387. */
  54388. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54389. /**
  54390. * Gets a cascade maximum extents
  54391. * @param cascadeIndex index of the cascade
  54392. * @returns the maximum cascade extents
  54393. */
  54394. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54395. private _cascades;
  54396. private _currentLayer;
  54397. private _viewSpaceFrustumsZ;
  54398. private _viewMatrices;
  54399. private _projectionMatrices;
  54400. private _transformMatrices;
  54401. private _transformMatricesAsArray;
  54402. private _frustumLengths;
  54403. private _lightSizeUVCorrection;
  54404. private _depthCorrection;
  54405. private _frustumCornersWorldSpace;
  54406. private _frustumCenter;
  54407. private _shadowCameraPos;
  54408. private _shadowMaxZ;
  54409. /**
  54410. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54411. * It defaults to camera.maxZ
  54412. */
  54413. get shadowMaxZ(): number;
  54414. /**
  54415. * Sets the shadow max z distance.
  54416. */
  54417. set shadowMaxZ(value: number);
  54418. protected _debug: boolean;
  54419. /**
  54420. * Gets or sets the debug flag.
  54421. * When enabled, the cascades are materialized by different colors on the screen.
  54422. */
  54423. get debug(): boolean;
  54424. set debug(dbg: boolean);
  54425. private _depthClamp;
  54426. /**
  54427. * Gets or sets the depth clamping value.
  54428. *
  54429. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54430. * to account for the shadow casters far away.
  54431. *
  54432. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54433. */
  54434. get depthClamp(): boolean;
  54435. set depthClamp(value: boolean);
  54436. private _cascadeBlendPercentage;
  54437. /**
  54438. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54439. * It defaults to 0.1 (10% blending).
  54440. */
  54441. get cascadeBlendPercentage(): number;
  54442. set cascadeBlendPercentage(value: number);
  54443. private _lambda;
  54444. /**
  54445. * Gets or set the lambda parameter.
  54446. * This parameter is used to split the camera frustum and create the cascades.
  54447. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  54448. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54449. */
  54450. get lambda(): number;
  54451. set lambda(value: number);
  54452. /**
  54453. * Gets the view matrix corresponding to a given cascade
  54454. * @param cascadeNum cascade to retrieve the view matrix from
  54455. * @returns the cascade view matrix
  54456. */
  54457. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54458. /**
  54459. * Gets the projection matrix corresponding to a given cascade
  54460. * @param cascadeNum cascade to retrieve the projection matrix from
  54461. * @returns the cascade projection matrix
  54462. */
  54463. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54464. /**
  54465. * Gets the transformation matrix corresponding to a given cascade
  54466. * @param cascadeNum cascade to retrieve the transformation matrix from
  54467. * @returns the cascade transformation matrix
  54468. */
  54469. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54470. private _depthRenderer;
  54471. /**
  54472. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54473. *
  54474. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54475. *
  54476. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54477. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54478. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  54479. */
  54480. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54481. private _depthReducer;
  54482. private _autoCalcDepthBounds;
  54483. /**
  54484. * Gets or sets the autoCalcDepthBounds property.
  54485. *
  54486. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54487. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54488. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54489. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54490. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54491. */
  54492. get autoCalcDepthBounds(): boolean;
  54493. set autoCalcDepthBounds(value: boolean);
  54494. /**
  54495. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54496. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54497. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54498. * for setting the refresh rate on the renderer yourself!
  54499. */
  54500. get autoCalcDepthBoundsRefreshRate(): number;
  54501. set autoCalcDepthBoundsRefreshRate(value: number);
  54502. /**
  54503. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54504. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54505. * you change the camera near/far planes!
  54506. */
  54507. splitFrustum(): void;
  54508. private _splitFrustum;
  54509. private _computeMatrices;
  54510. private _computeFrustumInWorldSpace;
  54511. private _computeCascadeFrustum;
  54512. /** @hidden */
  54513. static _SceneComponentInitialization: (scene: Scene) => void;
  54514. /**
  54515. * Creates a Cascaded Shadow Generator object.
  54516. * A ShadowGenerator is the required tool to use the shadows.
  54517. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54518. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54519. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54520. * @param light The directional light object generating the shadows.
  54521. * @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.
  54522. */
  54523. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54524. protected _initializeGenerator(): void;
  54525. protected _createTargetRenderTexture(): void;
  54526. protected _initializeShadowMap(): void;
  54527. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54528. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54529. /**
  54530. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54531. * @param defines Defines of the material we want to update
  54532. * @param lightIndex Index of the light in the enabled light list of the material
  54533. */
  54534. prepareDefines(defines: any, lightIndex: number): void;
  54535. /**
  54536. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54537. * defined in the generator but impacting the effect).
  54538. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54539. * @param effect The effect we are binfing the information for
  54540. */
  54541. bindShadowLight(lightIndex: string, effect: Effect): void;
  54542. /**
  54543. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54544. * (eq to view projection * shadow projection matrices)
  54545. * @returns The transform matrix used to create the shadow map
  54546. */
  54547. getTransformMatrix(): Matrix;
  54548. /**
  54549. * Disposes the ShadowGenerator.
  54550. * Returns nothing.
  54551. */
  54552. dispose(): void;
  54553. /**
  54554. * Serializes the shadow generator setup to a json object.
  54555. * @returns The serialized JSON object
  54556. */
  54557. serialize(): any;
  54558. /**
  54559. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54560. * @param parsedShadowGenerator The JSON object to parse
  54561. * @param scene The scene to create the shadow map for
  54562. * @returns The parsed shadow generator
  54563. */
  54564. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54565. }
  54566. }
  54567. declare module BABYLON {
  54568. /**
  54569. * Defines the shadow generator component responsible to manage any shadow generators
  54570. * in a given scene.
  54571. */
  54572. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54573. /**
  54574. * The component name helpfull to identify the component in the list of scene components.
  54575. */
  54576. readonly name: string;
  54577. /**
  54578. * The scene the component belongs to.
  54579. */
  54580. scene: Scene;
  54581. /**
  54582. * Creates a new instance of the component for the given scene
  54583. * @param scene Defines the scene to register the component in
  54584. */
  54585. constructor(scene: Scene);
  54586. /**
  54587. * Registers the component in a given scene
  54588. */
  54589. register(): void;
  54590. /**
  54591. * Rebuilds the elements related to this component in case of
  54592. * context lost for instance.
  54593. */
  54594. rebuild(): void;
  54595. /**
  54596. * Serializes the component data to the specified json object
  54597. * @param serializationObject The object to serialize to
  54598. */
  54599. serialize(serializationObject: any): void;
  54600. /**
  54601. * Adds all the elements from the container to the scene
  54602. * @param container the container holding the elements
  54603. */
  54604. addFromContainer(container: AbstractScene): void;
  54605. /**
  54606. * Removes all the elements in the container from the scene
  54607. * @param container contains the elements to remove
  54608. * @param dispose if the removed element should be disposed (default: false)
  54609. */
  54610. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54611. /**
  54612. * Rebuilds the elements related to this component in case of
  54613. * context lost for instance.
  54614. */
  54615. dispose(): void;
  54616. private _gatherRenderTargets;
  54617. }
  54618. }
  54619. declare module BABYLON {
  54620. /**
  54621. * A point light is a light defined by an unique point in world space.
  54622. * The light is emitted in every direction from this point.
  54623. * A good example of a point light is a standard light bulb.
  54624. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54625. */
  54626. export class PointLight extends ShadowLight {
  54627. private _shadowAngle;
  54628. /**
  54629. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54630. * This specifies what angle the shadow will use to be created.
  54631. *
  54632. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54633. */
  54634. get shadowAngle(): number;
  54635. /**
  54636. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54637. * This specifies what angle the shadow will use to be created.
  54638. *
  54639. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54640. */
  54641. set shadowAngle(value: number);
  54642. /**
  54643. * Gets the direction if it has been set.
  54644. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54645. */
  54646. get direction(): Vector3;
  54647. /**
  54648. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54649. */
  54650. set direction(value: Vector3);
  54651. /**
  54652. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54653. * A PointLight emits the light in every direction.
  54654. * It can cast shadows.
  54655. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54656. * ```javascript
  54657. * var pointLight = new PointLight("pl", camera.position, scene);
  54658. * ```
  54659. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54660. * @param name The light friendly name
  54661. * @param position The position of the point light in the scene
  54662. * @param scene The scene the lights belongs to
  54663. */
  54664. constructor(name: string, position: Vector3, scene: Scene);
  54665. /**
  54666. * Returns the string "PointLight"
  54667. * @returns the class name
  54668. */
  54669. getClassName(): string;
  54670. /**
  54671. * Returns the integer 0.
  54672. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54673. */
  54674. getTypeID(): number;
  54675. /**
  54676. * Specifies wether or not the shadowmap should be a cube texture.
  54677. * @returns true if the shadowmap needs to be a cube texture.
  54678. */
  54679. needCube(): boolean;
  54680. /**
  54681. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54682. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54683. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54684. */
  54685. getShadowDirection(faceIndex?: number): Vector3;
  54686. /**
  54687. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54688. * - fov = PI / 2
  54689. * - aspect ratio : 1.0
  54690. * - z-near and far equal to the active camera minZ and maxZ.
  54691. * Returns the PointLight.
  54692. */
  54693. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54694. protected _buildUniformLayout(): void;
  54695. /**
  54696. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54697. * @param effect The effect to update
  54698. * @param lightIndex The index of the light in the effect to update
  54699. * @returns The point light
  54700. */
  54701. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54702. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54703. /**
  54704. * Prepares the list of defines specific to the light type.
  54705. * @param defines the list of defines
  54706. * @param lightIndex defines the index of the light for the effect
  54707. */
  54708. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54709. }
  54710. }
  54711. declare module BABYLON {
  54712. /**
  54713. * Header information of HDR texture files.
  54714. */
  54715. export interface HDRInfo {
  54716. /**
  54717. * The height of the texture in pixels.
  54718. */
  54719. height: number;
  54720. /**
  54721. * The width of the texture in pixels.
  54722. */
  54723. width: number;
  54724. /**
  54725. * The index of the beginning of the data in the binary file.
  54726. */
  54727. dataPosition: number;
  54728. }
  54729. /**
  54730. * This groups tools to convert HDR texture to native colors array.
  54731. */
  54732. export class HDRTools {
  54733. private static Ldexp;
  54734. private static Rgbe2float;
  54735. private static readStringLine;
  54736. /**
  54737. * Reads header information from an RGBE texture stored in a native array.
  54738. * More information on this format are available here:
  54739. * https://en.wikipedia.org/wiki/RGBE_image_format
  54740. *
  54741. * @param uint8array The binary file stored in native array.
  54742. * @return The header information.
  54743. */
  54744. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54745. /**
  54746. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54747. * This RGBE texture needs to store the information as a panorama.
  54748. *
  54749. * More information on this format are available here:
  54750. * https://en.wikipedia.org/wiki/RGBE_image_format
  54751. *
  54752. * @param buffer The binary file stored in an array buffer.
  54753. * @param size The expected size of the extracted cubemap.
  54754. * @return The Cube Map information.
  54755. */
  54756. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54757. /**
  54758. * Returns the pixels data extracted from an RGBE texture.
  54759. * This pixels will be stored left to right up to down in the R G B order in one array.
  54760. *
  54761. * More information on this format are available here:
  54762. * https://en.wikipedia.org/wiki/RGBE_image_format
  54763. *
  54764. * @param uint8array The binary file stored in an array buffer.
  54765. * @param hdrInfo The header information of the file.
  54766. * @return The pixels data in RGB right to left up to down order.
  54767. */
  54768. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54769. private static RGBE_ReadPixels_RLE;
  54770. }
  54771. }
  54772. declare module BABYLON {
  54773. /**
  54774. * This represents a texture coming from an HDR input.
  54775. *
  54776. * The only supported format is currently panorama picture stored in RGBE format.
  54777. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54778. */
  54779. export class HDRCubeTexture extends BaseTexture {
  54780. private static _facesMapping;
  54781. private _generateHarmonics;
  54782. private _noMipmap;
  54783. private _textureMatrix;
  54784. private _size;
  54785. private _onLoad;
  54786. private _onError;
  54787. /**
  54788. * The texture URL.
  54789. */
  54790. url: string;
  54791. /**
  54792. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54793. */
  54794. coordinatesMode: number;
  54795. protected _isBlocking: boolean;
  54796. /**
  54797. * Sets wether or not the texture is blocking during loading.
  54798. */
  54799. set isBlocking(value: boolean);
  54800. /**
  54801. * Gets wether or not the texture is blocking during loading.
  54802. */
  54803. get isBlocking(): boolean;
  54804. protected _rotationY: number;
  54805. /**
  54806. * Sets texture matrix rotation angle around Y axis in radians.
  54807. */
  54808. set rotationY(value: number);
  54809. /**
  54810. * Gets texture matrix rotation angle around Y axis radians.
  54811. */
  54812. get rotationY(): number;
  54813. /**
  54814. * Gets or sets the center of the bounding box associated with the cube texture
  54815. * It must define where the camera used to render the texture was set
  54816. */
  54817. boundingBoxPosition: Vector3;
  54818. private _boundingBoxSize;
  54819. /**
  54820. * Gets or sets the size of the bounding box associated with the cube texture
  54821. * When defined, the cubemap will switch to local mode
  54822. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54823. * @example https://www.babylonjs-playground.com/#RNASML
  54824. */
  54825. set boundingBoxSize(value: Vector3);
  54826. get boundingBoxSize(): Vector3;
  54827. /**
  54828. * Instantiates an HDRTexture from the following parameters.
  54829. *
  54830. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54831. * @param scene The scene the texture will be used in
  54832. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54833. * @param noMipmap Forces to not generate the mipmap if true
  54834. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54835. * @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)
  54836. * @param reserved Reserved flag for internal use.
  54837. */
  54838. 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>);
  54839. /**
  54840. * Get the current class name of the texture useful for serialization or dynamic coding.
  54841. * @returns "HDRCubeTexture"
  54842. */
  54843. getClassName(): string;
  54844. /**
  54845. * Occurs when the file is raw .hdr file.
  54846. */
  54847. private loadTexture;
  54848. clone(): HDRCubeTexture;
  54849. delayLoad(): void;
  54850. /**
  54851. * Get the texture reflection matrix used to rotate/transform the reflection.
  54852. * @returns the reflection matrix
  54853. */
  54854. getReflectionTextureMatrix(): Matrix;
  54855. /**
  54856. * Set the texture reflection matrix used to rotate/transform the reflection.
  54857. * @param value Define the reflection matrix to set
  54858. */
  54859. setReflectionTextureMatrix(value: Matrix): void;
  54860. /**
  54861. * Parses a JSON representation of an HDR Texture in order to create the texture
  54862. * @param parsedTexture Define the JSON representation
  54863. * @param scene Define the scene the texture should be created in
  54864. * @param rootUrl Define the root url in case we need to load relative dependencies
  54865. * @returns the newly created texture after parsing
  54866. */
  54867. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54868. serialize(): any;
  54869. }
  54870. }
  54871. declare module BABYLON {
  54872. /**
  54873. * Class used to control physics engine
  54874. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54875. */
  54876. export class PhysicsEngine implements IPhysicsEngine {
  54877. private _physicsPlugin;
  54878. /**
  54879. * Global value used to control the smallest number supported by the simulation
  54880. */
  54881. static Epsilon: number;
  54882. private _impostors;
  54883. private _joints;
  54884. private _subTimeStep;
  54885. /**
  54886. * Gets the gravity vector used by the simulation
  54887. */
  54888. gravity: Vector3;
  54889. /**
  54890. * Factory used to create the default physics plugin.
  54891. * @returns The default physics plugin
  54892. */
  54893. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54894. /**
  54895. * Creates a new Physics Engine
  54896. * @param gravity defines the gravity vector used by the simulation
  54897. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54898. */
  54899. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54900. /**
  54901. * Sets the gravity vector used by the simulation
  54902. * @param gravity defines the gravity vector to use
  54903. */
  54904. setGravity(gravity: Vector3): void;
  54905. /**
  54906. * Set the time step of the physics engine.
  54907. * Default is 1/60.
  54908. * To slow it down, enter 1/600 for example.
  54909. * To speed it up, 1/30
  54910. * @param newTimeStep defines the new timestep to apply to this world.
  54911. */
  54912. setTimeStep(newTimeStep?: number): void;
  54913. /**
  54914. * Get the time step of the physics engine.
  54915. * @returns the current time step
  54916. */
  54917. getTimeStep(): number;
  54918. /**
  54919. * Set the sub time step of the physics engine.
  54920. * Default is 0 meaning there is no sub steps
  54921. * To increase physics resolution precision, set a small value (like 1 ms)
  54922. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54923. */
  54924. setSubTimeStep(subTimeStep?: number): void;
  54925. /**
  54926. * Get the sub time step of the physics engine.
  54927. * @returns the current sub time step
  54928. */
  54929. getSubTimeStep(): number;
  54930. /**
  54931. * Release all resources
  54932. */
  54933. dispose(): void;
  54934. /**
  54935. * Gets the name of the current physics plugin
  54936. * @returns the name of the plugin
  54937. */
  54938. getPhysicsPluginName(): string;
  54939. /**
  54940. * Adding a new impostor for the impostor tracking.
  54941. * This will be done by the impostor itself.
  54942. * @param impostor the impostor to add
  54943. */
  54944. addImpostor(impostor: PhysicsImpostor): void;
  54945. /**
  54946. * Remove an impostor from the engine.
  54947. * This impostor and its mesh will not longer be updated by the physics engine.
  54948. * @param impostor the impostor to remove
  54949. */
  54950. removeImpostor(impostor: PhysicsImpostor): void;
  54951. /**
  54952. * Add a joint to the physics engine
  54953. * @param mainImpostor defines the main impostor to which the joint is added.
  54954. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54955. * @param joint defines the joint that will connect both impostors.
  54956. */
  54957. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54958. /**
  54959. * Removes a joint from the simulation
  54960. * @param mainImpostor defines the impostor used with the joint
  54961. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54962. * @param joint defines the joint to remove
  54963. */
  54964. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54965. /**
  54966. * Called by the scene. No need to call it.
  54967. * @param delta defines the timespam between frames
  54968. */
  54969. _step(delta: number): void;
  54970. /**
  54971. * Gets the current plugin used to run the simulation
  54972. * @returns current plugin
  54973. */
  54974. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54975. /**
  54976. * Gets the list of physic impostors
  54977. * @returns an array of PhysicsImpostor
  54978. */
  54979. getImpostors(): Array<PhysicsImpostor>;
  54980. /**
  54981. * Gets the impostor for a physics enabled object
  54982. * @param object defines the object impersonated by the impostor
  54983. * @returns the PhysicsImpostor or null if not found
  54984. */
  54985. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54986. /**
  54987. * Gets the impostor for a physics body object
  54988. * @param body defines physics body used by the impostor
  54989. * @returns the PhysicsImpostor or null if not found
  54990. */
  54991. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54992. /**
  54993. * Does a raycast in the physics world
  54994. * @param from when should the ray start?
  54995. * @param to when should the ray end?
  54996. * @returns PhysicsRaycastResult
  54997. */
  54998. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54999. }
  55000. }
  55001. declare module BABYLON {
  55002. /** @hidden */
  55003. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55004. private _useDeltaForWorldStep;
  55005. world: any;
  55006. name: string;
  55007. private _physicsMaterials;
  55008. private _fixedTimeStep;
  55009. private _cannonRaycastResult;
  55010. private _raycastResult;
  55011. private _physicsBodysToRemoveAfterStep;
  55012. BJSCANNON: any;
  55013. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55014. setGravity(gravity: Vector3): void;
  55015. setTimeStep(timeStep: number): void;
  55016. getTimeStep(): number;
  55017. executeStep(delta: number): void;
  55018. private _removeMarkedPhysicsBodiesFromWorld;
  55019. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55020. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55021. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55022. private _processChildMeshes;
  55023. removePhysicsBody(impostor: PhysicsImpostor): void;
  55024. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55025. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55026. private _addMaterial;
  55027. private _checkWithEpsilon;
  55028. private _createShape;
  55029. private _createHeightmap;
  55030. private _minus90X;
  55031. private _plus90X;
  55032. private _tmpPosition;
  55033. private _tmpDeltaPosition;
  55034. private _tmpUnityRotation;
  55035. private _updatePhysicsBodyTransformation;
  55036. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55037. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55038. isSupported(): boolean;
  55039. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55040. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55041. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55042. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55043. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55044. getBodyMass(impostor: PhysicsImpostor): number;
  55045. getBodyFriction(impostor: PhysicsImpostor): number;
  55046. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55047. getBodyRestitution(impostor: PhysicsImpostor): number;
  55048. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55049. sleepBody(impostor: PhysicsImpostor): void;
  55050. wakeUpBody(impostor: PhysicsImpostor): void;
  55051. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55052. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55053. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55054. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55055. getRadius(impostor: PhysicsImpostor): number;
  55056. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55057. dispose(): void;
  55058. private _extendNamespace;
  55059. /**
  55060. * Does a raycast in the physics world
  55061. * @param from when should the ray start?
  55062. * @param to when should the ray end?
  55063. * @returns PhysicsRaycastResult
  55064. */
  55065. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55066. }
  55067. }
  55068. declare module BABYLON {
  55069. /** @hidden */
  55070. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55071. world: any;
  55072. name: string;
  55073. BJSOIMO: any;
  55074. private _raycastResult;
  55075. constructor(iterations?: number, oimoInjection?: any);
  55076. setGravity(gravity: Vector3): void;
  55077. setTimeStep(timeStep: number): void;
  55078. getTimeStep(): number;
  55079. private _tmpImpostorsArray;
  55080. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55081. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55082. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55083. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55084. private _tmpPositionVector;
  55085. removePhysicsBody(impostor: PhysicsImpostor): void;
  55086. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55087. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55088. isSupported(): boolean;
  55089. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55090. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55091. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55092. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55093. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55094. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55095. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55096. getBodyMass(impostor: PhysicsImpostor): number;
  55097. getBodyFriction(impostor: PhysicsImpostor): number;
  55098. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55099. getBodyRestitution(impostor: PhysicsImpostor): number;
  55100. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55101. sleepBody(impostor: PhysicsImpostor): void;
  55102. wakeUpBody(impostor: PhysicsImpostor): void;
  55103. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55104. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55105. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55106. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55107. getRadius(impostor: PhysicsImpostor): number;
  55108. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55109. dispose(): void;
  55110. /**
  55111. * Does a raycast in the physics world
  55112. * @param from when should the ray start?
  55113. * @param to when should the ray end?
  55114. * @returns PhysicsRaycastResult
  55115. */
  55116. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55117. }
  55118. }
  55119. declare module BABYLON {
  55120. /**
  55121. * Class containing static functions to help procedurally build meshes
  55122. */
  55123. export class RibbonBuilder {
  55124. /**
  55125. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55126. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55127. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55128. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55129. * * 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
  55130. * * 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
  55131. * * 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
  55132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55133. * * 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
  55134. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55135. * * 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
  55136. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55137. * * 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
  55138. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55140. * @param name defines the name of the mesh
  55141. * @param options defines the options used to create the mesh
  55142. * @param scene defines the hosting scene
  55143. * @returns the ribbon mesh
  55144. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55145. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55146. */
  55147. static CreateRibbon(name: string, options: {
  55148. pathArray: Vector3[][];
  55149. closeArray?: boolean;
  55150. closePath?: boolean;
  55151. offset?: number;
  55152. updatable?: boolean;
  55153. sideOrientation?: number;
  55154. frontUVs?: Vector4;
  55155. backUVs?: Vector4;
  55156. instance?: Mesh;
  55157. invertUV?: boolean;
  55158. uvs?: Vector2[];
  55159. colors?: Color4[];
  55160. }, scene?: Nullable<Scene>): Mesh;
  55161. }
  55162. }
  55163. declare module BABYLON {
  55164. /**
  55165. * Class containing static functions to help procedurally build meshes
  55166. */
  55167. export class ShapeBuilder {
  55168. /**
  55169. * 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.
  55170. * * 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.
  55171. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55172. * * 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.
  55173. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55174. * * 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
  55175. * * 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
  55176. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55178. * * 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
  55179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55181. * @param name defines the name of the mesh
  55182. * @param options defines the options used to create the mesh
  55183. * @param scene defines the hosting scene
  55184. * @returns the extruded shape mesh
  55185. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55187. */
  55188. static ExtrudeShape(name: string, options: {
  55189. shape: Vector3[];
  55190. path: Vector3[];
  55191. scale?: number;
  55192. rotation?: number;
  55193. cap?: number;
  55194. updatable?: boolean;
  55195. sideOrientation?: number;
  55196. frontUVs?: Vector4;
  55197. backUVs?: Vector4;
  55198. instance?: Mesh;
  55199. invertUV?: boolean;
  55200. }, scene?: Nullable<Scene>): Mesh;
  55201. /**
  55202. * Creates an custom extruded shape mesh.
  55203. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55204. * * 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.
  55205. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55206. * * 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
  55207. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55208. * * 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
  55209. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55210. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55211. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55212. * * 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
  55213. * * 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
  55214. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55216. * * 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
  55217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55219. * @param name defines the name of the mesh
  55220. * @param options defines the options used to create the mesh
  55221. * @param scene defines the hosting scene
  55222. * @returns the custom extruded shape mesh
  55223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55224. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55226. */
  55227. static ExtrudeShapeCustom(name: string, options: {
  55228. shape: Vector3[];
  55229. path: Vector3[];
  55230. scaleFunction?: any;
  55231. rotationFunction?: any;
  55232. ribbonCloseArray?: boolean;
  55233. ribbonClosePath?: boolean;
  55234. cap?: number;
  55235. updatable?: boolean;
  55236. sideOrientation?: number;
  55237. frontUVs?: Vector4;
  55238. backUVs?: Vector4;
  55239. instance?: Mesh;
  55240. invertUV?: boolean;
  55241. }, scene?: Nullable<Scene>): Mesh;
  55242. private static _ExtrudeShapeGeneric;
  55243. }
  55244. }
  55245. declare module BABYLON {
  55246. /**
  55247. * AmmoJS Physics plugin
  55248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55249. * @see https://github.com/kripken/ammo.js/
  55250. */
  55251. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55252. private _useDeltaForWorldStep;
  55253. /**
  55254. * Reference to the Ammo library
  55255. */
  55256. bjsAMMO: any;
  55257. /**
  55258. * Created ammoJS world which physics bodies are added to
  55259. */
  55260. world: any;
  55261. /**
  55262. * Name of the plugin
  55263. */
  55264. name: string;
  55265. private _timeStep;
  55266. private _fixedTimeStep;
  55267. private _maxSteps;
  55268. private _tmpQuaternion;
  55269. private _tmpAmmoTransform;
  55270. private _tmpAmmoQuaternion;
  55271. private _tmpAmmoConcreteContactResultCallback;
  55272. private _collisionConfiguration;
  55273. private _dispatcher;
  55274. private _overlappingPairCache;
  55275. private _solver;
  55276. private _softBodySolver;
  55277. private _tmpAmmoVectorA;
  55278. private _tmpAmmoVectorB;
  55279. private _tmpAmmoVectorC;
  55280. private _tmpAmmoVectorD;
  55281. private _tmpContactCallbackResult;
  55282. private _tmpAmmoVectorRCA;
  55283. private _tmpAmmoVectorRCB;
  55284. private _raycastResult;
  55285. private static readonly DISABLE_COLLISION_FLAG;
  55286. private static readonly KINEMATIC_FLAG;
  55287. private static readonly DISABLE_DEACTIVATION_FLAG;
  55288. /**
  55289. * Initializes the ammoJS plugin
  55290. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55291. * @param ammoInjection can be used to inject your own ammo reference
  55292. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55293. */
  55294. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55295. /**
  55296. * Sets the gravity of the physics world (m/(s^2))
  55297. * @param gravity Gravity to set
  55298. */
  55299. setGravity(gravity: Vector3): void;
  55300. /**
  55301. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55302. * @param timeStep timestep to use in seconds
  55303. */
  55304. setTimeStep(timeStep: number): void;
  55305. /**
  55306. * 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)
  55307. * @param fixedTimeStep fixedTimeStep to use in seconds
  55308. */
  55309. setFixedTimeStep(fixedTimeStep: number): void;
  55310. /**
  55311. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55312. * @param maxSteps the maximum number of steps by the physics engine per frame
  55313. */
  55314. setMaxSteps(maxSteps: number): void;
  55315. /**
  55316. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55317. * @returns the current timestep in seconds
  55318. */
  55319. getTimeStep(): number;
  55320. /**
  55321. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55322. */
  55323. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55324. private _isImpostorInContact;
  55325. private _isImpostorPairInContact;
  55326. private _stepSimulation;
  55327. /**
  55328. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55329. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55330. * After the step the babylon meshes are set to the position of the physics imposters
  55331. * @param delta amount of time to step forward
  55332. * @param impostors array of imposters to update before/after the step
  55333. */
  55334. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55335. /**
  55336. * Update babylon mesh to match physics world object
  55337. * @param impostor imposter to match
  55338. */
  55339. private _afterSoftStep;
  55340. /**
  55341. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55342. * @param impostor imposter to match
  55343. */
  55344. private _ropeStep;
  55345. /**
  55346. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55347. * @param impostor imposter to match
  55348. */
  55349. private _softbodyOrClothStep;
  55350. private _tmpVector;
  55351. private _tmpMatrix;
  55352. /**
  55353. * Applies an impulse on the imposter
  55354. * @param impostor imposter to apply impulse to
  55355. * @param force amount of force to be applied to the imposter
  55356. * @param contactPoint the location to apply the impulse on the imposter
  55357. */
  55358. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55359. /**
  55360. * Applies a force on the imposter
  55361. * @param impostor imposter to apply force
  55362. * @param force amount of force to be applied to the imposter
  55363. * @param contactPoint the location to apply the force on the imposter
  55364. */
  55365. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55366. /**
  55367. * Creates a physics body using the plugin
  55368. * @param impostor the imposter to create the physics body on
  55369. */
  55370. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55371. /**
  55372. * Removes the physics body from the imposter and disposes of the body's memory
  55373. * @param impostor imposter to remove the physics body from
  55374. */
  55375. removePhysicsBody(impostor: PhysicsImpostor): void;
  55376. /**
  55377. * Generates a joint
  55378. * @param impostorJoint the imposter joint to create the joint with
  55379. */
  55380. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55381. /**
  55382. * Removes a joint
  55383. * @param impostorJoint the imposter joint to remove the joint from
  55384. */
  55385. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55386. private _addMeshVerts;
  55387. /**
  55388. * Initialise the soft body vertices to match its object's (mesh) vertices
  55389. * Softbody vertices (nodes) are in world space and to match this
  55390. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55391. * @param impostor to create the softbody for
  55392. */
  55393. private _softVertexData;
  55394. /**
  55395. * Create an impostor's soft body
  55396. * @param impostor to create the softbody for
  55397. */
  55398. private _createSoftbody;
  55399. /**
  55400. * Create cloth for an impostor
  55401. * @param impostor to create the softbody for
  55402. */
  55403. private _createCloth;
  55404. /**
  55405. * Create rope for an impostor
  55406. * @param impostor to create the softbody for
  55407. */
  55408. private _createRope;
  55409. /**
  55410. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55411. * @param impostor to create the custom physics shape for
  55412. */
  55413. private _createCustom;
  55414. private _addHullVerts;
  55415. private _createShape;
  55416. /**
  55417. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55418. * @param impostor imposter containing the physics body and babylon object
  55419. */
  55420. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55421. /**
  55422. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55423. * @param impostor imposter containing the physics body and babylon object
  55424. * @param newPosition new position
  55425. * @param newRotation new rotation
  55426. */
  55427. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55428. /**
  55429. * If this plugin is supported
  55430. * @returns true if its supported
  55431. */
  55432. isSupported(): boolean;
  55433. /**
  55434. * Sets the linear velocity of the physics body
  55435. * @param impostor imposter to set the velocity on
  55436. * @param velocity velocity to set
  55437. */
  55438. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55439. /**
  55440. * Sets the angular velocity of the physics body
  55441. * @param impostor imposter to set the velocity on
  55442. * @param velocity velocity to set
  55443. */
  55444. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55445. /**
  55446. * gets the linear velocity
  55447. * @param impostor imposter to get linear velocity from
  55448. * @returns linear velocity
  55449. */
  55450. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55451. /**
  55452. * gets the angular velocity
  55453. * @param impostor imposter to get angular velocity from
  55454. * @returns angular velocity
  55455. */
  55456. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55457. /**
  55458. * Sets the mass of physics body
  55459. * @param impostor imposter to set the mass on
  55460. * @param mass mass to set
  55461. */
  55462. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55463. /**
  55464. * Gets the mass of the physics body
  55465. * @param impostor imposter to get the mass from
  55466. * @returns mass
  55467. */
  55468. getBodyMass(impostor: PhysicsImpostor): number;
  55469. /**
  55470. * Gets friction of the impostor
  55471. * @param impostor impostor to get friction from
  55472. * @returns friction value
  55473. */
  55474. getBodyFriction(impostor: PhysicsImpostor): number;
  55475. /**
  55476. * Sets friction of the impostor
  55477. * @param impostor impostor to set friction on
  55478. * @param friction friction value
  55479. */
  55480. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55481. /**
  55482. * Gets restitution of the impostor
  55483. * @param impostor impostor to get restitution from
  55484. * @returns restitution value
  55485. */
  55486. getBodyRestitution(impostor: PhysicsImpostor): number;
  55487. /**
  55488. * Sets resitution of the impostor
  55489. * @param impostor impostor to set resitution on
  55490. * @param restitution resitution value
  55491. */
  55492. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55493. /**
  55494. * Gets pressure inside the impostor
  55495. * @param impostor impostor to get pressure from
  55496. * @returns pressure value
  55497. */
  55498. getBodyPressure(impostor: PhysicsImpostor): number;
  55499. /**
  55500. * Sets pressure inside a soft body impostor
  55501. * Cloth and rope must remain 0 pressure
  55502. * @param impostor impostor to set pressure on
  55503. * @param pressure pressure value
  55504. */
  55505. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55506. /**
  55507. * Gets stiffness of the impostor
  55508. * @param impostor impostor to get stiffness from
  55509. * @returns pressure value
  55510. */
  55511. getBodyStiffness(impostor: PhysicsImpostor): number;
  55512. /**
  55513. * Sets stiffness of the impostor
  55514. * @param impostor impostor to set stiffness on
  55515. * @param stiffness stiffness value from 0 to 1
  55516. */
  55517. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55518. /**
  55519. * Gets velocityIterations of the impostor
  55520. * @param impostor impostor to get velocity iterations from
  55521. * @returns velocityIterations value
  55522. */
  55523. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55524. /**
  55525. * Sets velocityIterations of the impostor
  55526. * @param impostor impostor to set velocity iterations on
  55527. * @param velocityIterations velocityIterations value
  55528. */
  55529. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55530. /**
  55531. * Gets positionIterations of the impostor
  55532. * @param impostor impostor to get position iterations from
  55533. * @returns positionIterations value
  55534. */
  55535. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55536. /**
  55537. * Sets positionIterations of the impostor
  55538. * @param impostor impostor to set position on
  55539. * @param positionIterations positionIterations value
  55540. */
  55541. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55542. /**
  55543. * Append an anchor to a cloth object
  55544. * @param impostor is the cloth impostor to add anchor to
  55545. * @param otherImpostor is the rigid impostor to anchor to
  55546. * @param width ratio across width from 0 to 1
  55547. * @param height ratio up height from 0 to 1
  55548. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55549. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55550. */
  55551. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55552. /**
  55553. * Append an hook to a rope object
  55554. * @param impostor is the rope impostor to add hook to
  55555. * @param otherImpostor is the rigid impostor to hook to
  55556. * @param length ratio along the rope from 0 to 1
  55557. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55558. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55559. */
  55560. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55561. /**
  55562. * Sleeps the physics body and stops it from being active
  55563. * @param impostor impostor to sleep
  55564. */
  55565. sleepBody(impostor: PhysicsImpostor): void;
  55566. /**
  55567. * Activates the physics body
  55568. * @param impostor impostor to activate
  55569. */
  55570. wakeUpBody(impostor: PhysicsImpostor): void;
  55571. /**
  55572. * Updates the distance parameters of the joint
  55573. * @param joint joint to update
  55574. * @param maxDistance maximum distance of the joint
  55575. * @param minDistance minimum distance of the joint
  55576. */
  55577. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55578. /**
  55579. * Sets a motor on the joint
  55580. * @param joint joint to set motor on
  55581. * @param speed speed of the motor
  55582. * @param maxForce maximum force of the motor
  55583. * @param motorIndex index of the motor
  55584. */
  55585. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55586. /**
  55587. * Sets the motors limit
  55588. * @param joint joint to set limit on
  55589. * @param upperLimit upper limit
  55590. * @param lowerLimit lower limit
  55591. */
  55592. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55593. /**
  55594. * Syncs the position and rotation of a mesh with the impostor
  55595. * @param mesh mesh to sync
  55596. * @param impostor impostor to update the mesh with
  55597. */
  55598. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55599. /**
  55600. * Gets the radius of the impostor
  55601. * @param impostor impostor to get radius from
  55602. * @returns the radius
  55603. */
  55604. getRadius(impostor: PhysicsImpostor): number;
  55605. /**
  55606. * Gets the box size of the impostor
  55607. * @param impostor impostor to get box size from
  55608. * @param result the resulting box size
  55609. */
  55610. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55611. /**
  55612. * Disposes of the impostor
  55613. */
  55614. dispose(): void;
  55615. /**
  55616. * Does a raycast in the physics world
  55617. * @param from when should the ray start?
  55618. * @param to when should the ray end?
  55619. * @returns PhysicsRaycastResult
  55620. */
  55621. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55622. }
  55623. }
  55624. declare module BABYLON {
  55625. interface AbstractScene {
  55626. /**
  55627. * The list of reflection probes added to the scene
  55628. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55629. */
  55630. reflectionProbes: Array<ReflectionProbe>;
  55631. /**
  55632. * Removes the given reflection probe from this scene.
  55633. * @param toRemove The reflection probe to remove
  55634. * @returns The index of the removed reflection probe
  55635. */
  55636. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55637. /**
  55638. * Adds the given reflection probe to this scene.
  55639. * @param newReflectionProbe The reflection probe to add
  55640. */
  55641. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55642. }
  55643. /**
  55644. * Class used to generate realtime reflection / refraction cube textures
  55645. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55646. */
  55647. export class ReflectionProbe {
  55648. /** defines the name of the probe */
  55649. name: string;
  55650. private _scene;
  55651. private _renderTargetTexture;
  55652. private _projectionMatrix;
  55653. private _viewMatrix;
  55654. private _target;
  55655. private _add;
  55656. private _attachedMesh;
  55657. private _invertYAxis;
  55658. /** Gets or sets probe position (center of the cube map) */
  55659. position: Vector3;
  55660. /**
  55661. * Creates a new reflection probe
  55662. * @param name defines the name of the probe
  55663. * @param size defines the texture resolution (for each face)
  55664. * @param scene defines the hosting scene
  55665. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55666. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55667. */
  55668. constructor(
  55669. /** defines the name of the probe */
  55670. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55671. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55672. get samples(): number;
  55673. set samples(value: number);
  55674. /** Gets or sets the refresh rate to use (on every frame by default) */
  55675. get refreshRate(): number;
  55676. set refreshRate(value: number);
  55677. /**
  55678. * Gets the hosting scene
  55679. * @returns a Scene
  55680. */
  55681. getScene(): Scene;
  55682. /** Gets the internal CubeTexture used to render to */
  55683. get cubeTexture(): RenderTargetTexture;
  55684. /** Gets the list of meshes to render */
  55685. get renderList(): Nullable<AbstractMesh[]>;
  55686. /**
  55687. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55688. * @param mesh defines the mesh to attach to
  55689. */
  55690. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55691. /**
  55692. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55693. * @param renderingGroupId The rendering group id corresponding to its index
  55694. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55695. */
  55696. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55697. /**
  55698. * Clean all associated resources
  55699. */
  55700. dispose(): void;
  55701. /**
  55702. * Converts the reflection probe information to a readable string for debug purpose.
  55703. * @param fullDetails Supports for multiple levels of logging within scene loading
  55704. * @returns the human readable reflection probe info
  55705. */
  55706. toString(fullDetails?: boolean): string;
  55707. /**
  55708. * Get the class name of the relfection probe.
  55709. * @returns "ReflectionProbe"
  55710. */
  55711. getClassName(): string;
  55712. /**
  55713. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55714. * @returns The JSON representation of the texture
  55715. */
  55716. serialize(): any;
  55717. /**
  55718. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55719. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55720. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55721. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55722. * @returns The parsed reflection probe if successful
  55723. */
  55724. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55725. }
  55726. }
  55727. declare module BABYLON {
  55728. /** @hidden */
  55729. export var _BabylonLoaderRegistered: boolean;
  55730. /**
  55731. * Helps setting up some configuration for the babylon file loader.
  55732. */
  55733. export class BabylonFileLoaderConfiguration {
  55734. /**
  55735. * The loader does not allow injecting custom physix engine into the plugins.
  55736. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55737. * So you could set this variable to your engine import to make it work.
  55738. */
  55739. static LoaderInjectedPhysicsEngine: any;
  55740. }
  55741. }
  55742. declare module BABYLON {
  55743. /**
  55744. * The Physically based simple base material of BJS.
  55745. *
  55746. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55747. * It is used as the base class for both the specGloss and metalRough conventions.
  55748. */
  55749. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55750. /**
  55751. * Number of Simultaneous lights allowed on the material.
  55752. */
  55753. maxSimultaneousLights: number;
  55754. /**
  55755. * If sets to true, disables all the lights affecting the material.
  55756. */
  55757. disableLighting: boolean;
  55758. /**
  55759. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55760. */
  55761. environmentTexture: BaseTexture;
  55762. /**
  55763. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55764. */
  55765. invertNormalMapX: boolean;
  55766. /**
  55767. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55768. */
  55769. invertNormalMapY: boolean;
  55770. /**
  55771. * Normal map used in the model.
  55772. */
  55773. normalTexture: BaseTexture;
  55774. /**
  55775. * Emissivie color used to self-illuminate the model.
  55776. */
  55777. emissiveColor: Color3;
  55778. /**
  55779. * Emissivie texture used to self-illuminate the model.
  55780. */
  55781. emissiveTexture: BaseTexture;
  55782. /**
  55783. * Occlusion Channel Strenght.
  55784. */
  55785. occlusionStrength: number;
  55786. /**
  55787. * Occlusion Texture of the material (adding extra occlusion effects).
  55788. */
  55789. occlusionTexture: BaseTexture;
  55790. /**
  55791. * Defines the alpha limits in alpha test mode.
  55792. */
  55793. alphaCutOff: number;
  55794. /**
  55795. * Gets the current double sided mode.
  55796. */
  55797. get doubleSided(): boolean;
  55798. /**
  55799. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55800. */
  55801. set doubleSided(value: boolean);
  55802. /**
  55803. * Stores the pre-calculated light information of a mesh in a texture.
  55804. */
  55805. lightmapTexture: BaseTexture;
  55806. /**
  55807. * If true, the light map contains occlusion information instead of lighting info.
  55808. */
  55809. useLightmapAsShadowmap: boolean;
  55810. /**
  55811. * Instantiates a new PBRMaterial instance.
  55812. *
  55813. * @param name The material name
  55814. * @param scene The scene the material will be use in.
  55815. */
  55816. constructor(name: string, scene: Scene);
  55817. getClassName(): string;
  55818. }
  55819. }
  55820. declare module BABYLON {
  55821. /**
  55822. * The PBR material of BJS following the metal roughness convention.
  55823. *
  55824. * This fits to the PBR convention in the GLTF definition:
  55825. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55826. */
  55827. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55828. /**
  55829. * The base color has two different interpretations depending on the value of metalness.
  55830. * When the material is a metal, the base color is the specific measured reflectance value
  55831. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55832. * of the material.
  55833. */
  55834. baseColor: Color3;
  55835. /**
  55836. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55837. * well as opacity information in the alpha channel.
  55838. */
  55839. baseTexture: BaseTexture;
  55840. /**
  55841. * Specifies the metallic scalar value of the material.
  55842. * Can also be used to scale the metalness values of the metallic texture.
  55843. */
  55844. metallic: number;
  55845. /**
  55846. * Specifies the roughness scalar value of the material.
  55847. * Can also be used to scale the roughness values of the metallic texture.
  55848. */
  55849. roughness: number;
  55850. /**
  55851. * Texture containing both the metallic value in the B channel and the
  55852. * roughness value in the G channel to keep better precision.
  55853. */
  55854. metallicRoughnessTexture: BaseTexture;
  55855. /**
  55856. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55857. *
  55858. * @param name The material name
  55859. * @param scene The scene the material will be use in.
  55860. */
  55861. constructor(name: string, scene: Scene);
  55862. /**
  55863. * Return the currrent class name of the material.
  55864. */
  55865. getClassName(): string;
  55866. /**
  55867. * Makes a duplicate of the current material.
  55868. * @param name - name to use for the new material.
  55869. */
  55870. clone(name: string): PBRMetallicRoughnessMaterial;
  55871. /**
  55872. * Serialize the material to a parsable JSON object.
  55873. */
  55874. serialize(): any;
  55875. /**
  55876. * Parses a JSON object correponding to the serialize function.
  55877. */
  55878. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55879. }
  55880. }
  55881. declare module BABYLON {
  55882. /**
  55883. * The PBR material of BJS following the specular glossiness convention.
  55884. *
  55885. * This fits to the PBR convention in the GLTF definition:
  55886. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55887. */
  55888. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55889. /**
  55890. * Specifies the diffuse color of the material.
  55891. */
  55892. diffuseColor: Color3;
  55893. /**
  55894. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55895. * channel.
  55896. */
  55897. diffuseTexture: BaseTexture;
  55898. /**
  55899. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55900. */
  55901. specularColor: Color3;
  55902. /**
  55903. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55904. */
  55905. glossiness: number;
  55906. /**
  55907. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55908. */
  55909. specularGlossinessTexture: BaseTexture;
  55910. /**
  55911. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55912. *
  55913. * @param name The material name
  55914. * @param scene The scene the material will be use in.
  55915. */
  55916. constructor(name: string, scene: Scene);
  55917. /**
  55918. * Return the currrent class name of the material.
  55919. */
  55920. getClassName(): string;
  55921. /**
  55922. * Makes a duplicate of the current material.
  55923. * @param name - name to use for the new material.
  55924. */
  55925. clone(name: string): PBRSpecularGlossinessMaterial;
  55926. /**
  55927. * Serialize the material to a parsable JSON object.
  55928. */
  55929. serialize(): any;
  55930. /**
  55931. * Parses a JSON object correponding to the serialize function.
  55932. */
  55933. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55934. }
  55935. }
  55936. declare module BABYLON {
  55937. /**
  55938. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55939. * It can help converting any input color in a desired output one. This can then be used to create effects
  55940. * from sepia, black and white to sixties or futuristic rendering...
  55941. *
  55942. * The only supported format is currently 3dl.
  55943. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55944. */
  55945. export class ColorGradingTexture extends BaseTexture {
  55946. /**
  55947. * The current texture matrix. (will always be identity in color grading texture)
  55948. */
  55949. private _textureMatrix;
  55950. /**
  55951. * The texture URL.
  55952. */
  55953. url: string;
  55954. /**
  55955. * Empty line regex stored for GC.
  55956. */
  55957. private static _noneEmptyLineRegex;
  55958. private _engine;
  55959. /**
  55960. * Instantiates a ColorGradingTexture from the following parameters.
  55961. *
  55962. * @param url The location of the color gradind data (currently only supporting 3dl)
  55963. * @param scene The scene the texture will be used in
  55964. */
  55965. constructor(url: string, scene: Scene);
  55966. /**
  55967. * Returns the texture matrix used in most of the material.
  55968. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55969. */
  55970. getTextureMatrix(): Matrix;
  55971. /**
  55972. * Occurs when the file being loaded is a .3dl LUT file.
  55973. */
  55974. private load3dlTexture;
  55975. /**
  55976. * Starts the loading process of the texture.
  55977. */
  55978. private loadTexture;
  55979. /**
  55980. * Clones the color gradind texture.
  55981. */
  55982. clone(): ColorGradingTexture;
  55983. /**
  55984. * Called during delayed load for textures.
  55985. */
  55986. delayLoad(): void;
  55987. /**
  55988. * Parses a color grading texture serialized by Babylon.
  55989. * @param parsedTexture The texture information being parsedTexture
  55990. * @param scene The scene to load the texture in
  55991. * @param rootUrl The root url of the data assets to load
  55992. * @return A color gradind texture
  55993. */
  55994. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55995. /**
  55996. * Serializes the LUT texture to json format.
  55997. */
  55998. serialize(): any;
  55999. }
  56000. }
  56001. declare module BABYLON {
  56002. /**
  56003. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56004. */
  56005. export class EquiRectangularCubeTexture extends BaseTexture {
  56006. /** The six faces of the cube. */
  56007. private static _FacesMapping;
  56008. private _noMipmap;
  56009. private _onLoad;
  56010. private _onError;
  56011. /** The size of the cubemap. */
  56012. private _size;
  56013. /** The buffer of the image. */
  56014. private _buffer;
  56015. /** The width of the input image. */
  56016. private _width;
  56017. /** The height of the input image. */
  56018. private _height;
  56019. /** The URL to the image. */
  56020. url: string;
  56021. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56022. coordinatesMode: number;
  56023. /**
  56024. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56025. * @param url The location of the image
  56026. * @param scene The scene the texture will be used in
  56027. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56028. * @param noMipmap Forces to not generate the mipmap if true
  56029. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56030. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56031. * @param onLoad — defines a callback called when texture is loaded
  56032. * @param onError — defines a callback called if there is an error
  56033. */
  56034. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56035. /**
  56036. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56037. */
  56038. private loadImage;
  56039. /**
  56040. * Convert the image buffer into a cubemap and create a CubeTexture.
  56041. */
  56042. private loadTexture;
  56043. /**
  56044. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56045. * @param buffer The ArrayBuffer that should be converted.
  56046. * @returns The buffer as Float32Array.
  56047. */
  56048. private getFloat32ArrayFromArrayBuffer;
  56049. /**
  56050. * Get the current class name of the texture useful for serialization or dynamic coding.
  56051. * @returns "EquiRectangularCubeTexture"
  56052. */
  56053. getClassName(): string;
  56054. /**
  56055. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56056. * @returns A clone of the current EquiRectangularCubeTexture.
  56057. */
  56058. clone(): EquiRectangularCubeTexture;
  56059. }
  56060. }
  56061. declare module BABYLON {
  56062. /**
  56063. * Based on jsTGALoader - Javascript loader for TGA file
  56064. * By Vincent Thibault
  56065. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56066. */
  56067. export class TGATools {
  56068. private static _TYPE_INDEXED;
  56069. private static _TYPE_RGB;
  56070. private static _TYPE_GREY;
  56071. private static _TYPE_RLE_INDEXED;
  56072. private static _TYPE_RLE_RGB;
  56073. private static _TYPE_RLE_GREY;
  56074. private static _ORIGIN_MASK;
  56075. private static _ORIGIN_SHIFT;
  56076. private static _ORIGIN_BL;
  56077. private static _ORIGIN_BR;
  56078. private static _ORIGIN_UL;
  56079. private static _ORIGIN_UR;
  56080. /**
  56081. * Gets the header of a TGA file
  56082. * @param data defines the TGA data
  56083. * @returns the header
  56084. */
  56085. static GetTGAHeader(data: Uint8Array): any;
  56086. /**
  56087. * Uploads TGA content to a Babylon Texture
  56088. * @hidden
  56089. */
  56090. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56091. /** @hidden */
  56092. 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;
  56093. /** @hidden */
  56094. 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;
  56095. /** @hidden */
  56096. 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;
  56097. /** @hidden */
  56098. 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;
  56099. /** @hidden */
  56100. 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;
  56101. /** @hidden */
  56102. 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;
  56103. }
  56104. }
  56105. declare module BABYLON {
  56106. /**
  56107. * Implementation of the TGA Texture Loader.
  56108. * @hidden
  56109. */
  56110. export class _TGATextureLoader implements IInternalTextureLoader {
  56111. /**
  56112. * Defines wether the loader supports cascade loading the different faces.
  56113. */
  56114. readonly supportCascades: boolean;
  56115. /**
  56116. * This returns if the loader support the current file information.
  56117. * @param extension defines the file extension of the file being loaded
  56118. * @returns true if the loader can load the specified file
  56119. */
  56120. canLoad(extension: string): boolean;
  56121. /**
  56122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56123. * @param data contains the texture data
  56124. * @param texture defines the BabylonJS internal texture
  56125. * @param createPolynomials will be true if polynomials have been requested
  56126. * @param onLoad defines the callback to trigger once the texture is ready
  56127. * @param onError defines the callback to trigger in case of error
  56128. */
  56129. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56130. /**
  56131. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56132. * @param data contains the texture data
  56133. * @param texture defines the BabylonJS internal texture
  56134. * @param callback defines the method to call once ready to upload
  56135. */
  56136. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56137. }
  56138. }
  56139. declare module BABYLON {
  56140. /**
  56141. * Info about the .basis files
  56142. */
  56143. class BasisFileInfo {
  56144. /**
  56145. * If the file has alpha
  56146. */
  56147. hasAlpha: boolean;
  56148. /**
  56149. * Info about each image of the basis file
  56150. */
  56151. images: Array<{
  56152. levels: Array<{
  56153. width: number;
  56154. height: number;
  56155. transcodedPixels: ArrayBufferView;
  56156. }>;
  56157. }>;
  56158. }
  56159. /**
  56160. * Result of transcoding a basis file
  56161. */
  56162. class TranscodeResult {
  56163. /**
  56164. * Info about the .basis file
  56165. */
  56166. fileInfo: BasisFileInfo;
  56167. /**
  56168. * Format to use when loading the file
  56169. */
  56170. format: number;
  56171. }
  56172. /**
  56173. * Configuration options for the Basis transcoder
  56174. */
  56175. export class BasisTranscodeConfiguration {
  56176. /**
  56177. * Supported compression formats used to determine the supported output format of the transcoder
  56178. */
  56179. supportedCompressionFormats?: {
  56180. /**
  56181. * etc1 compression format
  56182. */
  56183. etc1?: boolean;
  56184. /**
  56185. * s3tc compression format
  56186. */
  56187. s3tc?: boolean;
  56188. /**
  56189. * pvrtc compression format
  56190. */
  56191. pvrtc?: boolean;
  56192. /**
  56193. * etc2 compression format
  56194. */
  56195. etc2?: boolean;
  56196. };
  56197. /**
  56198. * If mipmap levels should be loaded for transcoded images (Default: true)
  56199. */
  56200. loadMipmapLevels?: boolean;
  56201. /**
  56202. * Index of a single image to load (Default: all images)
  56203. */
  56204. loadSingleImage?: number;
  56205. }
  56206. /**
  56207. * Used to load .Basis files
  56208. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56209. */
  56210. export class BasisTools {
  56211. private static _IgnoreSupportedFormats;
  56212. /**
  56213. * URL to use when loading the basis transcoder
  56214. */
  56215. static JSModuleURL: string;
  56216. /**
  56217. * URL to use when loading the wasm module for the transcoder
  56218. */
  56219. static WasmModuleURL: string;
  56220. /**
  56221. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56222. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56223. * @returns internal format corresponding to the Basis format
  56224. */
  56225. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56226. private static _WorkerPromise;
  56227. private static _Worker;
  56228. private static _actionId;
  56229. private static _CreateWorkerAsync;
  56230. /**
  56231. * Transcodes a loaded image file to compressed pixel data
  56232. * @param data image data to transcode
  56233. * @param config configuration options for the transcoding
  56234. * @returns a promise resulting in the transcoded image
  56235. */
  56236. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56237. /**
  56238. * Loads a texture from the transcode result
  56239. * @param texture texture load to
  56240. * @param transcodeResult the result of transcoding the basis file to load from
  56241. */
  56242. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56243. }
  56244. }
  56245. declare module BABYLON {
  56246. /**
  56247. * Loader for .basis file format
  56248. */
  56249. export class _BasisTextureLoader implements IInternalTextureLoader {
  56250. /**
  56251. * Defines whether the loader supports cascade loading the different faces.
  56252. */
  56253. readonly supportCascades: boolean;
  56254. /**
  56255. * This returns if the loader support the current file information.
  56256. * @param extension defines the file extension of the file being loaded
  56257. * @returns true if the loader can load the specified file
  56258. */
  56259. canLoad(extension: string): boolean;
  56260. /**
  56261. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56262. * @param data contains the texture data
  56263. * @param texture defines the BabylonJS internal texture
  56264. * @param createPolynomials will be true if polynomials have been requested
  56265. * @param onLoad defines the callback to trigger once the texture is ready
  56266. * @param onError defines the callback to trigger in case of error
  56267. */
  56268. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56269. /**
  56270. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56271. * @param data contains the texture data
  56272. * @param texture defines the BabylonJS internal texture
  56273. * @param callback defines the method to call once ready to upload
  56274. */
  56275. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56276. }
  56277. }
  56278. declare module BABYLON {
  56279. /**
  56280. * 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.
  56281. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56282. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56283. */
  56284. export class CustomProceduralTexture extends ProceduralTexture {
  56285. private _animate;
  56286. private _time;
  56287. private _config;
  56288. private _texturePath;
  56289. /**
  56290. * Instantiates a new Custom Procedural Texture.
  56291. * 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.
  56292. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56293. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56294. * @param name Define the name of the texture
  56295. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56296. * @param size Define the size of the texture to create
  56297. * @param scene Define the scene the texture belongs to
  56298. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56299. * @param generateMipMaps Define if the texture should creates mip maps or not
  56300. */
  56301. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56302. private _loadJson;
  56303. /**
  56304. * Is the texture ready to be used ? (rendered at least once)
  56305. * @returns true if ready, otherwise, false.
  56306. */
  56307. isReady(): boolean;
  56308. /**
  56309. * Render the texture to its associated render target.
  56310. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56311. */
  56312. render(useCameraPostProcess?: boolean): void;
  56313. /**
  56314. * Update the list of dependant textures samplers in the shader.
  56315. */
  56316. updateTextures(): void;
  56317. /**
  56318. * Update the uniform values of the procedural texture in the shader.
  56319. */
  56320. updateShaderUniforms(): void;
  56321. /**
  56322. * Define if the texture animates or not.
  56323. */
  56324. get animate(): boolean;
  56325. set animate(value: boolean);
  56326. }
  56327. }
  56328. declare module BABYLON {
  56329. /** @hidden */
  56330. export var noisePixelShader: {
  56331. name: string;
  56332. shader: string;
  56333. };
  56334. }
  56335. declare module BABYLON {
  56336. /**
  56337. * Class used to generate noise procedural textures
  56338. */
  56339. export class NoiseProceduralTexture extends ProceduralTexture {
  56340. private _time;
  56341. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56342. brightness: number;
  56343. /** Defines the number of octaves to process */
  56344. octaves: number;
  56345. /** Defines the level of persistence (0.8 by default) */
  56346. persistence: number;
  56347. /** Gets or sets animation speed factor (default is 1) */
  56348. animationSpeedFactor: number;
  56349. /**
  56350. * Creates a new NoiseProceduralTexture
  56351. * @param name defines the name fo the texture
  56352. * @param size defines the size of the texture (default is 256)
  56353. * @param scene defines the hosting scene
  56354. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56355. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56356. */
  56357. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56358. private _updateShaderUniforms;
  56359. protected _getDefines(): string;
  56360. /** Generate the current state of the procedural texture */
  56361. render(useCameraPostProcess?: boolean): void;
  56362. /**
  56363. * Serializes this noise procedural texture
  56364. * @returns a serialized noise procedural texture object
  56365. */
  56366. serialize(): any;
  56367. /**
  56368. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56369. * @param parsedTexture defines parsed texture data
  56370. * @param scene defines the current scene
  56371. * @param rootUrl defines the root URL containing noise procedural texture information
  56372. * @returns a parsed NoiseProceduralTexture
  56373. */
  56374. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56375. }
  56376. }
  56377. declare module BABYLON {
  56378. /**
  56379. * Raw cube texture where the raw buffers are passed in
  56380. */
  56381. export class RawCubeTexture extends CubeTexture {
  56382. /**
  56383. * Creates a cube texture where the raw buffers are passed in.
  56384. * @param scene defines the scene the texture is attached to
  56385. * @param data defines the array of data to use to create each face
  56386. * @param size defines the size of the textures
  56387. * @param format defines the format of the data
  56388. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56389. * @param generateMipMaps defines if the engine should generate the mip levels
  56390. * @param invertY defines if data must be stored with Y axis inverted
  56391. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56392. * @param compression defines the compression used (null by default)
  56393. */
  56394. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56395. /**
  56396. * Updates the raw cube texture.
  56397. * @param data defines the data to store
  56398. * @param format defines the data format
  56399. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56400. * @param invertY defines if data must be stored with Y axis inverted
  56401. * @param compression defines the compression used (null by default)
  56402. * @param level defines which level of the texture to update
  56403. */
  56404. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56405. /**
  56406. * Updates a raw cube texture with RGBD encoded data.
  56407. * @param data defines the array of data [mipmap][face] to use to create each face
  56408. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56409. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56410. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56411. * @returns a promsie that resolves when the operation is complete
  56412. */
  56413. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56414. /**
  56415. * Clones the raw cube texture.
  56416. * @return a new cube texture
  56417. */
  56418. clone(): CubeTexture;
  56419. /** @hidden */
  56420. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56421. }
  56422. }
  56423. declare module BABYLON {
  56424. /**
  56425. * Class used to store 3D textures containing user data
  56426. */
  56427. export class RawTexture3D extends Texture {
  56428. /** Gets or sets the texture format to use */
  56429. format: number;
  56430. private _engine;
  56431. /**
  56432. * Create a new RawTexture3D
  56433. * @param data defines the data of the texture
  56434. * @param width defines the width of the texture
  56435. * @param height defines the height of the texture
  56436. * @param depth defines the depth of the texture
  56437. * @param format defines the texture format to use
  56438. * @param scene defines the hosting scene
  56439. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56440. * @param invertY defines if texture must be stored with Y axis inverted
  56441. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56442. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56443. */
  56444. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56445. /** Gets or sets the texture format to use */
  56446. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56447. /**
  56448. * Update the texture with new data
  56449. * @param data defines the data to store in the texture
  56450. */
  56451. update(data: ArrayBufferView): void;
  56452. }
  56453. }
  56454. declare module BABYLON {
  56455. /**
  56456. * Class used to store 2D array textures containing user data
  56457. */
  56458. export class RawTexture2DArray extends Texture {
  56459. /** Gets or sets the texture format to use */
  56460. format: number;
  56461. private _engine;
  56462. /**
  56463. * Create a new RawTexture2DArray
  56464. * @param data defines the data of the texture
  56465. * @param width defines the width of the texture
  56466. * @param height defines the height of the texture
  56467. * @param depth defines the number of layers of the texture
  56468. * @param format defines the texture format to use
  56469. * @param scene defines the hosting scene
  56470. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56471. * @param invertY defines if texture must be stored with Y axis inverted
  56472. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56473. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56474. */
  56475. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56476. /** Gets or sets the texture format to use */
  56477. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56478. /**
  56479. * Update the texture with new data
  56480. * @param data defines the data to store in the texture
  56481. */
  56482. update(data: ArrayBufferView): void;
  56483. }
  56484. }
  56485. declare module BABYLON {
  56486. /**
  56487. * Creates a refraction texture used by refraction channel of the standard material.
  56488. * It is like a mirror but to see through a material.
  56489. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56490. */
  56491. export class RefractionTexture extends RenderTargetTexture {
  56492. /**
  56493. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56494. * 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.
  56495. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56496. */
  56497. refractionPlane: Plane;
  56498. /**
  56499. * Define how deep under the surface we should see.
  56500. */
  56501. depth: number;
  56502. /**
  56503. * Creates a refraction texture used by refraction channel of the standard material.
  56504. * It is like a mirror but to see through a material.
  56505. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56506. * @param name Define the texture name
  56507. * @param size Define the size of the underlying texture
  56508. * @param scene Define the scene the refraction belongs to
  56509. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56510. */
  56511. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56512. /**
  56513. * Clone the refraction texture.
  56514. * @returns the cloned texture
  56515. */
  56516. clone(): RefractionTexture;
  56517. /**
  56518. * Serialize the texture to a JSON representation you could use in Parse later on
  56519. * @returns the serialized JSON representation
  56520. */
  56521. serialize(): any;
  56522. }
  56523. }
  56524. declare module BABYLON {
  56525. /**
  56526. * Defines the options related to the creation of an HtmlElementTexture
  56527. */
  56528. export interface IHtmlElementTextureOptions {
  56529. /**
  56530. * Defines wether mip maps should be created or not.
  56531. */
  56532. generateMipMaps?: boolean;
  56533. /**
  56534. * Defines the sampling mode of the texture.
  56535. */
  56536. samplingMode?: number;
  56537. /**
  56538. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56539. */
  56540. engine: Nullable<ThinEngine>;
  56541. /**
  56542. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56543. */
  56544. scene: Nullable<Scene>;
  56545. }
  56546. /**
  56547. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56548. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56549. * is automatically managed.
  56550. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56551. * in your application.
  56552. *
  56553. * As the update is not automatic, you need to call them manually.
  56554. */
  56555. export class HtmlElementTexture extends BaseTexture {
  56556. /**
  56557. * The texture URL.
  56558. */
  56559. element: HTMLVideoElement | HTMLCanvasElement;
  56560. private static readonly DefaultOptions;
  56561. private _textureMatrix;
  56562. private _engine;
  56563. private _isVideo;
  56564. private _generateMipMaps;
  56565. private _samplingMode;
  56566. /**
  56567. * Instantiates a HtmlElementTexture from the following parameters.
  56568. *
  56569. * @param name Defines the name of the texture
  56570. * @param element Defines the video or canvas the texture is filled with
  56571. * @param options Defines the other none mandatory texture creation options
  56572. */
  56573. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56574. private _createInternalTexture;
  56575. /**
  56576. * Returns the texture matrix used in most of the material.
  56577. */
  56578. getTextureMatrix(): Matrix;
  56579. /**
  56580. * Updates the content of the texture.
  56581. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56582. */
  56583. update(invertY?: Nullable<boolean>): void;
  56584. }
  56585. }
  56586. declare module BABYLON {
  56587. /**
  56588. * Defines the basic options interface of a TexturePacker Frame
  56589. */
  56590. export interface ITexturePackerFrame {
  56591. /**
  56592. * The frame ID
  56593. */
  56594. id: number;
  56595. /**
  56596. * The frames Scale
  56597. */
  56598. scale: Vector2;
  56599. /**
  56600. * The Frames offset
  56601. */
  56602. offset: Vector2;
  56603. }
  56604. /**
  56605. * This is a support class for frame Data on texture packer sets.
  56606. */
  56607. export class TexturePackerFrame implements ITexturePackerFrame {
  56608. /**
  56609. * The frame ID
  56610. */
  56611. id: number;
  56612. /**
  56613. * The frames Scale
  56614. */
  56615. scale: Vector2;
  56616. /**
  56617. * The Frames offset
  56618. */
  56619. offset: Vector2;
  56620. /**
  56621. * Initializes a texture package frame.
  56622. * @param id The numerical frame identifier
  56623. * @param scale Scalar Vector2 for UV frame
  56624. * @param offset Vector2 for the frame position in UV units.
  56625. * @returns TexturePackerFrame
  56626. */
  56627. constructor(id: number, scale: Vector2, offset: Vector2);
  56628. }
  56629. }
  56630. declare module BABYLON {
  56631. /**
  56632. * Defines the basic options interface of a TexturePacker
  56633. */
  56634. export interface ITexturePackerOptions {
  56635. /**
  56636. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56637. */
  56638. map?: string[];
  56639. /**
  56640. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56641. */
  56642. uvsIn?: string;
  56643. /**
  56644. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56645. */
  56646. uvsOut?: string;
  56647. /**
  56648. * number representing the layout style. Defaults to LAYOUT_STRIP
  56649. */
  56650. layout?: number;
  56651. /**
  56652. * number of columns if using custom column count layout(2). This defaults to 4.
  56653. */
  56654. colnum?: number;
  56655. /**
  56656. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56657. */
  56658. updateInputMeshes?: boolean;
  56659. /**
  56660. * boolean flag to dispose all the source textures. Defaults to true.
  56661. */
  56662. disposeSources?: boolean;
  56663. /**
  56664. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56665. */
  56666. fillBlanks?: boolean;
  56667. /**
  56668. * string value representing the context fill style color. Defaults to 'black'.
  56669. */
  56670. customFillColor?: string;
  56671. /**
  56672. * Width and Height Value of each Frame in the TexturePacker Sets
  56673. */
  56674. frameSize?: number;
  56675. /**
  56676. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56677. */
  56678. paddingRatio?: number;
  56679. /**
  56680. * Number that declares the fill method for the padding gutter.
  56681. */
  56682. paddingMode?: number;
  56683. /**
  56684. * If in SUBUV_COLOR padding mode what color to use.
  56685. */
  56686. paddingColor?: Color3 | Color4;
  56687. }
  56688. /**
  56689. * Defines the basic interface of a TexturePacker JSON File
  56690. */
  56691. export interface ITexturePackerJSON {
  56692. /**
  56693. * The frame ID
  56694. */
  56695. name: string;
  56696. /**
  56697. * The base64 channel data
  56698. */
  56699. sets: any;
  56700. /**
  56701. * The options of the Packer
  56702. */
  56703. options: ITexturePackerOptions;
  56704. /**
  56705. * The frame data of the Packer
  56706. */
  56707. frames: Array<number>;
  56708. }
  56709. /**
  56710. * This is a support class that generates a series of packed texture sets.
  56711. * @see https://doc.babylonjs.com/babylon101/materials
  56712. */
  56713. export class TexturePacker {
  56714. /** Packer Layout Constant 0 */
  56715. static readonly LAYOUT_STRIP: number;
  56716. /** Packer Layout Constant 1 */
  56717. static readonly LAYOUT_POWER2: number;
  56718. /** Packer Layout Constant 2 */
  56719. static readonly LAYOUT_COLNUM: number;
  56720. /** Packer Layout Constant 0 */
  56721. static readonly SUBUV_WRAP: number;
  56722. /** Packer Layout Constant 1 */
  56723. static readonly SUBUV_EXTEND: number;
  56724. /** Packer Layout Constant 2 */
  56725. static readonly SUBUV_COLOR: number;
  56726. /** The Name of the Texture Package */
  56727. name: string;
  56728. /** The scene scope of the TexturePacker */
  56729. scene: Scene;
  56730. /** The Meshes to target */
  56731. meshes: AbstractMesh[];
  56732. /** Arguments passed with the Constructor */
  56733. options: ITexturePackerOptions;
  56734. /** The promise that is started upon initialization */
  56735. promise: Nullable<Promise<TexturePacker | string>>;
  56736. /** The Container object for the channel sets that are generated */
  56737. sets: object;
  56738. /** The Container array for the frames that are generated */
  56739. frames: TexturePackerFrame[];
  56740. /** The expected number of textures the system is parsing. */
  56741. private _expecting;
  56742. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56743. private _paddingValue;
  56744. /**
  56745. * Initializes a texture package series from an array of meshes or a single mesh.
  56746. * @param name The name of the package
  56747. * @param meshes The target meshes to compose the package from
  56748. * @param options The arguments that texture packer should follow while building.
  56749. * @param scene The scene which the textures are scoped to.
  56750. * @returns TexturePacker
  56751. */
  56752. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56753. /**
  56754. * Starts the package process
  56755. * @param resolve The promises resolution function
  56756. * @returns TexturePacker
  56757. */
  56758. private _createFrames;
  56759. /**
  56760. * Calculates the Size of the Channel Sets
  56761. * @returns Vector2
  56762. */
  56763. private _calculateSize;
  56764. /**
  56765. * Calculates the UV data for the frames.
  56766. * @param baseSize the base frameSize
  56767. * @param padding the base frame padding
  56768. * @param dtSize size of the Dynamic Texture for that channel
  56769. * @param dtUnits is 1/dtSize
  56770. * @param update flag to update the input meshes
  56771. */
  56772. private _calculateMeshUVFrames;
  56773. /**
  56774. * Calculates the frames Offset.
  56775. * @param index of the frame
  56776. * @returns Vector2
  56777. */
  56778. private _getFrameOffset;
  56779. /**
  56780. * Updates a Mesh to the frame data
  56781. * @param mesh that is the target
  56782. * @param frameID or the frame index
  56783. */
  56784. private _updateMeshUV;
  56785. /**
  56786. * Updates a Meshes materials to use the texture packer channels
  56787. * @param m is the mesh to target
  56788. * @param force all channels on the packer to be set.
  56789. */
  56790. private _updateTextureReferences;
  56791. /**
  56792. * Public method to set a Mesh to a frame
  56793. * @param m that is the target
  56794. * @param frameID or the frame index
  56795. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56796. */
  56797. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56798. /**
  56799. * Starts the async promise to compile the texture packer.
  56800. * @returns Promise<void>
  56801. */
  56802. processAsync(): Promise<void>;
  56803. /**
  56804. * Disposes all textures associated with this packer
  56805. */
  56806. dispose(): void;
  56807. /**
  56808. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56809. * @param imageType is the image type to use.
  56810. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56811. */
  56812. download(imageType?: string, quality?: number): void;
  56813. /**
  56814. * Public method to load a texturePacker JSON file.
  56815. * @param data of the JSON file in string format.
  56816. */
  56817. updateFromJSON(data: string): void;
  56818. }
  56819. }
  56820. declare module BABYLON {
  56821. /**
  56822. * Enum used to define the target of a block
  56823. */
  56824. export enum NodeMaterialBlockTargets {
  56825. /** Vertex shader */
  56826. Vertex = 1,
  56827. /** Fragment shader */
  56828. Fragment = 2,
  56829. /** Neutral */
  56830. Neutral = 4,
  56831. /** Vertex and Fragment */
  56832. VertexAndFragment = 3
  56833. }
  56834. }
  56835. declare module BABYLON {
  56836. /**
  56837. * Defines the kind of connection point for node based material
  56838. */
  56839. export enum NodeMaterialBlockConnectionPointTypes {
  56840. /** Float */
  56841. Float = 1,
  56842. /** Int */
  56843. Int = 2,
  56844. /** Vector2 */
  56845. Vector2 = 4,
  56846. /** Vector3 */
  56847. Vector3 = 8,
  56848. /** Vector4 */
  56849. Vector4 = 16,
  56850. /** Color3 */
  56851. Color3 = 32,
  56852. /** Color4 */
  56853. Color4 = 64,
  56854. /** Matrix */
  56855. Matrix = 128,
  56856. /** Detect type based on connection */
  56857. AutoDetect = 1024,
  56858. /** Output type that will be defined by input type */
  56859. BasedOnInput = 2048
  56860. }
  56861. }
  56862. declare module BABYLON {
  56863. /**
  56864. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56865. */
  56866. export enum NodeMaterialBlockConnectionPointMode {
  56867. /** Value is an uniform */
  56868. Uniform = 0,
  56869. /** Value is a mesh attribute */
  56870. Attribute = 1,
  56871. /** Value is a varying between vertex and fragment shaders */
  56872. Varying = 2,
  56873. /** Mode is undefined */
  56874. Undefined = 3
  56875. }
  56876. }
  56877. declare module BABYLON {
  56878. /**
  56879. * Enum used to define system values e.g. values automatically provided by the system
  56880. */
  56881. export enum NodeMaterialSystemValues {
  56882. /** World */
  56883. World = 1,
  56884. /** View */
  56885. View = 2,
  56886. /** Projection */
  56887. Projection = 3,
  56888. /** ViewProjection */
  56889. ViewProjection = 4,
  56890. /** WorldView */
  56891. WorldView = 5,
  56892. /** WorldViewProjection */
  56893. WorldViewProjection = 6,
  56894. /** CameraPosition */
  56895. CameraPosition = 7,
  56896. /** Fog Color */
  56897. FogColor = 8,
  56898. /** Delta time */
  56899. DeltaTime = 9
  56900. }
  56901. }
  56902. declare module BABYLON {
  56903. /**
  56904. * Root class for all node material optimizers
  56905. */
  56906. export class NodeMaterialOptimizer {
  56907. /**
  56908. * Function used to optimize a NodeMaterial graph
  56909. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56910. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56911. */
  56912. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56913. }
  56914. }
  56915. declare module BABYLON {
  56916. /**
  56917. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56918. */
  56919. export class TransformBlock extends NodeMaterialBlock {
  56920. /**
  56921. * Defines the value to use to complement W value to transform it to a Vector4
  56922. */
  56923. complementW: number;
  56924. /**
  56925. * Defines the value to use to complement z value to transform it to a Vector4
  56926. */
  56927. complementZ: number;
  56928. /**
  56929. * Creates a new TransformBlock
  56930. * @param name defines the block name
  56931. */
  56932. constructor(name: string);
  56933. /**
  56934. * Gets the current class name
  56935. * @returns the class name
  56936. */
  56937. getClassName(): string;
  56938. /**
  56939. * Gets the vector input
  56940. */
  56941. get vector(): NodeMaterialConnectionPoint;
  56942. /**
  56943. * Gets the output component
  56944. */
  56945. get output(): NodeMaterialConnectionPoint;
  56946. /**
  56947. * Gets the xyz output component
  56948. */
  56949. get xyz(): NodeMaterialConnectionPoint;
  56950. /**
  56951. * Gets the matrix transform input
  56952. */
  56953. get transform(): NodeMaterialConnectionPoint;
  56954. protected _buildBlock(state: NodeMaterialBuildState): this;
  56955. serialize(): any;
  56956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56957. protected _dumpPropertiesCode(): string;
  56958. }
  56959. }
  56960. declare module BABYLON {
  56961. /**
  56962. * Block used to output the vertex position
  56963. */
  56964. export class VertexOutputBlock extends NodeMaterialBlock {
  56965. /**
  56966. * Creates a new VertexOutputBlock
  56967. * @param name defines the block name
  56968. */
  56969. constructor(name: string);
  56970. /**
  56971. * Gets the current class name
  56972. * @returns the class name
  56973. */
  56974. getClassName(): string;
  56975. /**
  56976. * Gets the vector input component
  56977. */
  56978. get vector(): NodeMaterialConnectionPoint;
  56979. protected _buildBlock(state: NodeMaterialBuildState): this;
  56980. }
  56981. }
  56982. declare module BABYLON {
  56983. /**
  56984. * Block used to output the final color
  56985. */
  56986. export class FragmentOutputBlock extends NodeMaterialBlock {
  56987. /**
  56988. * Create a new FragmentOutputBlock
  56989. * @param name defines the block name
  56990. */
  56991. constructor(name: string);
  56992. /**
  56993. * Gets the current class name
  56994. * @returns the class name
  56995. */
  56996. getClassName(): string;
  56997. /**
  56998. * Gets the rgba input component
  56999. */
  57000. get rgba(): NodeMaterialConnectionPoint;
  57001. /**
  57002. * Gets the rgb input component
  57003. */
  57004. get rgb(): NodeMaterialConnectionPoint;
  57005. /**
  57006. * Gets the a input component
  57007. */
  57008. get a(): NodeMaterialConnectionPoint;
  57009. protected _buildBlock(state: NodeMaterialBuildState): this;
  57010. }
  57011. }
  57012. declare module BABYLON {
  57013. /**
  57014. * Block used to read a reflection texture from a sampler
  57015. */
  57016. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57017. private _define3DName;
  57018. private _defineCubicName;
  57019. private _defineExplicitName;
  57020. private _defineProjectionName;
  57021. private _defineLocalCubicName;
  57022. private _defineSphericalName;
  57023. private _definePlanarName;
  57024. private _defineEquirectangularName;
  57025. private _defineMirroredEquirectangularFixedName;
  57026. private _defineEquirectangularFixedName;
  57027. private _defineSkyboxName;
  57028. private _cubeSamplerName;
  57029. private _2DSamplerName;
  57030. private _positionUVWName;
  57031. private _directionWName;
  57032. private _reflectionCoordsName;
  57033. private _reflection2DCoordsName;
  57034. private _reflectionColorName;
  57035. private _reflectionMatrixName;
  57036. /**
  57037. * Gets or sets the texture associated with the node
  57038. */
  57039. texture: Nullable<BaseTexture>;
  57040. /**
  57041. * Create a new TextureBlock
  57042. * @param name defines the block name
  57043. */
  57044. constructor(name: string);
  57045. /**
  57046. * Gets the current class name
  57047. * @returns the class name
  57048. */
  57049. getClassName(): string;
  57050. /**
  57051. * Gets the world position input component
  57052. */
  57053. get position(): NodeMaterialConnectionPoint;
  57054. /**
  57055. * Gets the world position input component
  57056. */
  57057. get worldPosition(): NodeMaterialConnectionPoint;
  57058. /**
  57059. * Gets the world normal input component
  57060. */
  57061. get worldNormal(): NodeMaterialConnectionPoint;
  57062. /**
  57063. * Gets the world input component
  57064. */
  57065. get world(): NodeMaterialConnectionPoint;
  57066. /**
  57067. * Gets the camera (or eye) position component
  57068. */
  57069. get cameraPosition(): NodeMaterialConnectionPoint;
  57070. /**
  57071. * Gets the view input component
  57072. */
  57073. get view(): NodeMaterialConnectionPoint;
  57074. /**
  57075. * Gets the rgb output component
  57076. */
  57077. get rgb(): NodeMaterialConnectionPoint;
  57078. /**
  57079. * Gets the r output component
  57080. */
  57081. get r(): NodeMaterialConnectionPoint;
  57082. /**
  57083. * Gets the g output component
  57084. */
  57085. get g(): NodeMaterialConnectionPoint;
  57086. /**
  57087. * Gets the b output component
  57088. */
  57089. get b(): NodeMaterialConnectionPoint;
  57090. autoConfigure(material: NodeMaterial): void;
  57091. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57092. isReady(): boolean;
  57093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57094. private _injectVertexCode;
  57095. private _writeOutput;
  57096. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57097. protected _dumpPropertiesCode(): string;
  57098. serialize(): any;
  57099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57100. }
  57101. }
  57102. declare module BABYLON {
  57103. /**
  57104. * Interface used to configure the node material editor
  57105. */
  57106. export interface INodeMaterialEditorOptions {
  57107. /** Define the URl to load node editor script */
  57108. editorURL?: string;
  57109. }
  57110. /** @hidden */
  57111. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57112. NORMAL: boolean;
  57113. TANGENT: boolean;
  57114. UV1: boolean;
  57115. /** BONES */
  57116. NUM_BONE_INFLUENCERS: number;
  57117. BonesPerMesh: number;
  57118. BONETEXTURE: boolean;
  57119. /** MORPH TARGETS */
  57120. MORPHTARGETS: boolean;
  57121. MORPHTARGETS_NORMAL: boolean;
  57122. MORPHTARGETS_TANGENT: boolean;
  57123. MORPHTARGETS_UV: boolean;
  57124. NUM_MORPH_INFLUENCERS: number;
  57125. /** IMAGE PROCESSING */
  57126. IMAGEPROCESSING: boolean;
  57127. VIGNETTE: boolean;
  57128. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57129. VIGNETTEBLENDMODEOPAQUE: boolean;
  57130. TONEMAPPING: boolean;
  57131. TONEMAPPING_ACES: boolean;
  57132. CONTRAST: boolean;
  57133. EXPOSURE: boolean;
  57134. COLORCURVES: boolean;
  57135. COLORGRADING: boolean;
  57136. COLORGRADING3D: boolean;
  57137. SAMPLER3DGREENDEPTH: boolean;
  57138. SAMPLER3DBGRMAP: boolean;
  57139. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57140. /** MISC. */
  57141. BUMPDIRECTUV: number;
  57142. constructor();
  57143. setValue(name: string, value: boolean): void;
  57144. }
  57145. /**
  57146. * Class used to configure NodeMaterial
  57147. */
  57148. export interface INodeMaterialOptions {
  57149. /**
  57150. * Defines if blocks should emit comments
  57151. */
  57152. emitComments: boolean;
  57153. }
  57154. /**
  57155. * Class used to create a node based material built by assembling shader blocks
  57156. */
  57157. export class NodeMaterial extends PushMaterial {
  57158. private static _BuildIdGenerator;
  57159. private _options;
  57160. private _vertexCompilationState;
  57161. private _fragmentCompilationState;
  57162. private _sharedData;
  57163. private _buildId;
  57164. private _buildWasSuccessful;
  57165. private _cachedWorldViewMatrix;
  57166. private _cachedWorldViewProjectionMatrix;
  57167. private _optimizers;
  57168. private _animationFrame;
  57169. /** Define the Url to load node editor script */
  57170. static EditorURL: string;
  57171. /** Define the Url to load snippets */
  57172. static SnippetUrl: string;
  57173. private BJSNODEMATERIALEDITOR;
  57174. /** Get the inspector from bundle or global */
  57175. private _getGlobalNodeMaterialEditor;
  57176. /**
  57177. * Gets or sets data used by visual editor
  57178. * @see https://nme.babylonjs.com
  57179. */
  57180. editorData: any;
  57181. /**
  57182. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  57183. */
  57184. ignoreAlpha: boolean;
  57185. /**
  57186. * Defines the maximum number of lights that can be used in the material
  57187. */
  57188. maxSimultaneousLights: number;
  57189. /**
  57190. * Observable raised when the material is built
  57191. */
  57192. onBuildObservable: Observable<NodeMaterial>;
  57193. /**
  57194. * Gets or sets the root nodes of the material vertex shader
  57195. */
  57196. _vertexOutputNodes: NodeMaterialBlock[];
  57197. /**
  57198. * Gets or sets the root nodes of the material fragment (pixel) shader
  57199. */
  57200. _fragmentOutputNodes: NodeMaterialBlock[];
  57201. /** Gets or sets options to control the node material overall behavior */
  57202. get options(): INodeMaterialOptions;
  57203. set options(options: INodeMaterialOptions);
  57204. /**
  57205. * Default configuration related to image processing available in the standard Material.
  57206. */
  57207. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57208. /**
  57209. * Gets the image processing configuration used either in this material.
  57210. */
  57211. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57212. /**
  57213. * Sets the Default image processing configuration used either in the this material.
  57214. *
  57215. * If sets to null, the scene one is in use.
  57216. */
  57217. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57218. /**
  57219. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57220. */
  57221. attachedBlocks: NodeMaterialBlock[];
  57222. /**
  57223. * Create a new node based material
  57224. * @param name defines the material name
  57225. * @param scene defines the hosting scene
  57226. * @param options defines creation option
  57227. */
  57228. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57229. /**
  57230. * Gets the current class name of the material e.g. "NodeMaterial"
  57231. * @returns the class name
  57232. */
  57233. getClassName(): string;
  57234. /**
  57235. * Keep track of the image processing observer to allow dispose and replace.
  57236. */
  57237. private _imageProcessingObserver;
  57238. /**
  57239. * Attaches a new image processing configuration to the Standard Material.
  57240. * @param configuration
  57241. */
  57242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57243. /**
  57244. * Get a block by its name
  57245. * @param name defines the name of the block to retrieve
  57246. * @returns the required block or null if not found
  57247. */
  57248. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57249. /**
  57250. * Get a block by its name
  57251. * @param predicate defines the predicate used to find the good candidate
  57252. * @returns the required block or null if not found
  57253. */
  57254. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57255. /**
  57256. * Get an input block by its name
  57257. * @param predicate defines the predicate used to find the good candidate
  57258. * @returns the required input block or null if not found
  57259. */
  57260. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57261. /**
  57262. * Gets the list of input blocks attached to this material
  57263. * @returns an array of InputBlocks
  57264. */
  57265. getInputBlocks(): InputBlock[];
  57266. /**
  57267. * Adds a new optimizer to the list of optimizers
  57268. * @param optimizer defines the optimizers to add
  57269. * @returns the current material
  57270. */
  57271. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57272. /**
  57273. * Remove an optimizer from the list of optimizers
  57274. * @param optimizer defines the optimizers to remove
  57275. * @returns the current material
  57276. */
  57277. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57278. /**
  57279. * Add a new block to the list of output nodes
  57280. * @param node defines the node to add
  57281. * @returns the current material
  57282. */
  57283. addOutputNode(node: NodeMaterialBlock): this;
  57284. /**
  57285. * Remove a block from the list of root nodes
  57286. * @param node defines the node to remove
  57287. * @returns the current material
  57288. */
  57289. removeOutputNode(node: NodeMaterialBlock): this;
  57290. private _addVertexOutputNode;
  57291. private _removeVertexOutputNode;
  57292. private _addFragmentOutputNode;
  57293. private _removeFragmentOutputNode;
  57294. /**
  57295. * Specifies if the material will require alpha blending
  57296. * @returns a boolean specifying if alpha blending is needed
  57297. */
  57298. needAlphaBlending(): boolean;
  57299. /**
  57300. * Specifies if this material should be rendered in alpha test mode
  57301. * @returns a boolean specifying if an alpha test is needed.
  57302. */
  57303. needAlphaTesting(): boolean;
  57304. private _initializeBlock;
  57305. private _resetDualBlocks;
  57306. /**
  57307. * Remove a block from the current node material
  57308. * @param block defines the block to remove
  57309. */
  57310. removeBlock(block: NodeMaterialBlock): void;
  57311. /**
  57312. * Build the material and generates the inner effect
  57313. * @param verbose defines if the build should log activity
  57314. */
  57315. build(verbose?: boolean): void;
  57316. /**
  57317. * Runs an otpimization phase to try to improve the shader code
  57318. */
  57319. optimize(): void;
  57320. private _prepareDefinesForAttributes;
  57321. /**
  57322. * Get if the submesh is ready to be used and all its information available.
  57323. * Child classes can use it to update shaders
  57324. * @param mesh defines the mesh to check
  57325. * @param subMesh defines which submesh to check
  57326. * @param useInstances specifies that instances should be used
  57327. * @returns a boolean indicating that the submesh is ready or not
  57328. */
  57329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57330. /**
  57331. * Get a string representing the shaders built by the current node graph
  57332. */
  57333. get compiledShaders(): string;
  57334. /**
  57335. * Binds the world matrix to the material
  57336. * @param world defines the world transformation matrix
  57337. */
  57338. bindOnlyWorldMatrix(world: Matrix): void;
  57339. /**
  57340. * Binds the submesh to this material by preparing the effect and shader to draw
  57341. * @param world defines the world transformation matrix
  57342. * @param mesh defines the mesh containing the submesh
  57343. * @param subMesh defines the submesh to bind the material to
  57344. */
  57345. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57346. /**
  57347. * Gets the active textures from the material
  57348. * @returns an array of textures
  57349. */
  57350. getActiveTextures(): BaseTexture[];
  57351. /**
  57352. * Gets the list of texture blocks
  57353. * @returns an array of texture blocks
  57354. */
  57355. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57356. /**
  57357. * Specifies if the material uses a texture
  57358. * @param texture defines the texture to check against the material
  57359. * @returns a boolean specifying if the material uses the texture
  57360. */
  57361. hasTexture(texture: BaseTexture): boolean;
  57362. /**
  57363. * Disposes the material
  57364. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57365. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57366. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57367. */
  57368. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57369. /** Creates the node editor window. */
  57370. private _createNodeEditor;
  57371. /**
  57372. * Launch the node material editor
  57373. * @param config Define the configuration of the editor
  57374. * @return a promise fulfilled when the node editor is visible
  57375. */
  57376. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57377. /**
  57378. * Clear the current material
  57379. */
  57380. clear(): void;
  57381. /**
  57382. * Clear the current material and set it to a default state
  57383. */
  57384. setToDefault(): void;
  57385. /**
  57386. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57387. * @param url defines the url to load from
  57388. * @returns a promise that will fullfil when the material is fully loaded
  57389. */
  57390. loadAsync(url: string): Promise<void>;
  57391. private _gatherBlocks;
  57392. /**
  57393. * Generate a string containing the code declaration required to create an equivalent of this material
  57394. * @returns a string
  57395. */
  57396. generateCode(): string;
  57397. /**
  57398. * Serializes this material in a JSON representation
  57399. * @returns the serialized material object
  57400. */
  57401. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57402. private _restoreConnections;
  57403. /**
  57404. * Clear the current graph and load a new one from a serialization object
  57405. * @param source defines the JSON representation of the material
  57406. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57407. */
  57408. loadFromSerialization(source: any, rootUrl?: string): void;
  57409. /**
  57410. * Creates a node material from parsed material data
  57411. * @param source defines the JSON representation of the material
  57412. * @param scene defines the hosting scene
  57413. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57414. * @returns a new node material
  57415. */
  57416. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57417. /**
  57418. * Creates a node material from a snippet saved in a remote file
  57419. * @param name defines the name of the material to create
  57420. * @param url defines the url to load from
  57421. * @param scene defines the hosting scene
  57422. * @returns a promise that will resolve to the new node material
  57423. */
  57424. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57425. /**
  57426. * Creates a node material from a snippet saved by the node material editor
  57427. * @param snippetId defines the snippet to load
  57428. * @param scene defines the hosting scene
  57429. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57430. * @returns a promise that will resolve to the new node material
  57431. */
  57432. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57433. /**
  57434. * Creates a new node material set to default basic configuration
  57435. * @param name defines the name of the material
  57436. * @param scene defines the hosting scene
  57437. * @returns a new NodeMaterial
  57438. */
  57439. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57440. }
  57441. }
  57442. declare module BABYLON {
  57443. /**
  57444. * Block used to read a texture from a sampler
  57445. */
  57446. export class TextureBlock extends NodeMaterialBlock {
  57447. private _defineName;
  57448. private _linearDefineName;
  57449. private _tempTextureRead;
  57450. private _samplerName;
  57451. private _transformedUVName;
  57452. private _textureTransformName;
  57453. private _textureInfoName;
  57454. private _mainUVName;
  57455. private _mainUVDefineName;
  57456. /**
  57457. * Gets or sets the texture associated with the node
  57458. */
  57459. texture: Nullable<Texture>;
  57460. /**
  57461. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57462. */
  57463. convertToGammaSpace: boolean;
  57464. /**
  57465. * Create a new TextureBlock
  57466. * @param name defines the block name
  57467. */
  57468. constructor(name: string);
  57469. /**
  57470. * Gets the current class name
  57471. * @returns the class name
  57472. */
  57473. getClassName(): string;
  57474. /**
  57475. * Gets the uv input component
  57476. */
  57477. get uv(): NodeMaterialConnectionPoint;
  57478. /**
  57479. * Gets the rgba output component
  57480. */
  57481. get rgba(): NodeMaterialConnectionPoint;
  57482. /**
  57483. * Gets the rgb output component
  57484. */
  57485. get rgb(): NodeMaterialConnectionPoint;
  57486. /**
  57487. * Gets the r output component
  57488. */
  57489. get r(): NodeMaterialConnectionPoint;
  57490. /**
  57491. * Gets the g output component
  57492. */
  57493. get g(): NodeMaterialConnectionPoint;
  57494. /**
  57495. * Gets the b output component
  57496. */
  57497. get b(): NodeMaterialConnectionPoint;
  57498. /**
  57499. * Gets the a output component
  57500. */
  57501. get a(): NodeMaterialConnectionPoint;
  57502. get target(): NodeMaterialBlockTargets;
  57503. autoConfigure(material: NodeMaterial): void;
  57504. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57506. isReady(): boolean;
  57507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57508. private get _isMixed();
  57509. private _injectVertexCode;
  57510. private _writeTextureRead;
  57511. private _writeOutput;
  57512. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57513. protected _dumpPropertiesCode(): string;
  57514. serialize(): any;
  57515. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57516. }
  57517. }
  57518. declare module BABYLON {
  57519. /**
  57520. * Class used to store shared data between 2 NodeMaterialBuildState
  57521. */
  57522. export class NodeMaterialBuildStateSharedData {
  57523. /**
  57524. * Gets the list of emitted varyings
  57525. */
  57526. temps: string[];
  57527. /**
  57528. * Gets the list of emitted varyings
  57529. */
  57530. varyings: string[];
  57531. /**
  57532. * Gets the varying declaration string
  57533. */
  57534. varyingDeclaration: string;
  57535. /**
  57536. * Input blocks
  57537. */
  57538. inputBlocks: InputBlock[];
  57539. /**
  57540. * Input blocks
  57541. */
  57542. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57543. /**
  57544. * Bindable blocks (Blocks that need to set data to the effect)
  57545. */
  57546. bindableBlocks: NodeMaterialBlock[];
  57547. /**
  57548. * List of blocks that can provide a compilation fallback
  57549. */
  57550. blocksWithFallbacks: NodeMaterialBlock[];
  57551. /**
  57552. * List of blocks that can provide a define update
  57553. */
  57554. blocksWithDefines: NodeMaterialBlock[];
  57555. /**
  57556. * List of blocks that can provide a repeatable content
  57557. */
  57558. repeatableContentBlocks: NodeMaterialBlock[];
  57559. /**
  57560. * List of blocks that can provide a dynamic list of uniforms
  57561. */
  57562. dynamicUniformBlocks: NodeMaterialBlock[];
  57563. /**
  57564. * List of blocks that can block the isReady function for the material
  57565. */
  57566. blockingBlocks: NodeMaterialBlock[];
  57567. /**
  57568. * Gets the list of animated inputs
  57569. */
  57570. animatedInputs: InputBlock[];
  57571. /**
  57572. * Build Id used to avoid multiple recompilations
  57573. */
  57574. buildId: number;
  57575. /** List of emitted variables */
  57576. variableNames: {
  57577. [key: string]: number;
  57578. };
  57579. /** List of emitted defines */
  57580. defineNames: {
  57581. [key: string]: number;
  57582. };
  57583. /** Should emit comments? */
  57584. emitComments: boolean;
  57585. /** Emit build activity */
  57586. verbose: boolean;
  57587. /** Gets or sets the hosting scene */
  57588. scene: Scene;
  57589. /**
  57590. * Gets the compilation hints emitted at compilation time
  57591. */
  57592. hints: {
  57593. needWorldViewMatrix: boolean;
  57594. needWorldViewProjectionMatrix: boolean;
  57595. needAlphaBlending: boolean;
  57596. needAlphaTesting: boolean;
  57597. };
  57598. /**
  57599. * List of compilation checks
  57600. */
  57601. checks: {
  57602. emitVertex: boolean;
  57603. emitFragment: boolean;
  57604. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57605. };
  57606. /** Creates a new shared data */
  57607. constructor();
  57608. /**
  57609. * Emits console errors and exceptions if there is a failing check
  57610. */
  57611. emitErrors(): void;
  57612. }
  57613. }
  57614. declare module BABYLON {
  57615. /**
  57616. * Class used to store node based material build state
  57617. */
  57618. export class NodeMaterialBuildState {
  57619. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57620. supportUniformBuffers: boolean;
  57621. /**
  57622. * Gets the list of emitted attributes
  57623. */
  57624. attributes: string[];
  57625. /**
  57626. * Gets the list of emitted uniforms
  57627. */
  57628. uniforms: string[];
  57629. /**
  57630. * Gets the list of emitted constants
  57631. */
  57632. constants: string[];
  57633. /**
  57634. * Gets the list of emitted samplers
  57635. */
  57636. samplers: string[];
  57637. /**
  57638. * Gets the list of emitted functions
  57639. */
  57640. functions: {
  57641. [key: string]: string;
  57642. };
  57643. /**
  57644. * Gets the list of emitted extensions
  57645. */
  57646. extensions: {
  57647. [key: string]: string;
  57648. };
  57649. /**
  57650. * Gets the target of the compilation state
  57651. */
  57652. target: NodeMaterialBlockTargets;
  57653. /**
  57654. * Gets the list of emitted counters
  57655. */
  57656. counters: {
  57657. [key: string]: number;
  57658. };
  57659. /**
  57660. * Shared data between multiple NodeMaterialBuildState instances
  57661. */
  57662. sharedData: NodeMaterialBuildStateSharedData;
  57663. /** @hidden */
  57664. _vertexState: NodeMaterialBuildState;
  57665. /** @hidden */
  57666. _attributeDeclaration: string;
  57667. /** @hidden */
  57668. _uniformDeclaration: string;
  57669. /** @hidden */
  57670. _constantDeclaration: string;
  57671. /** @hidden */
  57672. _samplerDeclaration: string;
  57673. /** @hidden */
  57674. _varyingTransfer: string;
  57675. private _repeatableContentAnchorIndex;
  57676. /** @hidden */
  57677. _builtCompilationString: string;
  57678. /**
  57679. * Gets the emitted compilation strings
  57680. */
  57681. compilationString: string;
  57682. /**
  57683. * Finalize the compilation strings
  57684. * @param state defines the current compilation state
  57685. */
  57686. finalize(state: NodeMaterialBuildState): void;
  57687. /** @hidden */
  57688. get _repeatableContentAnchor(): string;
  57689. /** @hidden */
  57690. _getFreeVariableName(prefix: string): string;
  57691. /** @hidden */
  57692. _getFreeDefineName(prefix: string): string;
  57693. /** @hidden */
  57694. _excludeVariableName(name: string): void;
  57695. /** @hidden */
  57696. _emit2DSampler(name: string): void;
  57697. /** @hidden */
  57698. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57699. /** @hidden */
  57700. _emitExtension(name: string, extension: string): void;
  57701. /** @hidden */
  57702. _emitFunction(name: string, code: string, comments: string): void;
  57703. /** @hidden */
  57704. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57705. replaceStrings?: {
  57706. search: RegExp;
  57707. replace: string;
  57708. }[];
  57709. repeatKey?: string;
  57710. }): string;
  57711. /** @hidden */
  57712. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57713. repeatKey?: string;
  57714. removeAttributes?: boolean;
  57715. removeUniforms?: boolean;
  57716. removeVaryings?: boolean;
  57717. removeIfDef?: boolean;
  57718. replaceStrings?: {
  57719. search: RegExp;
  57720. replace: string;
  57721. }[];
  57722. }, storeKey?: string): void;
  57723. /** @hidden */
  57724. _registerTempVariable(name: string): boolean;
  57725. /** @hidden */
  57726. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57727. /** @hidden */
  57728. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57729. /** @hidden */
  57730. _emitFloat(value: number): string;
  57731. }
  57732. }
  57733. declare module BABYLON {
  57734. /**
  57735. * Defines a block that can be used inside a node based material
  57736. */
  57737. export class NodeMaterialBlock {
  57738. private _buildId;
  57739. private _buildTarget;
  57740. private _target;
  57741. private _isFinalMerger;
  57742. private _isInput;
  57743. protected _isUnique: boolean;
  57744. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57745. inputsAreExclusive: boolean;
  57746. /** @hidden */
  57747. _codeVariableName: string;
  57748. /** @hidden */
  57749. _inputs: NodeMaterialConnectionPoint[];
  57750. /** @hidden */
  57751. _outputs: NodeMaterialConnectionPoint[];
  57752. /** @hidden */
  57753. _preparationId: number;
  57754. /**
  57755. * Gets or sets the name of the block
  57756. */
  57757. name: string;
  57758. /**
  57759. * Gets or sets the unique id of the node
  57760. */
  57761. uniqueId: number;
  57762. /**
  57763. * Gets or sets the comments associated with this block
  57764. */
  57765. comments: string;
  57766. /**
  57767. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57768. */
  57769. get isUnique(): boolean;
  57770. /**
  57771. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57772. */
  57773. get isFinalMerger(): boolean;
  57774. /**
  57775. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57776. */
  57777. get isInput(): boolean;
  57778. /**
  57779. * Gets or sets the build Id
  57780. */
  57781. get buildId(): number;
  57782. set buildId(value: number);
  57783. /**
  57784. * Gets or sets the target of the block
  57785. */
  57786. get target(): NodeMaterialBlockTargets;
  57787. set target(value: NodeMaterialBlockTargets);
  57788. /**
  57789. * Gets the list of input points
  57790. */
  57791. get inputs(): NodeMaterialConnectionPoint[];
  57792. /** Gets the list of output points */
  57793. get outputs(): NodeMaterialConnectionPoint[];
  57794. /**
  57795. * Find an input by its name
  57796. * @param name defines the name of the input to look for
  57797. * @returns the input or null if not found
  57798. */
  57799. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57800. /**
  57801. * Find an output by its name
  57802. * @param name defines the name of the outputto look for
  57803. * @returns the output or null if not found
  57804. */
  57805. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57806. /**
  57807. * Creates a new NodeMaterialBlock
  57808. * @param name defines the block name
  57809. * @param target defines the target of that block (Vertex by default)
  57810. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57811. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57812. */
  57813. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57814. /**
  57815. * Initialize the block and prepare the context for build
  57816. * @param state defines the state that will be used for the build
  57817. */
  57818. initialize(state: NodeMaterialBuildState): void;
  57819. /**
  57820. * Bind data to effect. Will only be called for blocks with isBindable === true
  57821. * @param effect defines the effect to bind data to
  57822. * @param nodeMaterial defines the hosting NodeMaterial
  57823. * @param mesh defines the mesh that will be rendered
  57824. */
  57825. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57826. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57827. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57828. protected _writeFloat(value: number): string;
  57829. /**
  57830. * Gets the current class name e.g. "NodeMaterialBlock"
  57831. * @returns the class name
  57832. */
  57833. getClassName(): string;
  57834. /**
  57835. * Register a new input. Must be called inside a block constructor
  57836. * @param name defines the connection point name
  57837. * @param type defines the connection point type
  57838. * @param isOptional defines a boolean indicating that this input can be omitted
  57839. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57840. * @returns the current block
  57841. */
  57842. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57843. /**
  57844. * Register a new output. Must be called inside a block constructor
  57845. * @param name defines the connection point name
  57846. * @param type defines the connection point type
  57847. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57848. * @returns the current block
  57849. */
  57850. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57851. /**
  57852. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57853. * @param forOutput defines an optional connection point to check compatibility with
  57854. * @returns the first available input or null
  57855. */
  57856. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57857. /**
  57858. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57859. * @param forBlock defines an optional block to check compatibility with
  57860. * @returns the first available input or null
  57861. */
  57862. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57863. /**
  57864. * Gets the sibling of the given output
  57865. * @param current defines the current output
  57866. * @returns the next output in the list or null
  57867. */
  57868. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57869. /**
  57870. * Connect current block with another block
  57871. * @param other defines the block to connect with
  57872. * @param options define the various options to help pick the right connections
  57873. * @returns the current block
  57874. */
  57875. connectTo(other: NodeMaterialBlock, options?: {
  57876. input?: string;
  57877. output?: string;
  57878. outputSwizzle?: string;
  57879. }): this | undefined;
  57880. protected _buildBlock(state: NodeMaterialBuildState): void;
  57881. /**
  57882. * Add uniforms, samplers and uniform buffers at compilation time
  57883. * @param state defines the state to update
  57884. * @param nodeMaterial defines the node material requesting the update
  57885. * @param defines defines the material defines to update
  57886. * @param uniformBuffers defines the list of uniform buffer names
  57887. */
  57888. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57889. /**
  57890. * Add potential fallbacks if shader compilation fails
  57891. * @param mesh defines the mesh to be rendered
  57892. * @param fallbacks defines the current prioritized list of fallbacks
  57893. */
  57894. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57895. /**
  57896. * Initialize defines for shader compilation
  57897. * @param mesh defines the mesh to be rendered
  57898. * @param nodeMaterial defines the node material requesting the update
  57899. * @param defines defines the material defines to update
  57900. * @param useInstances specifies that instances should be used
  57901. */
  57902. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57903. /**
  57904. * Update defines for shader compilation
  57905. * @param mesh defines the mesh to be rendered
  57906. * @param nodeMaterial defines the node material requesting the update
  57907. * @param defines defines the material defines to update
  57908. * @param useInstances specifies that instances should be used
  57909. */
  57910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57911. /**
  57912. * Lets the block try to connect some inputs automatically
  57913. * @param material defines the hosting NodeMaterial
  57914. */
  57915. autoConfigure(material: NodeMaterial): void;
  57916. /**
  57917. * Function called when a block is declared as repeatable content generator
  57918. * @param vertexShaderState defines the current compilation state for the vertex shader
  57919. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57920. * @param mesh defines the mesh to be rendered
  57921. * @param defines defines the material defines to update
  57922. */
  57923. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57924. /**
  57925. * Checks if the block is ready
  57926. * @param mesh defines the mesh to be rendered
  57927. * @param nodeMaterial defines the node material requesting the update
  57928. * @param defines defines the material defines to update
  57929. * @param useInstances specifies that instances should be used
  57930. * @returns true if the block is ready
  57931. */
  57932. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57933. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57934. private _processBuild;
  57935. /**
  57936. * Compile the current node and generate the shader code
  57937. * @param state defines the current compilation state (uniforms, samplers, current string)
  57938. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57939. * @returns true if already built
  57940. */
  57941. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57942. protected _inputRename(name: string): string;
  57943. protected _outputRename(name: string): string;
  57944. protected _dumpPropertiesCode(): string;
  57945. /** @hidden */
  57946. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57947. /** @hidden */
  57948. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57949. /**
  57950. * Clone the current block to a new identical block
  57951. * @param scene defines the hosting scene
  57952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57953. * @returns a copy of the current block
  57954. */
  57955. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57956. /**
  57957. * Serializes this block in a JSON representation
  57958. * @returns the serialized block object
  57959. */
  57960. serialize(): any;
  57961. /** @hidden */
  57962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57963. /**
  57964. * Release resources
  57965. */
  57966. dispose(): void;
  57967. }
  57968. }
  57969. declare module BABYLON {
  57970. /**
  57971. * Enum defining the type of animations supported by InputBlock
  57972. */
  57973. export enum AnimatedInputBlockTypes {
  57974. /** No animation */
  57975. None = 0,
  57976. /** Time based animation. Will only work for floats */
  57977. Time = 1
  57978. }
  57979. }
  57980. declare module BABYLON {
  57981. /**
  57982. * Block used to expose an input value
  57983. */
  57984. export class InputBlock extends NodeMaterialBlock {
  57985. private _mode;
  57986. private _associatedVariableName;
  57987. private _storedValue;
  57988. private _valueCallback;
  57989. private _type;
  57990. private _animationType;
  57991. /** Gets or set a value used to limit the range of float values */
  57992. min: number;
  57993. /** Gets or set a value used to limit the range of float values */
  57994. max: number;
  57995. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57996. isBoolean: boolean;
  57997. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57998. matrixMode: number;
  57999. /** @hidden */
  58000. _systemValue: Nullable<NodeMaterialSystemValues>;
  58001. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58002. visibleInInspector: boolean;
  58003. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58004. isConstant: boolean;
  58005. /** Gets or sets the group to use to display this block in the Inspector */
  58006. groupInInspector: string;
  58007. /** Gets an observable raised when the value is changed */
  58008. onValueChangedObservable: Observable<InputBlock>;
  58009. /**
  58010. * Gets or sets the connection point type (default is float)
  58011. */
  58012. get type(): NodeMaterialBlockConnectionPointTypes;
  58013. /**
  58014. * Creates a new InputBlock
  58015. * @param name defines the block name
  58016. * @param target defines the target of that block (Vertex by default)
  58017. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58018. */
  58019. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58020. /**
  58021. * Gets the output component
  58022. */
  58023. get output(): NodeMaterialConnectionPoint;
  58024. /**
  58025. * Set the source of this connection point to a vertex attribute
  58026. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58027. * @returns the current connection point
  58028. */
  58029. setAsAttribute(attributeName?: string): InputBlock;
  58030. /**
  58031. * Set the source of this connection point to a system value
  58032. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58033. * @returns the current connection point
  58034. */
  58035. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58036. /**
  58037. * Gets or sets the value of that point.
  58038. * Please note that this value will be ignored if valueCallback is defined
  58039. */
  58040. get value(): any;
  58041. set value(value: any);
  58042. /**
  58043. * Gets or sets a callback used to get the value of that point.
  58044. * Please note that setting this value will force the connection point to ignore the value property
  58045. */
  58046. get valueCallback(): () => any;
  58047. set valueCallback(value: () => any);
  58048. /**
  58049. * Gets or sets the associated variable name in the shader
  58050. */
  58051. get associatedVariableName(): string;
  58052. set associatedVariableName(value: string);
  58053. /** Gets or sets the type of animation applied to the input */
  58054. get animationType(): AnimatedInputBlockTypes;
  58055. set animationType(value: AnimatedInputBlockTypes);
  58056. /**
  58057. * Gets a boolean indicating that this connection point not defined yet
  58058. */
  58059. get isUndefined(): boolean;
  58060. /**
  58061. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58062. * In this case the connection point name must be the name of the uniform to use.
  58063. * Can only be set on inputs
  58064. */
  58065. get isUniform(): boolean;
  58066. set isUniform(value: boolean);
  58067. /**
  58068. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58069. * In this case the connection point name must be the name of the attribute to use
  58070. * Can only be set on inputs
  58071. */
  58072. get isAttribute(): boolean;
  58073. set isAttribute(value: boolean);
  58074. /**
  58075. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58076. * Can only be set on exit points
  58077. */
  58078. get isVarying(): boolean;
  58079. set isVarying(value: boolean);
  58080. /**
  58081. * Gets a boolean indicating that the current connection point is a system value
  58082. */
  58083. get isSystemValue(): boolean;
  58084. /**
  58085. * Gets or sets the current well known value or null if not defined as a system value
  58086. */
  58087. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58088. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58089. /**
  58090. * Gets the current class name
  58091. * @returns the class name
  58092. */
  58093. getClassName(): string;
  58094. /**
  58095. * Animate the input if animationType !== None
  58096. * @param scene defines the rendering scene
  58097. */
  58098. animate(scene: Scene): void;
  58099. private _emitDefine;
  58100. initialize(state: NodeMaterialBuildState): void;
  58101. /**
  58102. * Set the input block to its default value (based on its type)
  58103. */
  58104. setDefaultValue(): void;
  58105. private _emitConstant;
  58106. private _emit;
  58107. /** @hidden */
  58108. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58109. /** @hidden */
  58110. _transmit(effect: Effect, scene: Scene): void;
  58111. protected _buildBlock(state: NodeMaterialBuildState): void;
  58112. protected _dumpPropertiesCode(): string;
  58113. dispose(): void;
  58114. serialize(): any;
  58115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58116. }
  58117. }
  58118. declare module BABYLON {
  58119. /**
  58120. * Enum used to define the compatibility state between two connection points
  58121. */
  58122. export enum NodeMaterialConnectionPointCompatibilityStates {
  58123. /** Points are compatibles */
  58124. Compatible = 0,
  58125. /** Points are incompatible because of their types */
  58126. TypeIncompatible = 1,
  58127. /** Points are incompatible because of their targets (vertex vs fragment) */
  58128. TargetIncompatible = 2
  58129. }
  58130. /**
  58131. * Defines the direction of a connection point
  58132. */
  58133. export enum NodeMaterialConnectionPointDirection {
  58134. /** Input */
  58135. Input = 0,
  58136. /** Output */
  58137. Output = 1
  58138. }
  58139. /**
  58140. * Defines a connection point for a block
  58141. */
  58142. export class NodeMaterialConnectionPoint {
  58143. /** @hidden */
  58144. _ownerBlock: NodeMaterialBlock;
  58145. /** @hidden */
  58146. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58147. private _endpoints;
  58148. private _associatedVariableName;
  58149. private _direction;
  58150. /** @hidden */
  58151. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58152. /** @hidden */
  58153. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58154. private _type;
  58155. /** @hidden */
  58156. _enforceAssociatedVariableName: boolean;
  58157. /** Gets the direction of the point */
  58158. get direction(): NodeMaterialConnectionPointDirection;
  58159. /**
  58160. * Gets or sets the additional types supported by this connection point
  58161. */
  58162. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58163. /**
  58164. * Gets or sets the additional types excluded by this connection point
  58165. */
  58166. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58167. /**
  58168. * Observable triggered when this point is connected
  58169. */
  58170. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58171. /**
  58172. * Gets or sets the associated variable name in the shader
  58173. */
  58174. get associatedVariableName(): string;
  58175. set associatedVariableName(value: string);
  58176. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58177. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58178. /**
  58179. * Gets or sets the connection point type (default is float)
  58180. */
  58181. get type(): NodeMaterialBlockConnectionPointTypes;
  58182. set type(value: NodeMaterialBlockConnectionPointTypes);
  58183. /**
  58184. * Gets or sets the connection point name
  58185. */
  58186. name: string;
  58187. /**
  58188. * Gets or sets a boolean indicating that this connection point can be omitted
  58189. */
  58190. isOptional: boolean;
  58191. /**
  58192. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58193. */
  58194. define: string;
  58195. /** @hidden */
  58196. _prioritizeVertex: boolean;
  58197. private _target;
  58198. /** Gets or sets the target of that connection point */
  58199. get target(): NodeMaterialBlockTargets;
  58200. set target(value: NodeMaterialBlockTargets);
  58201. /**
  58202. * Gets a boolean indicating that the current point is connected
  58203. */
  58204. get isConnected(): boolean;
  58205. /**
  58206. * Gets a boolean indicating that the current point is connected to an input block
  58207. */
  58208. get isConnectedToInputBlock(): boolean;
  58209. /**
  58210. * Gets a the connected input block (if any)
  58211. */
  58212. get connectInputBlock(): Nullable<InputBlock>;
  58213. /** Get the other side of the connection (if any) */
  58214. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58215. /** Get the block that owns this connection point */
  58216. get ownerBlock(): NodeMaterialBlock;
  58217. /** Get the block connected on the other side of this connection (if any) */
  58218. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58219. /** Get the block connected on the endpoints of this connection (if any) */
  58220. get connectedBlocks(): Array<NodeMaterialBlock>;
  58221. /** Gets the list of connected endpoints */
  58222. get endpoints(): NodeMaterialConnectionPoint[];
  58223. /** Gets a boolean indicating if that output point is connected to at least one input */
  58224. get hasEndpoints(): boolean;
  58225. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58226. get isConnectedInVertexShader(): boolean;
  58227. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58228. get isConnectedInFragmentShader(): boolean;
  58229. /**
  58230. * Creates a new connection point
  58231. * @param name defines the connection point name
  58232. * @param ownerBlock defines the block hosting this connection point
  58233. * @param direction defines the direction of the connection point
  58234. */
  58235. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58236. /**
  58237. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58238. * @returns the class name
  58239. */
  58240. getClassName(): string;
  58241. /**
  58242. * Gets a boolean indicating if the current point can be connected to another point
  58243. * @param connectionPoint defines the other connection point
  58244. * @returns a boolean
  58245. */
  58246. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58247. /**
  58248. * Gets a number indicating if the current point can be connected to another point
  58249. * @param connectionPoint defines the other connection point
  58250. * @returns a number defining the compatibility state
  58251. */
  58252. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58253. /**
  58254. * Connect this point to another connection point
  58255. * @param connectionPoint defines the other connection point
  58256. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58257. * @returns the current connection point
  58258. */
  58259. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58260. /**
  58261. * Disconnect this point from one of his endpoint
  58262. * @param endpoint defines the other connection point
  58263. * @returns the current connection point
  58264. */
  58265. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58266. /**
  58267. * Serializes this point in a JSON representation
  58268. * @returns the serialized point object
  58269. */
  58270. serialize(): any;
  58271. /**
  58272. * Release resources
  58273. */
  58274. dispose(): void;
  58275. }
  58276. }
  58277. declare module BABYLON {
  58278. /**
  58279. * Block used to add support for vertex skinning (bones)
  58280. */
  58281. export class BonesBlock extends NodeMaterialBlock {
  58282. /**
  58283. * Creates a new BonesBlock
  58284. * @param name defines the block name
  58285. */
  58286. constructor(name: string);
  58287. /**
  58288. * Initialize the block and prepare the context for build
  58289. * @param state defines the state that will be used for the build
  58290. */
  58291. initialize(state: NodeMaterialBuildState): void;
  58292. /**
  58293. * Gets the current class name
  58294. * @returns the class name
  58295. */
  58296. getClassName(): string;
  58297. /**
  58298. * Gets the matrix indices input component
  58299. */
  58300. get matricesIndices(): NodeMaterialConnectionPoint;
  58301. /**
  58302. * Gets the matrix weights input component
  58303. */
  58304. get matricesWeights(): NodeMaterialConnectionPoint;
  58305. /**
  58306. * Gets the extra matrix indices input component
  58307. */
  58308. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58309. /**
  58310. * Gets the extra matrix weights input component
  58311. */
  58312. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58313. /**
  58314. * Gets the world input component
  58315. */
  58316. get world(): NodeMaterialConnectionPoint;
  58317. /**
  58318. * Gets the output component
  58319. */
  58320. get output(): NodeMaterialConnectionPoint;
  58321. autoConfigure(material: NodeMaterial): void;
  58322. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58323. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58324. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58325. protected _buildBlock(state: NodeMaterialBuildState): this;
  58326. }
  58327. }
  58328. declare module BABYLON {
  58329. /**
  58330. * Block used to add support for instances
  58331. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58332. */
  58333. export class InstancesBlock extends NodeMaterialBlock {
  58334. /**
  58335. * Creates a new InstancesBlock
  58336. * @param name defines the block name
  58337. */
  58338. constructor(name: string);
  58339. /**
  58340. * Gets the current class name
  58341. * @returns the class name
  58342. */
  58343. getClassName(): string;
  58344. /**
  58345. * Gets the first world row input component
  58346. */
  58347. get world0(): NodeMaterialConnectionPoint;
  58348. /**
  58349. * Gets the second world row input component
  58350. */
  58351. get world1(): NodeMaterialConnectionPoint;
  58352. /**
  58353. * Gets the third world row input component
  58354. */
  58355. get world2(): NodeMaterialConnectionPoint;
  58356. /**
  58357. * Gets the forth world row input component
  58358. */
  58359. get world3(): NodeMaterialConnectionPoint;
  58360. /**
  58361. * Gets the world input component
  58362. */
  58363. get world(): NodeMaterialConnectionPoint;
  58364. /**
  58365. * Gets the output component
  58366. */
  58367. get output(): NodeMaterialConnectionPoint;
  58368. /**
  58369. * Gets the isntanceID component
  58370. */
  58371. get instanceID(): NodeMaterialConnectionPoint;
  58372. autoConfigure(material: NodeMaterial): void;
  58373. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58374. protected _buildBlock(state: NodeMaterialBuildState): this;
  58375. }
  58376. }
  58377. declare module BABYLON {
  58378. /**
  58379. * Block used to add morph targets support to vertex shader
  58380. */
  58381. export class MorphTargetsBlock extends NodeMaterialBlock {
  58382. private _repeatableContentAnchor;
  58383. /**
  58384. * Create a new MorphTargetsBlock
  58385. * @param name defines the block name
  58386. */
  58387. constructor(name: string);
  58388. /**
  58389. * Gets the current class name
  58390. * @returns the class name
  58391. */
  58392. getClassName(): string;
  58393. /**
  58394. * Gets the position input component
  58395. */
  58396. get position(): NodeMaterialConnectionPoint;
  58397. /**
  58398. * Gets the normal input component
  58399. */
  58400. get normal(): NodeMaterialConnectionPoint;
  58401. /**
  58402. * Gets the tangent input component
  58403. */
  58404. get tangent(): NodeMaterialConnectionPoint;
  58405. /**
  58406. * Gets the tangent input component
  58407. */
  58408. get uv(): NodeMaterialConnectionPoint;
  58409. /**
  58410. * Gets the position output component
  58411. */
  58412. get positionOutput(): NodeMaterialConnectionPoint;
  58413. /**
  58414. * Gets the normal output component
  58415. */
  58416. get normalOutput(): NodeMaterialConnectionPoint;
  58417. /**
  58418. * Gets the tangent output component
  58419. */
  58420. get tangentOutput(): NodeMaterialConnectionPoint;
  58421. /**
  58422. * Gets the tangent output component
  58423. */
  58424. get uvOutput(): NodeMaterialConnectionPoint;
  58425. initialize(state: NodeMaterialBuildState): void;
  58426. autoConfigure(material: NodeMaterial): void;
  58427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58429. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58430. protected _buildBlock(state: NodeMaterialBuildState): this;
  58431. }
  58432. }
  58433. declare module BABYLON {
  58434. /**
  58435. * Block used to get data information from a light
  58436. */
  58437. export class LightInformationBlock extends NodeMaterialBlock {
  58438. private _lightDataUniformName;
  58439. private _lightColorUniformName;
  58440. private _lightTypeDefineName;
  58441. /**
  58442. * Gets or sets the light associated with this block
  58443. */
  58444. light: Nullable<Light>;
  58445. /**
  58446. * Creates a new LightInformationBlock
  58447. * @param name defines the block name
  58448. */
  58449. constructor(name: string);
  58450. /**
  58451. * Gets the current class name
  58452. * @returns the class name
  58453. */
  58454. getClassName(): string;
  58455. /**
  58456. * Gets the world position input component
  58457. */
  58458. get worldPosition(): NodeMaterialConnectionPoint;
  58459. /**
  58460. * Gets the direction output component
  58461. */
  58462. get direction(): NodeMaterialConnectionPoint;
  58463. /**
  58464. * Gets the direction output component
  58465. */
  58466. get color(): NodeMaterialConnectionPoint;
  58467. /**
  58468. * Gets the direction output component
  58469. */
  58470. get intensity(): NodeMaterialConnectionPoint;
  58471. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58473. protected _buildBlock(state: NodeMaterialBuildState): this;
  58474. serialize(): any;
  58475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58476. }
  58477. }
  58478. declare module BABYLON {
  58479. /**
  58480. * Block used to add image processing support to fragment shader
  58481. */
  58482. export class ImageProcessingBlock extends NodeMaterialBlock {
  58483. /**
  58484. * Create a new ImageProcessingBlock
  58485. * @param name defines the block name
  58486. */
  58487. constructor(name: string);
  58488. /**
  58489. * Gets the current class name
  58490. * @returns the class name
  58491. */
  58492. getClassName(): string;
  58493. /**
  58494. * Gets the color input component
  58495. */
  58496. get color(): NodeMaterialConnectionPoint;
  58497. /**
  58498. * Gets the output component
  58499. */
  58500. get output(): NodeMaterialConnectionPoint;
  58501. /**
  58502. * Initialize the block and prepare the context for build
  58503. * @param state defines the state that will be used for the build
  58504. */
  58505. initialize(state: NodeMaterialBuildState): void;
  58506. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58508. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58509. protected _buildBlock(state: NodeMaterialBuildState): this;
  58510. }
  58511. }
  58512. declare module BABYLON {
  58513. /**
  58514. * Block used to pertub normals based on a normal map
  58515. */
  58516. export class PerturbNormalBlock extends NodeMaterialBlock {
  58517. private _tangentSpaceParameterName;
  58518. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58519. invertX: boolean;
  58520. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58521. invertY: boolean;
  58522. /**
  58523. * Create a new PerturbNormalBlock
  58524. * @param name defines the block name
  58525. */
  58526. constructor(name: string);
  58527. /**
  58528. * Gets the current class name
  58529. * @returns the class name
  58530. */
  58531. getClassName(): string;
  58532. /**
  58533. * Gets the world position input component
  58534. */
  58535. get worldPosition(): NodeMaterialConnectionPoint;
  58536. /**
  58537. * Gets the world normal input component
  58538. */
  58539. get worldNormal(): NodeMaterialConnectionPoint;
  58540. /**
  58541. * Gets the world tangent input component
  58542. */
  58543. get worldTangent(): NodeMaterialConnectionPoint;
  58544. /**
  58545. * Gets the uv input component
  58546. */
  58547. get uv(): NodeMaterialConnectionPoint;
  58548. /**
  58549. * Gets the normal map color input component
  58550. */
  58551. get normalMapColor(): NodeMaterialConnectionPoint;
  58552. /**
  58553. * Gets the strength input component
  58554. */
  58555. get strength(): NodeMaterialConnectionPoint;
  58556. /**
  58557. * Gets the output component
  58558. */
  58559. get output(): NodeMaterialConnectionPoint;
  58560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58561. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58562. autoConfigure(material: NodeMaterial): void;
  58563. protected _buildBlock(state: NodeMaterialBuildState): this;
  58564. protected _dumpPropertiesCode(): string;
  58565. serialize(): any;
  58566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58567. }
  58568. }
  58569. declare module BABYLON {
  58570. /**
  58571. * Block used to discard a pixel if a value is smaller than a cutoff
  58572. */
  58573. export class DiscardBlock extends NodeMaterialBlock {
  58574. /**
  58575. * Create a new DiscardBlock
  58576. * @param name defines the block name
  58577. */
  58578. constructor(name: string);
  58579. /**
  58580. * Gets the current class name
  58581. * @returns the class name
  58582. */
  58583. getClassName(): string;
  58584. /**
  58585. * Gets the color input component
  58586. */
  58587. get value(): NodeMaterialConnectionPoint;
  58588. /**
  58589. * Gets the cutoff input component
  58590. */
  58591. get cutoff(): NodeMaterialConnectionPoint;
  58592. protected _buildBlock(state: NodeMaterialBuildState): this;
  58593. }
  58594. }
  58595. declare module BABYLON {
  58596. /**
  58597. * Block used to test if the fragment shader is front facing
  58598. */
  58599. export class FrontFacingBlock extends NodeMaterialBlock {
  58600. /**
  58601. * Creates a new FrontFacingBlock
  58602. * @param name defines the block name
  58603. */
  58604. constructor(name: string);
  58605. /**
  58606. * Gets the current class name
  58607. * @returns the class name
  58608. */
  58609. getClassName(): string;
  58610. /**
  58611. * Gets the output component
  58612. */
  58613. get output(): NodeMaterialConnectionPoint;
  58614. protected _buildBlock(state: NodeMaterialBuildState): this;
  58615. }
  58616. }
  58617. declare module BABYLON {
  58618. /**
  58619. * Block used to get the derivative value on x and y of a given input
  58620. */
  58621. export class DerivativeBlock extends NodeMaterialBlock {
  58622. /**
  58623. * Create a new DerivativeBlock
  58624. * @param name defines the block name
  58625. */
  58626. constructor(name: string);
  58627. /**
  58628. * Gets the current class name
  58629. * @returns the class name
  58630. */
  58631. getClassName(): string;
  58632. /**
  58633. * Gets the input component
  58634. */
  58635. get input(): NodeMaterialConnectionPoint;
  58636. /**
  58637. * Gets the derivative output on x
  58638. */
  58639. get dx(): NodeMaterialConnectionPoint;
  58640. /**
  58641. * Gets the derivative output on y
  58642. */
  58643. get dy(): NodeMaterialConnectionPoint;
  58644. protected _buildBlock(state: NodeMaterialBuildState): this;
  58645. }
  58646. }
  58647. declare module BABYLON {
  58648. /**
  58649. * Block used to add support for scene fog
  58650. */
  58651. export class FogBlock extends NodeMaterialBlock {
  58652. private _fogDistanceName;
  58653. private _fogParameters;
  58654. /**
  58655. * Create a new FogBlock
  58656. * @param name defines the block name
  58657. */
  58658. constructor(name: string);
  58659. /**
  58660. * Gets the current class name
  58661. * @returns the class name
  58662. */
  58663. getClassName(): string;
  58664. /**
  58665. * Gets the world position input component
  58666. */
  58667. get worldPosition(): NodeMaterialConnectionPoint;
  58668. /**
  58669. * Gets the view input component
  58670. */
  58671. get view(): NodeMaterialConnectionPoint;
  58672. /**
  58673. * Gets the color input component
  58674. */
  58675. get input(): NodeMaterialConnectionPoint;
  58676. /**
  58677. * Gets the fog color input component
  58678. */
  58679. get fogColor(): NodeMaterialConnectionPoint;
  58680. /**
  58681. * Gets the output component
  58682. */
  58683. get output(): NodeMaterialConnectionPoint;
  58684. autoConfigure(material: NodeMaterial): void;
  58685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58686. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58687. protected _buildBlock(state: NodeMaterialBuildState): this;
  58688. }
  58689. }
  58690. declare module BABYLON {
  58691. /**
  58692. * Block used to add light in the fragment shader
  58693. */
  58694. export class LightBlock extends NodeMaterialBlock {
  58695. private _lightId;
  58696. /**
  58697. * Gets or sets the light associated with this block
  58698. */
  58699. light: Nullable<Light>;
  58700. /**
  58701. * Create a new LightBlock
  58702. * @param name defines the block name
  58703. */
  58704. constructor(name: string);
  58705. /**
  58706. * Gets the current class name
  58707. * @returns the class name
  58708. */
  58709. getClassName(): string;
  58710. /**
  58711. * Gets the world position input component
  58712. */
  58713. get worldPosition(): NodeMaterialConnectionPoint;
  58714. /**
  58715. * Gets the world normal input component
  58716. */
  58717. get worldNormal(): NodeMaterialConnectionPoint;
  58718. /**
  58719. * Gets the camera (or eye) position component
  58720. */
  58721. get cameraPosition(): NodeMaterialConnectionPoint;
  58722. /**
  58723. * Gets the glossiness component
  58724. */
  58725. get glossiness(): NodeMaterialConnectionPoint;
  58726. /**
  58727. * Gets the glossinness power component
  58728. */
  58729. get glossPower(): NodeMaterialConnectionPoint;
  58730. /**
  58731. * Gets the diffuse color component
  58732. */
  58733. get diffuseColor(): NodeMaterialConnectionPoint;
  58734. /**
  58735. * Gets the specular color component
  58736. */
  58737. get specularColor(): NodeMaterialConnectionPoint;
  58738. /**
  58739. * Gets the diffuse output component
  58740. */
  58741. get diffuseOutput(): NodeMaterialConnectionPoint;
  58742. /**
  58743. * Gets the specular output component
  58744. */
  58745. get specularOutput(): NodeMaterialConnectionPoint;
  58746. /**
  58747. * Gets the shadow output component
  58748. */
  58749. get shadow(): NodeMaterialConnectionPoint;
  58750. autoConfigure(material: NodeMaterial): void;
  58751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58752. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58753. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58754. private _injectVertexCode;
  58755. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58756. serialize(): any;
  58757. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58758. }
  58759. }
  58760. declare module BABYLON {
  58761. /**
  58762. * Block used to multiply 2 values
  58763. */
  58764. export class MultiplyBlock extends NodeMaterialBlock {
  58765. /**
  58766. * Creates a new MultiplyBlock
  58767. * @param name defines the block name
  58768. */
  58769. constructor(name: string);
  58770. /**
  58771. * Gets the current class name
  58772. * @returns the class name
  58773. */
  58774. getClassName(): string;
  58775. /**
  58776. * Gets the left operand input component
  58777. */
  58778. get left(): NodeMaterialConnectionPoint;
  58779. /**
  58780. * Gets the right operand input component
  58781. */
  58782. get right(): NodeMaterialConnectionPoint;
  58783. /**
  58784. * Gets the output component
  58785. */
  58786. get output(): NodeMaterialConnectionPoint;
  58787. protected _buildBlock(state: NodeMaterialBuildState): this;
  58788. }
  58789. }
  58790. declare module BABYLON {
  58791. /**
  58792. * Block used to add 2 vectors
  58793. */
  58794. export class AddBlock extends NodeMaterialBlock {
  58795. /**
  58796. * Creates a new AddBlock
  58797. * @param name defines the block name
  58798. */
  58799. constructor(name: string);
  58800. /**
  58801. * Gets the current class name
  58802. * @returns the class name
  58803. */
  58804. getClassName(): string;
  58805. /**
  58806. * Gets the left operand input component
  58807. */
  58808. get left(): NodeMaterialConnectionPoint;
  58809. /**
  58810. * Gets the right operand input component
  58811. */
  58812. get right(): NodeMaterialConnectionPoint;
  58813. /**
  58814. * Gets the output component
  58815. */
  58816. get output(): NodeMaterialConnectionPoint;
  58817. protected _buildBlock(state: NodeMaterialBuildState): this;
  58818. }
  58819. }
  58820. declare module BABYLON {
  58821. /**
  58822. * Block used to scale a vector by a float
  58823. */
  58824. export class ScaleBlock extends NodeMaterialBlock {
  58825. /**
  58826. * Creates a new ScaleBlock
  58827. * @param name defines the block name
  58828. */
  58829. constructor(name: string);
  58830. /**
  58831. * Gets the current class name
  58832. * @returns the class name
  58833. */
  58834. getClassName(): string;
  58835. /**
  58836. * Gets the input component
  58837. */
  58838. get input(): NodeMaterialConnectionPoint;
  58839. /**
  58840. * Gets the factor input component
  58841. */
  58842. get factor(): NodeMaterialConnectionPoint;
  58843. /**
  58844. * Gets the output component
  58845. */
  58846. get output(): NodeMaterialConnectionPoint;
  58847. protected _buildBlock(state: NodeMaterialBuildState): this;
  58848. }
  58849. }
  58850. declare module BABYLON {
  58851. /**
  58852. * Block used to clamp a float
  58853. */
  58854. export class ClampBlock extends NodeMaterialBlock {
  58855. /** Gets or sets the minimum range */
  58856. minimum: number;
  58857. /** Gets or sets the maximum range */
  58858. maximum: number;
  58859. /**
  58860. * Creates a new ClampBlock
  58861. * @param name defines the block name
  58862. */
  58863. constructor(name: string);
  58864. /**
  58865. * Gets the current class name
  58866. * @returns the class name
  58867. */
  58868. getClassName(): string;
  58869. /**
  58870. * Gets the value input component
  58871. */
  58872. get value(): NodeMaterialConnectionPoint;
  58873. /**
  58874. * Gets the output component
  58875. */
  58876. get output(): NodeMaterialConnectionPoint;
  58877. protected _buildBlock(state: NodeMaterialBuildState): this;
  58878. protected _dumpPropertiesCode(): string;
  58879. serialize(): any;
  58880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58881. }
  58882. }
  58883. declare module BABYLON {
  58884. /**
  58885. * Block used to apply a cross product between 2 vectors
  58886. */
  58887. export class CrossBlock extends NodeMaterialBlock {
  58888. /**
  58889. * Creates a new CrossBlock
  58890. * @param name defines the block name
  58891. */
  58892. constructor(name: string);
  58893. /**
  58894. * Gets the current class name
  58895. * @returns the class name
  58896. */
  58897. getClassName(): string;
  58898. /**
  58899. * Gets the left operand input component
  58900. */
  58901. get left(): NodeMaterialConnectionPoint;
  58902. /**
  58903. * Gets the right operand input component
  58904. */
  58905. get right(): NodeMaterialConnectionPoint;
  58906. /**
  58907. * Gets the output component
  58908. */
  58909. get output(): NodeMaterialConnectionPoint;
  58910. protected _buildBlock(state: NodeMaterialBuildState): this;
  58911. }
  58912. }
  58913. declare module BABYLON {
  58914. /**
  58915. * Block used to apply a dot product between 2 vectors
  58916. */
  58917. export class DotBlock extends NodeMaterialBlock {
  58918. /**
  58919. * Creates a new DotBlock
  58920. * @param name defines the block name
  58921. */
  58922. constructor(name: string);
  58923. /**
  58924. * Gets the current class name
  58925. * @returns the class name
  58926. */
  58927. getClassName(): string;
  58928. /**
  58929. * Gets the left operand input component
  58930. */
  58931. get left(): NodeMaterialConnectionPoint;
  58932. /**
  58933. * Gets the right operand input component
  58934. */
  58935. get right(): NodeMaterialConnectionPoint;
  58936. /**
  58937. * Gets the output component
  58938. */
  58939. get output(): NodeMaterialConnectionPoint;
  58940. protected _buildBlock(state: NodeMaterialBuildState): this;
  58941. }
  58942. }
  58943. declare module BABYLON {
  58944. /**
  58945. * Block used to remap a float from a range to a new one
  58946. */
  58947. export class RemapBlock extends NodeMaterialBlock {
  58948. /**
  58949. * Gets or sets the source range
  58950. */
  58951. sourceRange: Vector2;
  58952. /**
  58953. * Gets or sets the target range
  58954. */
  58955. targetRange: Vector2;
  58956. /**
  58957. * Creates a new RemapBlock
  58958. * @param name defines the block name
  58959. */
  58960. constructor(name: string);
  58961. /**
  58962. * Gets the current class name
  58963. * @returns the class name
  58964. */
  58965. getClassName(): string;
  58966. /**
  58967. * Gets the input component
  58968. */
  58969. get input(): NodeMaterialConnectionPoint;
  58970. /**
  58971. * Gets the source min input component
  58972. */
  58973. get sourceMin(): NodeMaterialConnectionPoint;
  58974. /**
  58975. * Gets the source max input component
  58976. */
  58977. get sourceMax(): NodeMaterialConnectionPoint;
  58978. /**
  58979. * Gets the target min input component
  58980. */
  58981. get targetMin(): NodeMaterialConnectionPoint;
  58982. /**
  58983. * Gets the target max input component
  58984. */
  58985. get targetMax(): NodeMaterialConnectionPoint;
  58986. /**
  58987. * Gets the output component
  58988. */
  58989. get output(): NodeMaterialConnectionPoint;
  58990. protected _buildBlock(state: NodeMaterialBuildState): this;
  58991. protected _dumpPropertiesCode(): string;
  58992. serialize(): any;
  58993. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58994. }
  58995. }
  58996. declare module BABYLON {
  58997. /**
  58998. * Block used to normalize a vector
  58999. */
  59000. export class NormalizeBlock extends NodeMaterialBlock {
  59001. /**
  59002. * Creates a new NormalizeBlock
  59003. * @param name defines the block name
  59004. */
  59005. constructor(name: string);
  59006. /**
  59007. * Gets the current class name
  59008. * @returns the class name
  59009. */
  59010. getClassName(): string;
  59011. /**
  59012. * Gets the input component
  59013. */
  59014. get input(): NodeMaterialConnectionPoint;
  59015. /**
  59016. * Gets the output component
  59017. */
  59018. get output(): NodeMaterialConnectionPoint;
  59019. protected _buildBlock(state: NodeMaterialBuildState): this;
  59020. }
  59021. }
  59022. declare module BABYLON {
  59023. /**
  59024. * Operations supported by the Trigonometry block
  59025. */
  59026. export enum TrigonometryBlockOperations {
  59027. /** Cos */
  59028. Cos = 0,
  59029. /** Sin */
  59030. Sin = 1,
  59031. /** Abs */
  59032. Abs = 2,
  59033. /** Exp */
  59034. Exp = 3,
  59035. /** Exp2 */
  59036. Exp2 = 4,
  59037. /** Round */
  59038. Round = 5,
  59039. /** Floor */
  59040. Floor = 6,
  59041. /** Ceiling */
  59042. Ceiling = 7,
  59043. /** Square root */
  59044. Sqrt = 8,
  59045. /** Log */
  59046. Log = 9,
  59047. /** Tangent */
  59048. Tan = 10,
  59049. /** Arc tangent */
  59050. ArcTan = 11,
  59051. /** Arc cosinus */
  59052. ArcCos = 12,
  59053. /** Arc sinus */
  59054. ArcSin = 13,
  59055. /** Fraction */
  59056. Fract = 14,
  59057. /** Sign */
  59058. Sign = 15,
  59059. /** To radians (from degrees) */
  59060. Radians = 16,
  59061. /** To degrees (from radians) */
  59062. Degrees = 17
  59063. }
  59064. /**
  59065. * Block used to apply trigonometry operation to floats
  59066. */
  59067. export class TrigonometryBlock extends NodeMaterialBlock {
  59068. /**
  59069. * Gets or sets the operation applied by the block
  59070. */
  59071. operation: TrigonometryBlockOperations;
  59072. /**
  59073. * Creates a new TrigonometryBlock
  59074. * @param name defines the block name
  59075. */
  59076. constructor(name: string);
  59077. /**
  59078. * Gets the current class name
  59079. * @returns the class name
  59080. */
  59081. getClassName(): string;
  59082. /**
  59083. * Gets the input component
  59084. */
  59085. get input(): NodeMaterialConnectionPoint;
  59086. /**
  59087. * Gets the output component
  59088. */
  59089. get output(): NodeMaterialConnectionPoint;
  59090. protected _buildBlock(state: NodeMaterialBuildState): this;
  59091. serialize(): any;
  59092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59093. protected _dumpPropertiesCode(): string;
  59094. }
  59095. }
  59096. declare module BABYLON {
  59097. /**
  59098. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59099. */
  59100. export class ColorMergerBlock extends NodeMaterialBlock {
  59101. /**
  59102. * Create a new ColorMergerBlock
  59103. * @param name defines the block name
  59104. */
  59105. constructor(name: string);
  59106. /**
  59107. * Gets the current class name
  59108. * @returns the class name
  59109. */
  59110. getClassName(): string;
  59111. /**
  59112. * Gets the rgb component (input)
  59113. */
  59114. get rgbIn(): NodeMaterialConnectionPoint;
  59115. /**
  59116. * Gets the r component (input)
  59117. */
  59118. get r(): NodeMaterialConnectionPoint;
  59119. /**
  59120. * Gets the g component (input)
  59121. */
  59122. get g(): NodeMaterialConnectionPoint;
  59123. /**
  59124. * Gets the b component (input)
  59125. */
  59126. get b(): NodeMaterialConnectionPoint;
  59127. /**
  59128. * Gets the a component (input)
  59129. */
  59130. get a(): NodeMaterialConnectionPoint;
  59131. /**
  59132. * Gets the rgba component (output)
  59133. */
  59134. get rgba(): NodeMaterialConnectionPoint;
  59135. /**
  59136. * Gets the rgb component (output)
  59137. */
  59138. get rgbOut(): NodeMaterialConnectionPoint;
  59139. /**
  59140. * Gets the rgb component (output)
  59141. * @deprecated Please use rgbOut instead.
  59142. */
  59143. get rgb(): NodeMaterialConnectionPoint;
  59144. protected _buildBlock(state: NodeMaterialBuildState): this;
  59145. }
  59146. }
  59147. declare module BABYLON {
  59148. /**
  59149. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59150. */
  59151. export class VectorMergerBlock extends NodeMaterialBlock {
  59152. /**
  59153. * Create a new VectorMergerBlock
  59154. * @param name defines the block name
  59155. */
  59156. constructor(name: string);
  59157. /**
  59158. * Gets the current class name
  59159. * @returns the class name
  59160. */
  59161. getClassName(): string;
  59162. /**
  59163. * Gets the xyz component (input)
  59164. */
  59165. get xyzIn(): NodeMaterialConnectionPoint;
  59166. /**
  59167. * Gets the xy component (input)
  59168. */
  59169. get xyIn(): NodeMaterialConnectionPoint;
  59170. /**
  59171. * Gets the x component (input)
  59172. */
  59173. get x(): NodeMaterialConnectionPoint;
  59174. /**
  59175. * Gets the y component (input)
  59176. */
  59177. get y(): NodeMaterialConnectionPoint;
  59178. /**
  59179. * Gets the z component (input)
  59180. */
  59181. get z(): NodeMaterialConnectionPoint;
  59182. /**
  59183. * Gets the w component (input)
  59184. */
  59185. get w(): NodeMaterialConnectionPoint;
  59186. /**
  59187. * Gets the xyzw component (output)
  59188. */
  59189. get xyzw(): NodeMaterialConnectionPoint;
  59190. /**
  59191. * Gets the xyz component (output)
  59192. */
  59193. get xyzOut(): NodeMaterialConnectionPoint;
  59194. /**
  59195. * Gets the xy component (output)
  59196. */
  59197. get xyOut(): NodeMaterialConnectionPoint;
  59198. /**
  59199. * Gets the xy component (output)
  59200. * @deprecated Please use xyOut instead.
  59201. */
  59202. get xy(): NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the xyz component (output)
  59205. * @deprecated Please use xyzOut instead.
  59206. */
  59207. get xyz(): NodeMaterialConnectionPoint;
  59208. protected _buildBlock(state: NodeMaterialBuildState): this;
  59209. }
  59210. }
  59211. declare module BABYLON {
  59212. /**
  59213. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59214. */
  59215. export class ColorSplitterBlock extends NodeMaterialBlock {
  59216. /**
  59217. * Create a new ColorSplitterBlock
  59218. * @param name defines the block name
  59219. */
  59220. constructor(name: string);
  59221. /**
  59222. * Gets the current class name
  59223. * @returns the class name
  59224. */
  59225. getClassName(): string;
  59226. /**
  59227. * Gets the rgba component (input)
  59228. */
  59229. get rgba(): NodeMaterialConnectionPoint;
  59230. /**
  59231. * Gets the rgb component (input)
  59232. */
  59233. get rgbIn(): NodeMaterialConnectionPoint;
  59234. /**
  59235. * Gets the rgb component (output)
  59236. */
  59237. get rgbOut(): NodeMaterialConnectionPoint;
  59238. /**
  59239. * Gets the r component (output)
  59240. */
  59241. get r(): NodeMaterialConnectionPoint;
  59242. /**
  59243. * Gets the g component (output)
  59244. */
  59245. get g(): NodeMaterialConnectionPoint;
  59246. /**
  59247. * Gets the b component (output)
  59248. */
  59249. get b(): NodeMaterialConnectionPoint;
  59250. /**
  59251. * Gets the a component (output)
  59252. */
  59253. get a(): NodeMaterialConnectionPoint;
  59254. protected _inputRename(name: string): string;
  59255. protected _outputRename(name: string): string;
  59256. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59257. }
  59258. }
  59259. declare module BABYLON {
  59260. /**
  59261. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59262. */
  59263. export class VectorSplitterBlock extends NodeMaterialBlock {
  59264. /**
  59265. * Create a new VectorSplitterBlock
  59266. * @param name defines the block name
  59267. */
  59268. constructor(name: string);
  59269. /**
  59270. * Gets the current class name
  59271. * @returns the class name
  59272. */
  59273. getClassName(): string;
  59274. /**
  59275. * Gets the xyzw component (input)
  59276. */
  59277. get xyzw(): NodeMaterialConnectionPoint;
  59278. /**
  59279. * Gets the xyz component (input)
  59280. */
  59281. get xyzIn(): NodeMaterialConnectionPoint;
  59282. /**
  59283. * Gets the xy component (input)
  59284. */
  59285. get xyIn(): NodeMaterialConnectionPoint;
  59286. /**
  59287. * Gets the xyz component (output)
  59288. */
  59289. get xyzOut(): NodeMaterialConnectionPoint;
  59290. /**
  59291. * Gets the xy component (output)
  59292. */
  59293. get xyOut(): NodeMaterialConnectionPoint;
  59294. /**
  59295. * Gets the x component (output)
  59296. */
  59297. get x(): NodeMaterialConnectionPoint;
  59298. /**
  59299. * Gets the y component (output)
  59300. */
  59301. get y(): NodeMaterialConnectionPoint;
  59302. /**
  59303. * Gets the z component (output)
  59304. */
  59305. get z(): NodeMaterialConnectionPoint;
  59306. /**
  59307. * Gets the w component (output)
  59308. */
  59309. get w(): NodeMaterialConnectionPoint;
  59310. protected _inputRename(name: string): string;
  59311. protected _outputRename(name: string): string;
  59312. protected _buildBlock(state: NodeMaterialBuildState): this;
  59313. }
  59314. }
  59315. declare module BABYLON {
  59316. /**
  59317. * Block used to lerp between 2 values
  59318. */
  59319. export class LerpBlock extends NodeMaterialBlock {
  59320. /**
  59321. * Creates a new LerpBlock
  59322. * @param name defines the block name
  59323. */
  59324. constructor(name: string);
  59325. /**
  59326. * Gets the current class name
  59327. * @returns the class name
  59328. */
  59329. getClassName(): string;
  59330. /**
  59331. * Gets the left operand input component
  59332. */
  59333. get left(): NodeMaterialConnectionPoint;
  59334. /**
  59335. * Gets the right operand input component
  59336. */
  59337. get right(): NodeMaterialConnectionPoint;
  59338. /**
  59339. * Gets the gradient operand input component
  59340. */
  59341. get gradient(): NodeMaterialConnectionPoint;
  59342. /**
  59343. * Gets the output component
  59344. */
  59345. get output(): NodeMaterialConnectionPoint;
  59346. protected _buildBlock(state: NodeMaterialBuildState): this;
  59347. }
  59348. }
  59349. declare module BABYLON {
  59350. /**
  59351. * Block used to divide 2 vectors
  59352. */
  59353. export class DivideBlock extends NodeMaterialBlock {
  59354. /**
  59355. * Creates a new DivideBlock
  59356. * @param name defines the block name
  59357. */
  59358. constructor(name: string);
  59359. /**
  59360. * Gets the current class name
  59361. * @returns the class name
  59362. */
  59363. getClassName(): string;
  59364. /**
  59365. * Gets the left operand input component
  59366. */
  59367. get left(): NodeMaterialConnectionPoint;
  59368. /**
  59369. * Gets the right operand input component
  59370. */
  59371. get right(): NodeMaterialConnectionPoint;
  59372. /**
  59373. * Gets the output component
  59374. */
  59375. get output(): NodeMaterialConnectionPoint;
  59376. protected _buildBlock(state: NodeMaterialBuildState): this;
  59377. }
  59378. }
  59379. declare module BABYLON {
  59380. /**
  59381. * Block used to subtract 2 vectors
  59382. */
  59383. export class SubtractBlock extends NodeMaterialBlock {
  59384. /**
  59385. * Creates a new SubtractBlock
  59386. * @param name defines the block name
  59387. */
  59388. constructor(name: string);
  59389. /**
  59390. * Gets the current class name
  59391. * @returns the class name
  59392. */
  59393. getClassName(): string;
  59394. /**
  59395. * Gets the left operand input component
  59396. */
  59397. get left(): NodeMaterialConnectionPoint;
  59398. /**
  59399. * Gets the right operand input component
  59400. */
  59401. get right(): NodeMaterialConnectionPoint;
  59402. /**
  59403. * Gets the output component
  59404. */
  59405. get output(): NodeMaterialConnectionPoint;
  59406. protected _buildBlock(state: NodeMaterialBuildState): this;
  59407. }
  59408. }
  59409. declare module BABYLON {
  59410. /**
  59411. * Block used to step a value
  59412. */
  59413. export class StepBlock extends NodeMaterialBlock {
  59414. /**
  59415. * Creates a new StepBlock
  59416. * @param name defines the block name
  59417. */
  59418. constructor(name: string);
  59419. /**
  59420. * Gets the current class name
  59421. * @returns the class name
  59422. */
  59423. getClassName(): string;
  59424. /**
  59425. * Gets the value operand input component
  59426. */
  59427. get value(): NodeMaterialConnectionPoint;
  59428. /**
  59429. * Gets the edge operand input component
  59430. */
  59431. get edge(): NodeMaterialConnectionPoint;
  59432. /**
  59433. * Gets the output component
  59434. */
  59435. get output(): NodeMaterialConnectionPoint;
  59436. protected _buildBlock(state: NodeMaterialBuildState): this;
  59437. }
  59438. }
  59439. declare module BABYLON {
  59440. /**
  59441. * Block used to get the opposite (1 - x) of a value
  59442. */
  59443. export class OneMinusBlock extends NodeMaterialBlock {
  59444. /**
  59445. * Creates a new OneMinusBlock
  59446. * @param name defines the block name
  59447. */
  59448. constructor(name: string);
  59449. /**
  59450. * Gets the current class name
  59451. * @returns the class name
  59452. */
  59453. getClassName(): string;
  59454. /**
  59455. * Gets the input component
  59456. */
  59457. get input(): NodeMaterialConnectionPoint;
  59458. /**
  59459. * Gets the output component
  59460. */
  59461. get output(): NodeMaterialConnectionPoint;
  59462. protected _buildBlock(state: NodeMaterialBuildState): this;
  59463. }
  59464. }
  59465. declare module BABYLON {
  59466. /**
  59467. * Block used to get the view direction
  59468. */
  59469. export class ViewDirectionBlock extends NodeMaterialBlock {
  59470. /**
  59471. * Creates a new ViewDirectionBlock
  59472. * @param name defines the block name
  59473. */
  59474. constructor(name: string);
  59475. /**
  59476. * Gets the current class name
  59477. * @returns the class name
  59478. */
  59479. getClassName(): string;
  59480. /**
  59481. * Gets the world position component
  59482. */
  59483. get worldPosition(): NodeMaterialConnectionPoint;
  59484. /**
  59485. * Gets the camera position component
  59486. */
  59487. get cameraPosition(): NodeMaterialConnectionPoint;
  59488. /**
  59489. * Gets the output component
  59490. */
  59491. get output(): NodeMaterialConnectionPoint;
  59492. autoConfigure(material: NodeMaterial): void;
  59493. protected _buildBlock(state: NodeMaterialBuildState): this;
  59494. }
  59495. }
  59496. declare module BABYLON {
  59497. /**
  59498. * Block used to compute fresnel value
  59499. */
  59500. export class FresnelBlock extends NodeMaterialBlock {
  59501. /**
  59502. * Create a new FresnelBlock
  59503. * @param name defines the block name
  59504. */
  59505. constructor(name: string);
  59506. /**
  59507. * Gets the current class name
  59508. * @returns the class name
  59509. */
  59510. getClassName(): string;
  59511. /**
  59512. * Gets the world normal input component
  59513. */
  59514. get worldNormal(): NodeMaterialConnectionPoint;
  59515. /**
  59516. * Gets the view direction input component
  59517. */
  59518. get viewDirection(): NodeMaterialConnectionPoint;
  59519. /**
  59520. * Gets the bias input component
  59521. */
  59522. get bias(): NodeMaterialConnectionPoint;
  59523. /**
  59524. * Gets the camera (or eye) position component
  59525. */
  59526. get power(): NodeMaterialConnectionPoint;
  59527. /**
  59528. * Gets the fresnel output component
  59529. */
  59530. get fresnel(): NodeMaterialConnectionPoint;
  59531. autoConfigure(material: NodeMaterial): void;
  59532. protected _buildBlock(state: NodeMaterialBuildState): this;
  59533. }
  59534. }
  59535. declare module BABYLON {
  59536. /**
  59537. * Block used to get the max of 2 values
  59538. */
  59539. export class MaxBlock extends NodeMaterialBlock {
  59540. /**
  59541. * Creates a new MaxBlock
  59542. * @param name defines the block name
  59543. */
  59544. constructor(name: string);
  59545. /**
  59546. * Gets the current class name
  59547. * @returns the class name
  59548. */
  59549. getClassName(): string;
  59550. /**
  59551. * Gets the left operand input component
  59552. */
  59553. get left(): NodeMaterialConnectionPoint;
  59554. /**
  59555. * Gets the right operand input component
  59556. */
  59557. get right(): NodeMaterialConnectionPoint;
  59558. /**
  59559. * Gets the output component
  59560. */
  59561. get output(): NodeMaterialConnectionPoint;
  59562. protected _buildBlock(state: NodeMaterialBuildState): this;
  59563. }
  59564. }
  59565. declare module BABYLON {
  59566. /**
  59567. * Block used to get the min of 2 values
  59568. */
  59569. export class MinBlock extends NodeMaterialBlock {
  59570. /**
  59571. * Creates a new MinBlock
  59572. * @param name defines the block name
  59573. */
  59574. constructor(name: string);
  59575. /**
  59576. * Gets the current class name
  59577. * @returns the class name
  59578. */
  59579. getClassName(): string;
  59580. /**
  59581. * Gets the left operand input component
  59582. */
  59583. get left(): NodeMaterialConnectionPoint;
  59584. /**
  59585. * Gets the right operand input component
  59586. */
  59587. get right(): NodeMaterialConnectionPoint;
  59588. /**
  59589. * Gets the output component
  59590. */
  59591. get output(): NodeMaterialConnectionPoint;
  59592. protected _buildBlock(state: NodeMaterialBuildState): this;
  59593. }
  59594. }
  59595. declare module BABYLON {
  59596. /**
  59597. * Block used to get the distance between 2 values
  59598. */
  59599. export class DistanceBlock extends NodeMaterialBlock {
  59600. /**
  59601. * Creates a new DistanceBlock
  59602. * @param name defines the block name
  59603. */
  59604. constructor(name: string);
  59605. /**
  59606. * Gets the current class name
  59607. * @returns the class name
  59608. */
  59609. getClassName(): string;
  59610. /**
  59611. * Gets the left operand input component
  59612. */
  59613. get left(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the right operand input component
  59616. */
  59617. get right(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the output component
  59620. */
  59621. get output(): NodeMaterialConnectionPoint;
  59622. protected _buildBlock(state: NodeMaterialBuildState): this;
  59623. }
  59624. }
  59625. declare module BABYLON {
  59626. /**
  59627. * Block used to get the length of a vector
  59628. */
  59629. export class LengthBlock extends NodeMaterialBlock {
  59630. /**
  59631. * Creates a new LengthBlock
  59632. * @param name defines the block name
  59633. */
  59634. constructor(name: string);
  59635. /**
  59636. * Gets the current class name
  59637. * @returns the class name
  59638. */
  59639. getClassName(): string;
  59640. /**
  59641. * Gets the value input component
  59642. */
  59643. get value(): NodeMaterialConnectionPoint;
  59644. /**
  59645. * Gets the output component
  59646. */
  59647. get output(): NodeMaterialConnectionPoint;
  59648. protected _buildBlock(state: NodeMaterialBuildState): this;
  59649. }
  59650. }
  59651. declare module BABYLON {
  59652. /**
  59653. * Block used to get negative version of a value (i.e. x * -1)
  59654. */
  59655. export class NegateBlock extends NodeMaterialBlock {
  59656. /**
  59657. * Creates a new NegateBlock
  59658. * @param name defines the block name
  59659. */
  59660. constructor(name: string);
  59661. /**
  59662. * Gets the current class name
  59663. * @returns the class name
  59664. */
  59665. getClassName(): string;
  59666. /**
  59667. * Gets the value input component
  59668. */
  59669. get value(): NodeMaterialConnectionPoint;
  59670. /**
  59671. * Gets the output component
  59672. */
  59673. get output(): NodeMaterialConnectionPoint;
  59674. protected _buildBlock(state: NodeMaterialBuildState): this;
  59675. }
  59676. }
  59677. declare module BABYLON {
  59678. /**
  59679. * Block used to get the value of the first parameter raised to the power of the second
  59680. */
  59681. export class PowBlock extends NodeMaterialBlock {
  59682. /**
  59683. * Creates a new PowBlock
  59684. * @param name defines the block name
  59685. */
  59686. constructor(name: string);
  59687. /**
  59688. * Gets the current class name
  59689. * @returns the class name
  59690. */
  59691. getClassName(): string;
  59692. /**
  59693. * Gets the value operand input component
  59694. */
  59695. get value(): NodeMaterialConnectionPoint;
  59696. /**
  59697. * Gets the power operand input component
  59698. */
  59699. get power(): NodeMaterialConnectionPoint;
  59700. /**
  59701. * Gets the output component
  59702. */
  59703. get output(): NodeMaterialConnectionPoint;
  59704. protected _buildBlock(state: NodeMaterialBuildState): this;
  59705. }
  59706. }
  59707. declare module BABYLON {
  59708. /**
  59709. * Block used to get a random number
  59710. */
  59711. export class RandomNumberBlock extends NodeMaterialBlock {
  59712. /**
  59713. * Creates a new RandomNumberBlock
  59714. * @param name defines the block name
  59715. */
  59716. constructor(name: string);
  59717. /**
  59718. * Gets the current class name
  59719. * @returns the class name
  59720. */
  59721. getClassName(): string;
  59722. /**
  59723. * Gets the seed input component
  59724. */
  59725. get seed(): NodeMaterialConnectionPoint;
  59726. /**
  59727. * Gets the output component
  59728. */
  59729. get output(): NodeMaterialConnectionPoint;
  59730. protected _buildBlock(state: NodeMaterialBuildState): this;
  59731. }
  59732. }
  59733. declare module BABYLON {
  59734. /**
  59735. * Block used to compute arc tangent of 2 values
  59736. */
  59737. export class ArcTan2Block extends NodeMaterialBlock {
  59738. /**
  59739. * Creates a new ArcTan2Block
  59740. * @param name defines the block name
  59741. */
  59742. constructor(name: string);
  59743. /**
  59744. * Gets the current class name
  59745. * @returns the class name
  59746. */
  59747. getClassName(): string;
  59748. /**
  59749. * Gets the x operand input component
  59750. */
  59751. get x(): NodeMaterialConnectionPoint;
  59752. /**
  59753. * Gets the y operand input component
  59754. */
  59755. get y(): NodeMaterialConnectionPoint;
  59756. /**
  59757. * Gets the output component
  59758. */
  59759. get output(): NodeMaterialConnectionPoint;
  59760. protected _buildBlock(state: NodeMaterialBuildState): this;
  59761. }
  59762. }
  59763. declare module BABYLON {
  59764. /**
  59765. * Block used to smooth step a value
  59766. */
  59767. export class SmoothStepBlock extends NodeMaterialBlock {
  59768. /**
  59769. * Creates a new SmoothStepBlock
  59770. * @param name defines the block name
  59771. */
  59772. constructor(name: string);
  59773. /**
  59774. * Gets the current class name
  59775. * @returns the class name
  59776. */
  59777. getClassName(): string;
  59778. /**
  59779. * Gets the value operand input component
  59780. */
  59781. get value(): NodeMaterialConnectionPoint;
  59782. /**
  59783. * Gets the first edge operand input component
  59784. */
  59785. get edge0(): NodeMaterialConnectionPoint;
  59786. /**
  59787. * Gets the second edge operand input component
  59788. */
  59789. get edge1(): NodeMaterialConnectionPoint;
  59790. /**
  59791. * Gets the output component
  59792. */
  59793. get output(): NodeMaterialConnectionPoint;
  59794. protected _buildBlock(state: NodeMaterialBuildState): this;
  59795. }
  59796. }
  59797. declare module BABYLON {
  59798. /**
  59799. * Block used to get the reciprocal (1 / x) of a value
  59800. */
  59801. export class ReciprocalBlock extends NodeMaterialBlock {
  59802. /**
  59803. * Creates a new ReciprocalBlock
  59804. * @param name defines the block name
  59805. */
  59806. constructor(name: string);
  59807. /**
  59808. * Gets the current class name
  59809. * @returns the class name
  59810. */
  59811. getClassName(): string;
  59812. /**
  59813. * Gets the input component
  59814. */
  59815. get input(): NodeMaterialConnectionPoint;
  59816. /**
  59817. * Gets the output component
  59818. */
  59819. get output(): NodeMaterialConnectionPoint;
  59820. protected _buildBlock(state: NodeMaterialBuildState): this;
  59821. }
  59822. }
  59823. declare module BABYLON {
  59824. /**
  59825. * Block used to replace a color by another one
  59826. */
  59827. export class ReplaceColorBlock extends NodeMaterialBlock {
  59828. /**
  59829. * Creates a new ReplaceColorBlock
  59830. * @param name defines the block name
  59831. */
  59832. constructor(name: string);
  59833. /**
  59834. * Gets the current class name
  59835. * @returns the class name
  59836. */
  59837. getClassName(): string;
  59838. /**
  59839. * Gets the value input component
  59840. */
  59841. get value(): NodeMaterialConnectionPoint;
  59842. /**
  59843. * Gets the reference input component
  59844. */
  59845. get reference(): NodeMaterialConnectionPoint;
  59846. /**
  59847. * Gets the distance input component
  59848. */
  59849. get distance(): NodeMaterialConnectionPoint;
  59850. /**
  59851. * Gets the replacement input component
  59852. */
  59853. get replacement(): NodeMaterialConnectionPoint;
  59854. /**
  59855. * Gets the output component
  59856. */
  59857. get output(): NodeMaterialConnectionPoint;
  59858. protected _buildBlock(state: NodeMaterialBuildState): this;
  59859. }
  59860. }
  59861. declare module BABYLON {
  59862. /**
  59863. * Block used to posterize a value
  59864. * @see https://en.wikipedia.org/wiki/Posterization
  59865. */
  59866. export class PosterizeBlock extends NodeMaterialBlock {
  59867. /**
  59868. * Creates a new PosterizeBlock
  59869. * @param name defines the block name
  59870. */
  59871. constructor(name: string);
  59872. /**
  59873. * Gets the current class name
  59874. * @returns the class name
  59875. */
  59876. getClassName(): string;
  59877. /**
  59878. * Gets the value input component
  59879. */
  59880. get value(): NodeMaterialConnectionPoint;
  59881. /**
  59882. * Gets the steps input component
  59883. */
  59884. get steps(): NodeMaterialConnectionPoint;
  59885. /**
  59886. * Gets the output component
  59887. */
  59888. get output(): NodeMaterialConnectionPoint;
  59889. protected _buildBlock(state: NodeMaterialBuildState): this;
  59890. }
  59891. }
  59892. declare module BABYLON {
  59893. /**
  59894. * Operations supported by the Wave block
  59895. */
  59896. export enum WaveBlockKind {
  59897. /** SawTooth */
  59898. SawTooth = 0,
  59899. /** Square */
  59900. Square = 1,
  59901. /** Triangle */
  59902. Triangle = 2
  59903. }
  59904. /**
  59905. * Block used to apply wave operation to floats
  59906. */
  59907. export class WaveBlock extends NodeMaterialBlock {
  59908. /**
  59909. * Gets or sets the kibnd of wave to be applied by the block
  59910. */
  59911. kind: WaveBlockKind;
  59912. /**
  59913. * Creates a new WaveBlock
  59914. * @param name defines the block name
  59915. */
  59916. constructor(name: string);
  59917. /**
  59918. * Gets the current class name
  59919. * @returns the class name
  59920. */
  59921. getClassName(): string;
  59922. /**
  59923. * Gets the input component
  59924. */
  59925. get input(): NodeMaterialConnectionPoint;
  59926. /**
  59927. * Gets the output component
  59928. */
  59929. get output(): NodeMaterialConnectionPoint;
  59930. protected _buildBlock(state: NodeMaterialBuildState): this;
  59931. serialize(): any;
  59932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59933. }
  59934. }
  59935. declare module BABYLON {
  59936. /**
  59937. * Class used to store a color step for the GradientBlock
  59938. */
  59939. export class GradientBlockColorStep {
  59940. /**
  59941. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59942. */
  59943. step: number;
  59944. /**
  59945. * Gets or sets the color associated with this step
  59946. */
  59947. color: Color3;
  59948. /**
  59949. * Creates a new GradientBlockColorStep
  59950. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59951. * @param color defines the color associated with this step
  59952. */
  59953. constructor(
  59954. /**
  59955. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59956. */
  59957. step: number,
  59958. /**
  59959. * Gets or sets the color associated with this step
  59960. */
  59961. color: Color3);
  59962. }
  59963. /**
  59964. * Block used to return a color from a gradient based on an input value between 0 and 1
  59965. */
  59966. export class GradientBlock extends NodeMaterialBlock {
  59967. /**
  59968. * Gets or sets the list of color steps
  59969. */
  59970. colorSteps: GradientBlockColorStep[];
  59971. /**
  59972. * Creates a new GradientBlock
  59973. * @param name defines the block name
  59974. */
  59975. constructor(name: string);
  59976. /**
  59977. * Gets the current class name
  59978. * @returns the class name
  59979. */
  59980. getClassName(): string;
  59981. /**
  59982. * Gets the gradient input component
  59983. */
  59984. get gradient(): NodeMaterialConnectionPoint;
  59985. /**
  59986. * Gets the output component
  59987. */
  59988. get output(): NodeMaterialConnectionPoint;
  59989. private _writeColorConstant;
  59990. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59991. serialize(): any;
  59992. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59993. protected _dumpPropertiesCode(): string;
  59994. }
  59995. }
  59996. declare module BABYLON {
  59997. /**
  59998. * Block used to normalize lerp between 2 values
  59999. */
  60000. export class NLerpBlock extends NodeMaterialBlock {
  60001. /**
  60002. * Creates a new NLerpBlock
  60003. * @param name defines the block name
  60004. */
  60005. constructor(name: string);
  60006. /**
  60007. * Gets the current class name
  60008. * @returns the class name
  60009. */
  60010. getClassName(): string;
  60011. /**
  60012. * Gets the left operand input component
  60013. */
  60014. get left(): NodeMaterialConnectionPoint;
  60015. /**
  60016. * Gets the right operand input component
  60017. */
  60018. get right(): NodeMaterialConnectionPoint;
  60019. /**
  60020. * Gets the gradient operand input component
  60021. */
  60022. get gradient(): NodeMaterialConnectionPoint;
  60023. /**
  60024. * Gets the output component
  60025. */
  60026. get output(): NodeMaterialConnectionPoint;
  60027. protected _buildBlock(state: NodeMaterialBuildState): this;
  60028. }
  60029. }
  60030. declare module BABYLON {
  60031. /**
  60032. * block used to Generate a Worley Noise 3D Noise Pattern
  60033. */
  60034. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60035. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60036. manhattanDistance: boolean;
  60037. /**
  60038. * Creates a new WorleyNoise3DBlock
  60039. * @param name defines the block name
  60040. */
  60041. constructor(name: string);
  60042. /**
  60043. * Gets the current class name
  60044. * @returns the class name
  60045. */
  60046. getClassName(): string;
  60047. /**
  60048. * Gets the seed input component
  60049. */
  60050. get seed(): NodeMaterialConnectionPoint;
  60051. /**
  60052. * Gets the jitter input component
  60053. */
  60054. get jitter(): NodeMaterialConnectionPoint;
  60055. /**
  60056. * Gets the output component
  60057. */
  60058. get output(): NodeMaterialConnectionPoint;
  60059. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60060. /**
  60061. * Exposes the properties to the UI?
  60062. */
  60063. protected _dumpPropertiesCode(): string;
  60064. /**
  60065. * Exposes the properties to the Seralize?
  60066. */
  60067. serialize(): any;
  60068. /**
  60069. * Exposes the properties to the deseralize?
  60070. */
  60071. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60072. }
  60073. }
  60074. declare module BABYLON {
  60075. /**
  60076. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60077. */
  60078. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60079. /**
  60080. * Creates a new SimplexPerlin3DBlock
  60081. * @param name defines the block name
  60082. */
  60083. constructor(name: string);
  60084. /**
  60085. * Gets the current class name
  60086. * @returns the class name
  60087. */
  60088. getClassName(): string;
  60089. /**
  60090. * Gets the seed operand input component
  60091. */
  60092. get seed(): NodeMaterialConnectionPoint;
  60093. /**
  60094. * Gets the output component
  60095. */
  60096. get output(): NodeMaterialConnectionPoint;
  60097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60098. }
  60099. }
  60100. declare module BABYLON {
  60101. /**
  60102. * Block used to blend normals
  60103. */
  60104. export class NormalBlendBlock extends NodeMaterialBlock {
  60105. /**
  60106. * Creates a new NormalBlendBlock
  60107. * @param name defines the block name
  60108. */
  60109. constructor(name: string);
  60110. /**
  60111. * Gets the current class name
  60112. * @returns the class name
  60113. */
  60114. getClassName(): string;
  60115. /**
  60116. * Gets the first input component
  60117. */
  60118. get normalMap0(): NodeMaterialConnectionPoint;
  60119. /**
  60120. * Gets the second input component
  60121. */
  60122. get normalMap1(): NodeMaterialConnectionPoint;
  60123. /**
  60124. * Gets the output component
  60125. */
  60126. get output(): NodeMaterialConnectionPoint;
  60127. protected _buildBlock(state: NodeMaterialBuildState): this;
  60128. }
  60129. }
  60130. declare module BABYLON {
  60131. /**
  60132. * Block used to rotate a 2d vector by a given angle
  60133. */
  60134. export class Rotate2dBlock extends NodeMaterialBlock {
  60135. /**
  60136. * Creates a new Rotate2dBlock
  60137. * @param name defines the block name
  60138. */
  60139. constructor(name: string);
  60140. /**
  60141. * Gets the current class name
  60142. * @returns the class name
  60143. */
  60144. getClassName(): string;
  60145. /**
  60146. * Gets the input vector
  60147. */
  60148. get input(): NodeMaterialConnectionPoint;
  60149. /**
  60150. * Gets the input angle
  60151. */
  60152. get angle(): NodeMaterialConnectionPoint;
  60153. /**
  60154. * Gets the output component
  60155. */
  60156. get output(): NodeMaterialConnectionPoint;
  60157. autoConfigure(material: NodeMaterial): void;
  60158. protected _buildBlock(state: NodeMaterialBuildState): this;
  60159. }
  60160. }
  60161. declare module BABYLON {
  60162. /**
  60163. * Block used to get the reflected vector from a direction and a normal
  60164. */
  60165. export class ReflectBlock extends NodeMaterialBlock {
  60166. /**
  60167. * Creates a new ReflectBlock
  60168. * @param name defines the block name
  60169. */
  60170. constructor(name: string);
  60171. /**
  60172. * Gets the current class name
  60173. * @returns the class name
  60174. */
  60175. getClassName(): string;
  60176. /**
  60177. * Gets the incident component
  60178. */
  60179. get incident(): NodeMaterialConnectionPoint;
  60180. /**
  60181. * Gets the normal component
  60182. */
  60183. get normal(): NodeMaterialConnectionPoint;
  60184. /**
  60185. * Gets the output component
  60186. */
  60187. get output(): NodeMaterialConnectionPoint;
  60188. protected _buildBlock(state: NodeMaterialBuildState): this;
  60189. }
  60190. }
  60191. declare module BABYLON {
  60192. /**
  60193. * Block used to get the refracted vector from a direction and a normal
  60194. */
  60195. export class RefractBlock extends NodeMaterialBlock {
  60196. /**
  60197. * Creates a new RefractBlock
  60198. * @param name defines the block name
  60199. */
  60200. constructor(name: string);
  60201. /**
  60202. * Gets the current class name
  60203. * @returns the class name
  60204. */
  60205. getClassName(): string;
  60206. /**
  60207. * Gets the incident component
  60208. */
  60209. get incident(): NodeMaterialConnectionPoint;
  60210. /**
  60211. * Gets the normal component
  60212. */
  60213. get normal(): NodeMaterialConnectionPoint;
  60214. /**
  60215. * Gets the index of refraction component
  60216. */
  60217. get ior(): NodeMaterialConnectionPoint;
  60218. /**
  60219. * Gets the output component
  60220. */
  60221. get output(): NodeMaterialConnectionPoint;
  60222. protected _buildBlock(state: NodeMaterialBuildState): this;
  60223. }
  60224. }
  60225. declare module BABYLON {
  60226. /**
  60227. * Block used to desaturate a color
  60228. */
  60229. export class DesaturateBlock extends NodeMaterialBlock {
  60230. /**
  60231. * Creates a new DesaturateBlock
  60232. * @param name defines the block name
  60233. */
  60234. constructor(name: string);
  60235. /**
  60236. * Gets the current class name
  60237. * @returns the class name
  60238. */
  60239. getClassName(): string;
  60240. /**
  60241. * Gets the color operand input component
  60242. */
  60243. get color(): NodeMaterialConnectionPoint;
  60244. /**
  60245. * Gets the level operand input component
  60246. */
  60247. get level(): NodeMaterialConnectionPoint;
  60248. /**
  60249. * Gets the output component
  60250. */
  60251. get output(): NodeMaterialConnectionPoint;
  60252. protected _buildBlock(state: NodeMaterialBuildState): this;
  60253. }
  60254. }
  60255. declare module BABYLON {
  60256. /**
  60257. * Effect Render Options
  60258. */
  60259. export interface IEffectRendererOptions {
  60260. /**
  60261. * Defines the vertices positions.
  60262. */
  60263. positions?: number[];
  60264. /**
  60265. * Defines the indices.
  60266. */
  60267. indices?: number[];
  60268. }
  60269. /**
  60270. * Helper class to render one or more effects
  60271. */
  60272. export class EffectRenderer {
  60273. private engine;
  60274. private static _DefaultOptions;
  60275. private _vertexBuffers;
  60276. private _indexBuffer;
  60277. private _ringBufferIndex;
  60278. private _ringScreenBuffer;
  60279. private _fullscreenViewport;
  60280. private _getNextFrameBuffer;
  60281. /**
  60282. * Creates an effect renderer
  60283. * @param engine the engine to use for rendering
  60284. * @param options defines the options of the effect renderer
  60285. */
  60286. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60287. /**
  60288. * Sets the current viewport in normalized coordinates 0-1
  60289. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60290. */
  60291. setViewport(viewport?: Viewport): void;
  60292. /**
  60293. * Binds the embedded attributes buffer to the effect.
  60294. * @param effect Defines the effect to bind the attributes for
  60295. */
  60296. bindBuffers(effect: Effect): void;
  60297. /**
  60298. * Sets the current effect wrapper to use during draw.
  60299. * The effect needs to be ready before calling this api.
  60300. * This also sets the default full screen position attribute.
  60301. * @param effectWrapper Defines the effect to draw with
  60302. */
  60303. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60304. /**
  60305. * Draws a full screen quad.
  60306. */
  60307. draw(): void;
  60308. /**
  60309. * renders one or more effects to a specified texture
  60310. * @param effectWrappers list of effects to renderer
  60311. * @param outputTexture texture to draw to, if null it will render to the screen
  60312. */
  60313. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60314. /**
  60315. * Disposes of the effect renderer
  60316. */
  60317. dispose(): void;
  60318. }
  60319. /**
  60320. * Options to create an EffectWrapper
  60321. */
  60322. interface EffectWrapperCreationOptions {
  60323. /**
  60324. * Engine to use to create the effect
  60325. */
  60326. engine: ThinEngine;
  60327. /**
  60328. * Fragment shader for the effect
  60329. */
  60330. fragmentShader: string;
  60331. /**
  60332. * Vertex shader for the effect
  60333. */
  60334. vertexShader?: string;
  60335. /**
  60336. * Attributes to use in the shader
  60337. */
  60338. attributeNames?: Array<string>;
  60339. /**
  60340. * Uniforms to use in the shader
  60341. */
  60342. uniformNames?: Array<string>;
  60343. /**
  60344. * Texture sampler names to use in the shader
  60345. */
  60346. samplerNames?: Array<string>;
  60347. /**
  60348. * The friendly name of the effect displayed in Spector.
  60349. */
  60350. name?: string;
  60351. }
  60352. /**
  60353. * Wraps an effect to be used for rendering
  60354. */
  60355. export class EffectWrapper {
  60356. /**
  60357. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60358. */
  60359. onApplyObservable: Observable<{}>;
  60360. /**
  60361. * The underlying effect
  60362. */
  60363. effect: Effect;
  60364. /**
  60365. * Creates an effect to be renderer
  60366. * @param creationOptions options to create the effect
  60367. */
  60368. constructor(creationOptions: EffectWrapperCreationOptions);
  60369. /**
  60370. * Disposes of the effect wrapper
  60371. */
  60372. dispose(): void;
  60373. }
  60374. }
  60375. declare module BABYLON {
  60376. /**
  60377. * Helper class to push actions to a pool of workers.
  60378. */
  60379. export class WorkerPool implements IDisposable {
  60380. private _workerInfos;
  60381. private _pendingActions;
  60382. /**
  60383. * Constructor
  60384. * @param workers Array of workers to use for actions
  60385. */
  60386. constructor(workers: Array<Worker>);
  60387. /**
  60388. * Terminates all workers and clears any pending actions.
  60389. */
  60390. dispose(): void;
  60391. /**
  60392. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60393. * pended until a worker has completed its action.
  60394. * @param action The action to perform. Call onComplete when the action is complete.
  60395. */
  60396. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60397. private _execute;
  60398. }
  60399. }
  60400. declare module BABYLON {
  60401. /**
  60402. * Configuration for Draco compression
  60403. */
  60404. export interface IDracoCompressionConfiguration {
  60405. /**
  60406. * Configuration for the decoder.
  60407. */
  60408. decoder: {
  60409. /**
  60410. * The url to the WebAssembly module.
  60411. */
  60412. wasmUrl?: string;
  60413. /**
  60414. * The url to the WebAssembly binary.
  60415. */
  60416. wasmBinaryUrl?: string;
  60417. /**
  60418. * The url to the fallback JavaScript module.
  60419. */
  60420. fallbackUrl?: string;
  60421. };
  60422. }
  60423. /**
  60424. * Draco compression (https://google.github.io/draco/)
  60425. *
  60426. * This class wraps the Draco module.
  60427. *
  60428. * **Encoder**
  60429. *
  60430. * The encoder is not currently implemented.
  60431. *
  60432. * **Decoder**
  60433. *
  60434. * 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.
  60435. *
  60436. * To update the configuration, use the following code:
  60437. * ```javascript
  60438. * DracoCompression.Configuration = {
  60439. * decoder: {
  60440. * wasmUrl: "<url to the WebAssembly library>",
  60441. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60442. * fallbackUrl: "<url to the fallback JavaScript library>",
  60443. * }
  60444. * };
  60445. * ```
  60446. *
  60447. * 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.
  60448. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60449. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60450. *
  60451. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60452. * ```javascript
  60453. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60454. * ```
  60455. *
  60456. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60457. */
  60458. export class DracoCompression implements IDisposable {
  60459. private _workerPoolPromise?;
  60460. private _decoderModulePromise?;
  60461. /**
  60462. * The configuration. Defaults to the following urls:
  60463. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60464. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60465. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60466. */
  60467. static Configuration: IDracoCompressionConfiguration;
  60468. /**
  60469. * Returns true if the decoder configuration is available.
  60470. */
  60471. static get DecoderAvailable(): boolean;
  60472. /**
  60473. * Default number of workers to create when creating the draco compression object.
  60474. */
  60475. static DefaultNumWorkers: number;
  60476. private static GetDefaultNumWorkers;
  60477. private static _Default;
  60478. /**
  60479. * Default instance for the draco compression object.
  60480. */
  60481. static get Default(): DracoCompression;
  60482. /**
  60483. * Constructor
  60484. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60485. */
  60486. constructor(numWorkers?: number);
  60487. /**
  60488. * Stop all async operations and release resources.
  60489. */
  60490. dispose(): void;
  60491. /**
  60492. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60493. * @returns a promise that resolves when ready
  60494. */
  60495. whenReadyAsync(): Promise<void>;
  60496. /**
  60497. * Decode Draco compressed mesh data to vertex data.
  60498. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60499. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60500. * @returns A promise that resolves with the decoded vertex data
  60501. */
  60502. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60503. [kind: string]: number;
  60504. }): Promise<VertexData>;
  60505. }
  60506. }
  60507. declare module BABYLON {
  60508. /**
  60509. * Class for building Constructive Solid Geometry
  60510. */
  60511. export class CSG {
  60512. private polygons;
  60513. /**
  60514. * The world matrix
  60515. */
  60516. matrix: Matrix;
  60517. /**
  60518. * Stores the position
  60519. */
  60520. position: Vector3;
  60521. /**
  60522. * Stores the rotation
  60523. */
  60524. rotation: Vector3;
  60525. /**
  60526. * Stores the rotation quaternion
  60527. */
  60528. rotationQuaternion: Nullable<Quaternion>;
  60529. /**
  60530. * Stores the scaling vector
  60531. */
  60532. scaling: Vector3;
  60533. /**
  60534. * Convert the Mesh to CSG
  60535. * @param mesh The Mesh to convert to CSG
  60536. * @returns A new CSG from the Mesh
  60537. */
  60538. static FromMesh(mesh: Mesh): CSG;
  60539. /**
  60540. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60541. * @param polygons Polygons used to construct a CSG solid
  60542. */
  60543. private static FromPolygons;
  60544. /**
  60545. * Clones, or makes a deep copy, of the CSG
  60546. * @returns A new CSG
  60547. */
  60548. clone(): CSG;
  60549. /**
  60550. * Unions this CSG with another CSG
  60551. * @param csg The CSG to union against this CSG
  60552. * @returns The unioned CSG
  60553. */
  60554. union(csg: CSG): CSG;
  60555. /**
  60556. * Unions this CSG with another CSG in place
  60557. * @param csg The CSG to union against this CSG
  60558. */
  60559. unionInPlace(csg: CSG): void;
  60560. /**
  60561. * Subtracts this CSG with another CSG
  60562. * @param csg The CSG to subtract against this CSG
  60563. * @returns A new CSG
  60564. */
  60565. subtract(csg: CSG): CSG;
  60566. /**
  60567. * Subtracts this CSG with another CSG in place
  60568. * @param csg The CSG to subtact against this CSG
  60569. */
  60570. subtractInPlace(csg: CSG): void;
  60571. /**
  60572. * Intersect this CSG with another CSG
  60573. * @param csg The CSG to intersect against this CSG
  60574. * @returns A new CSG
  60575. */
  60576. intersect(csg: CSG): CSG;
  60577. /**
  60578. * Intersects this CSG with another CSG in place
  60579. * @param csg The CSG to intersect against this CSG
  60580. */
  60581. intersectInPlace(csg: CSG): void;
  60582. /**
  60583. * Return a new CSG solid with solid and empty space switched. This solid is
  60584. * not modified.
  60585. * @returns A new CSG solid with solid and empty space switched
  60586. */
  60587. inverse(): CSG;
  60588. /**
  60589. * Inverses the CSG in place
  60590. */
  60591. inverseInPlace(): void;
  60592. /**
  60593. * This is used to keep meshes transformations so they can be restored
  60594. * when we build back a Babylon Mesh
  60595. * NB : All CSG operations are performed in world coordinates
  60596. * @param csg The CSG to copy the transform attributes from
  60597. * @returns This CSG
  60598. */
  60599. copyTransformAttributes(csg: CSG): CSG;
  60600. /**
  60601. * Build Raw mesh from CSG
  60602. * Coordinates here are in world space
  60603. * @param name The name of the mesh geometry
  60604. * @param scene The Scene
  60605. * @param keepSubMeshes Specifies if the submeshes should be kept
  60606. * @returns A new Mesh
  60607. */
  60608. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60609. /**
  60610. * Build Mesh from CSG taking material and transforms into account
  60611. * @param name The name of the Mesh
  60612. * @param material The material of the Mesh
  60613. * @param scene The Scene
  60614. * @param keepSubMeshes Specifies if submeshes should be kept
  60615. * @returns The new Mesh
  60616. */
  60617. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60618. }
  60619. }
  60620. declare module BABYLON {
  60621. /**
  60622. * Class used to create a trail following a mesh
  60623. */
  60624. export class TrailMesh extends Mesh {
  60625. private _generator;
  60626. private _autoStart;
  60627. private _running;
  60628. private _diameter;
  60629. private _length;
  60630. private _sectionPolygonPointsCount;
  60631. private _sectionVectors;
  60632. private _sectionNormalVectors;
  60633. private _beforeRenderObserver;
  60634. /**
  60635. * @constructor
  60636. * @param name The value used by scene.getMeshByName() to do a lookup.
  60637. * @param generator The mesh or transform node to generate a trail.
  60638. * @param scene The scene to add this mesh to.
  60639. * @param diameter Diameter of trailing mesh. Default is 1.
  60640. * @param length Length of trailing mesh. Default is 60.
  60641. * @param autoStart Automatically start trailing mesh. Default true.
  60642. */
  60643. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60644. /**
  60645. * "TrailMesh"
  60646. * @returns "TrailMesh"
  60647. */
  60648. getClassName(): string;
  60649. private _createMesh;
  60650. /**
  60651. * Start trailing mesh.
  60652. */
  60653. start(): void;
  60654. /**
  60655. * Stop trailing mesh.
  60656. */
  60657. stop(): void;
  60658. /**
  60659. * Update trailing mesh geometry.
  60660. */
  60661. update(): void;
  60662. /**
  60663. * Returns a new TrailMesh object.
  60664. * @param name is a string, the name given to the new mesh
  60665. * @param newGenerator use new generator object for cloned trail mesh
  60666. * @returns a new mesh
  60667. */
  60668. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60669. /**
  60670. * Serializes this trail mesh
  60671. * @param serializationObject object to write serialization to
  60672. */
  60673. serialize(serializationObject: any): void;
  60674. /**
  60675. * Parses a serialized trail mesh
  60676. * @param parsedMesh the serialized mesh
  60677. * @param scene the scene to create the trail mesh in
  60678. * @returns the created trail mesh
  60679. */
  60680. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60681. }
  60682. }
  60683. declare module BABYLON {
  60684. /**
  60685. * Class containing static functions to help procedurally build meshes
  60686. */
  60687. export class TiledBoxBuilder {
  60688. /**
  60689. * Creates a box mesh
  60690. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  60691. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60693. * * 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
  60694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60695. * @param name defines the name of the mesh
  60696. * @param options defines the options used to create the mesh
  60697. * @param scene defines the hosting scene
  60698. * @returns the box mesh
  60699. */
  60700. static CreateTiledBox(name: string, options: {
  60701. pattern?: number;
  60702. width?: number;
  60703. height?: number;
  60704. depth?: number;
  60705. tileSize?: number;
  60706. tileWidth?: number;
  60707. tileHeight?: number;
  60708. alignHorizontal?: number;
  60709. alignVertical?: number;
  60710. faceUV?: Vector4[];
  60711. faceColors?: Color4[];
  60712. sideOrientation?: number;
  60713. updatable?: boolean;
  60714. }, scene?: Nullable<Scene>): Mesh;
  60715. }
  60716. }
  60717. declare module BABYLON {
  60718. /**
  60719. * Class containing static functions to help procedurally build meshes
  60720. */
  60721. export class TorusKnotBuilder {
  60722. /**
  60723. * Creates a torus knot mesh
  60724. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60725. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60726. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60727. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60729. * * 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
  60730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60731. * @param name defines the name of the mesh
  60732. * @param options defines the options used to create the mesh
  60733. * @param scene defines the hosting scene
  60734. * @returns the torus knot mesh
  60735. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60736. */
  60737. static CreateTorusKnot(name: string, options: {
  60738. radius?: number;
  60739. tube?: number;
  60740. radialSegments?: number;
  60741. tubularSegments?: number;
  60742. p?: number;
  60743. q?: number;
  60744. updatable?: boolean;
  60745. sideOrientation?: number;
  60746. frontUVs?: Vector4;
  60747. backUVs?: Vector4;
  60748. }, scene: any): Mesh;
  60749. }
  60750. }
  60751. declare module BABYLON {
  60752. /**
  60753. * Polygon
  60754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60755. */
  60756. export class Polygon {
  60757. /**
  60758. * Creates a rectangle
  60759. * @param xmin bottom X coord
  60760. * @param ymin bottom Y coord
  60761. * @param xmax top X coord
  60762. * @param ymax top Y coord
  60763. * @returns points that make the resulting rectation
  60764. */
  60765. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60766. /**
  60767. * Creates a circle
  60768. * @param radius radius of circle
  60769. * @param cx scale in x
  60770. * @param cy scale in y
  60771. * @param numberOfSides number of sides that make up the circle
  60772. * @returns points that make the resulting circle
  60773. */
  60774. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60775. /**
  60776. * Creates a polygon from input string
  60777. * @param input Input polygon data
  60778. * @returns the parsed points
  60779. */
  60780. static Parse(input: string): Vector2[];
  60781. /**
  60782. * Starts building a polygon from x and y coordinates
  60783. * @param x x coordinate
  60784. * @param y y coordinate
  60785. * @returns the started path2
  60786. */
  60787. static StartingAt(x: number, y: number): Path2;
  60788. }
  60789. /**
  60790. * Builds a polygon
  60791. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60792. */
  60793. export class PolygonMeshBuilder {
  60794. private _points;
  60795. private _outlinepoints;
  60796. private _holes;
  60797. private _name;
  60798. private _scene;
  60799. private _epoints;
  60800. private _eholes;
  60801. private _addToepoint;
  60802. /**
  60803. * Babylon reference to the earcut plugin.
  60804. */
  60805. bjsEarcut: any;
  60806. /**
  60807. * Creates a PolygonMeshBuilder
  60808. * @param name name of the builder
  60809. * @param contours Path of the polygon
  60810. * @param scene scene to add to when creating the mesh
  60811. * @param earcutInjection can be used to inject your own earcut reference
  60812. */
  60813. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60814. /**
  60815. * Adds a whole within the polygon
  60816. * @param hole Array of points defining the hole
  60817. * @returns this
  60818. */
  60819. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60820. /**
  60821. * Creates the polygon
  60822. * @param updatable If the mesh should be updatable
  60823. * @param depth The depth of the mesh created
  60824. * @returns the created mesh
  60825. */
  60826. build(updatable?: boolean, depth?: number): Mesh;
  60827. /**
  60828. * Creates the polygon
  60829. * @param depth The depth of the mesh created
  60830. * @returns the created VertexData
  60831. */
  60832. buildVertexData(depth?: number): VertexData;
  60833. /**
  60834. * Adds a side to the polygon
  60835. * @param positions points that make the polygon
  60836. * @param normals normals of the polygon
  60837. * @param uvs uvs of the polygon
  60838. * @param indices indices of the polygon
  60839. * @param bounds bounds of the polygon
  60840. * @param points points of the polygon
  60841. * @param depth depth of the polygon
  60842. * @param flip flip of the polygon
  60843. */
  60844. private addSide;
  60845. }
  60846. }
  60847. declare module BABYLON {
  60848. /**
  60849. * Class containing static functions to help procedurally build meshes
  60850. */
  60851. export class PolygonBuilder {
  60852. /**
  60853. * Creates a polygon mesh
  60854. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60855. * * 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
  60856. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60858. * * 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)
  60859. * * Remember you can only change the shape positions, not their number when updating a polygon
  60860. * @param name defines the name of the mesh
  60861. * @param options defines the options used to create the mesh
  60862. * @param scene defines the hosting scene
  60863. * @param earcutInjection can be used to inject your own earcut reference
  60864. * @returns the polygon mesh
  60865. */
  60866. static CreatePolygon(name: string, options: {
  60867. shape: Vector3[];
  60868. holes?: Vector3[][];
  60869. depth?: number;
  60870. faceUV?: Vector4[];
  60871. faceColors?: Color4[];
  60872. updatable?: boolean;
  60873. sideOrientation?: number;
  60874. frontUVs?: Vector4;
  60875. backUVs?: Vector4;
  60876. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60877. /**
  60878. * Creates an extruded polygon mesh, with depth in the Y direction.
  60879. * * 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)
  60880. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60881. * @param name defines the name of the mesh
  60882. * @param options defines the options used to create the mesh
  60883. * @param scene defines the hosting scene
  60884. * @param earcutInjection can be used to inject your own earcut reference
  60885. * @returns the polygon mesh
  60886. */
  60887. static ExtrudePolygon(name: string, options: {
  60888. shape: Vector3[];
  60889. holes?: Vector3[][];
  60890. depth?: number;
  60891. faceUV?: Vector4[];
  60892. faceColors?: Color4[];
  60893. updatable?: boolean;
  60894. sideOrientation?: number;
  60895. frontUVs?: Vector4;
  60896. backUVs?: Vector4;
  60897. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60898. }
  60899. }
  60900. declare module BABYLON {
  60901. /**
  60902. * Class containing static functions to help procedurally build meshes
  60903. */
  60904. export class LatheBuilder {
  60905. /**
  60906. * Creates lathe mesh.
  60907. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60908. * * 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
  60909. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60910. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60911. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60912. * * 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
  60913. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60914. * * 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
  60915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60916. * * 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
  60917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60919. * @param name defines the name of the mesh
  60920. * @param options defines the options used to create the mesh
  60921. * @param scene defines the hosting scene
  60922. * @returns the lathe mesh
  60923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60924. */
  60925. static CreateLathe(name: string, options: {
  60926. shape: Vector3[];
  60927. radius?: number;
  60928. tessellation?: number;
  60929. clip?: number;
  60930. arc?: number;
  60931. closed?: boolean;
  60932. updatable?: boolean;
  60933. sideOrientation?: number;
  60934. frontUVs?: Vector4;
  60935. backUVs?: Vector4;
  60936. cap?: number;
  60937. invertUV?: boolean;
  60938. }, scene?: Nullable<Scene>): Mesh;
  60939. }
  60940. }
  60941. declare module BABYLON {
  60942. /**
  60943. * Class containing static functions to help procedurally build meshes
  60944. */
  60945. export class TiledPlaneBuilder {
  60946. /**
  60947. * Creates a tiled plane mesh
  60948. * * The parameter `pattern` will, depending on value, do nothing or
  60949. * * * flip (reflect about central vertical) alternate tiles across and up
  60950. * * * flip every tile on alternate rows
  60951. * * * rotate (180 degs) alternate tiles across and up
  60952. * * * rotate every tile on alternate rows
  60953. * * * flip and rotate alternate tiles across and up
  60954. * * * flip and rotate every tile on alternate rows
  60955. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60956. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60957. * * 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
  60958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60959. * * 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)
  60960. * * 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)
  60961. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60962. * @param name defines the name of the mesh
  60963. * @param options defines the options used to create the mesh
  60964. * @param scene defines the hosting scene
  60965. * @returns the box mesh
  60966. */
  60967. static CreateTiledPlane(name: string, options: {
  60968. pattern?: number;
  60969. tileSize?: number;
  60970. tileWidth?: number;
  60971. tileHeight?: number;
  60972. size?: number;
  60973. width?: number;
  60974. height?: number;
  60975. alignHorizontal?: number;
  60976. alignVertical?: number;
  60977. sideOrientation?: number;
  60978. frontUVs?: Vector4;
  60979. backUVs?: Vector4;
  60980. updatable?: boolean;
  60981. }, scene?: Nullable<Scene>): Mesh;
  60982. }
  60983. }
  60984. declare module BABYLON {
  60985. /**
  60986. * Class containing static functions to help procedurally build meshes
  60987. */
  60988. export class TubeBuilder {
  60989. /**
  60990. * Creates a tube mesh.
  60991. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60992. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60993. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60994. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60995. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60996. * * 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)
  60997. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60998. * * 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
  60999. * * 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
  61000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61001. * * 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
  61002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61004. * @param name defines the name of the mesh
  61005. * @param options defines the options used to create the mesh
  61006. * @param scene defines the hosting scene
  61007. * @returns the tube mesh
  61008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61009. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61010. */
  61011. static CreateTube(name: string, options: {
  61012. path: Vector3[];
  61013. radius?: number;
  61014. tessellation?: number;
  61015. radiusFunction?: {
  61016. (i: number, distance: number): number;
  61017. };
  61018. cap?: number;
  61019. arc?: number;
  61020. updatable?: boolean;
  61021. sideOrientation?: number;
  61022. frontUVs?: Vector4;
  61023. backUVs?: Vector4;
  61024. instance?: Mesh;
  61025. invertUV?: boolean;
  61026. }, scene?: Nullable<Scene>): Mesh;
  61027. }
  61028. }
  61029. declare module BABYLON {
  61030. /**
  61031. * Class containing static functions to help procedurally build meshes
  61032. */
  61033. export class IcoSphereBuilder {
  61034. /**
  61035. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61036. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61037. * * 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`)
  61038. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61039. * * 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
  61040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61041. * * 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
  61042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61043. * @param name defines the name of the mesh
  61044. * @param options defines the options used to create the mesh
  61045. * @param scene defines the hosting scene
  61046. * @returns the icosahedron mesh
  61047. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61048. */
  61049. static CreateIcoSphere(name: string, options: {
  61050. radius?: number;
  61051. radiusX?: number;
  61052. radiusY?: number;
  61053. radiusZ?: number;
  61054. flat?: boolean;
  61055. subdivisions?: number;
  61056. sideOrientation?: number;
  61057. frontUVs?: Vector4;
  61058. backUVs?: Vector4;
  61059. updatable?: boolean;
  61060. }, scene?: Nullable<Scene>): Mesh;
  61061. }
  61062. }
  61063. declare module BABYLON {
  61064. /**
  61065. * Class containing static functions to help procedurally build meshes
  61066. */
  61067. export class DecalBuilder {
  61068. /**
  61069. * Creates a decal mesh.
  61070. * 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
  61071. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61072. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61073. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61074. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61075. * @param name defines the name of the mesh
  61076. * @param sourceMesh defines the mesh where the decal must be applied
  61077. * @param options defines the options used to create the mesh
  61078. * @param scene defines the hosting scene
  61079. * @returns the decal mesh
  61080. * @see https://doc.babylonjs.com/how_to/decals
  61081. */
  61082. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61083. position?: Vector3;
  61084. normal?: Vector3;
  61085. size?: Vector3;
  61086. angle?: number;
  61087. }): Mesh;
  61088. }
  61089. }
  61090. declare module BABYLON {
  61091. /**
  61092. * Class containing static functions to help procedurally build meshes
  61093. */
  61094. export class MeshBuilder {
  61095. /**
  61096. * Creates a box mesh
  61097. * * The parameter `size` sets the size (float) of each box side (default 1)
  61098. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61099. * * 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)
  61100. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61102. * * 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
  61103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61104. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61105. * @param name defines the name of the mesh
  61106. * @param options defines the options used to create the mesh
  61107. * @param scene defines the hosting scene
  61108. * @returns the box mesh
  61109. */
  61110. static CreateBox(name: string, options: {
  61111. size?: number;
  61112. width?: number;
  61113. height?: number;
  61114. depth?: number;
  61115. faceUV?: Vector4[];
  61116. faceColors?: Color4[];
  61117. sideOrientation?: number;
  61118. frontUVs?: Vector4;
  61119. backUVs?: Vector4;
  61120. updatable?: boolean;
  61121. }, scene?: Nullable<Scene>): Mesh;
  61122. /**
  61123. * Creates a tiled box mesh
  61124. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61126. * @param name defines the name of the mesh
  61127. * @param options defines the options used to create the mesh
  61128. * @param scene defines the hosting scene
  61129. * @returns the tiled box mesh
  61130. */
  61131. static CreateTiledBox(name: string, options: {
  61132. pattern?: number;
  61133. size?: number;
  61134. width?: number;
  61135. height?: number;
  61136. depth: number;
  61137. tileSize?: number;
  61138. tileWidth?: number;
  61139. tileHeight?: number;
  61140. faceUV?: Vector4[];
  61141. faceColors?: Color4[];
  61142. alignHorizontal?: number;
  61143. alignVertical?: number;
  61144. sideOrientation?: number;
  61145. updatable?: boolean;
  61146. }, scene?: Nullable<Scene>): Mesh;
  61147. /**
  61148. * Creates a sphere mesh
  61149. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61150. * * 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`)
  61151. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61152. * * 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
  61153. * * 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)
  61154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61155. * * 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
  61156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61157. * @param name defines the name of the mesh
  61158. * @param options defines the options used to create the mesh
  61159. * @param scene defines the hosting scene
  61160. * @returns the sphere mesh
  61161. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61162. */
  61163. static CreateSphere(name: string, options: {
  61164. segments?: number;
  61165. diameter?: number;
  61166. diameterX?: number;
  61167. diameterY?: number;
  61168. diameterZ?: number;
  61169. arc?: number;
  61170. slice?: number;
  61171. sideOrientation?: number;
  61172. frontUVs?: Vector4;
  61173. backUVs?: Vector4;
  61174. updatable?: boolean;
  61175. }, scene?: Nullable<Scene>): Mesh;
  61176. /**
  61177. * Creates a plane polygonal mesh. By default, this is a disc
  61178. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61179. * * 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
  61180. * * 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
  61181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61182. * * 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
  61183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61184. * @param name defines the name of the mesh
  61185. * @param options defines the options used to create the mesh
  61186. * @param scene defines the hosting scene
  61187. * @returns the plane polygonal mesh
  61188. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61189. */
  61190. static CreateDisc(name: string, options: {
  61191. radius?: number;
  61192. tessellation?: number;
  61193. arc?: number;
  61194. updatable?: boolean;
  61195. sideOrientation?: number;
  61196. frontUVs?: Vector4;
  61197. backUVs?: Vector4;
  61198. }, scene?: Nullable<Scene>): Mesh;
  61199. /**
  61200. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61201. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61202. * * 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`)
  61203. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61204. * * 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
  61205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61206. * * 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
  61207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61208. * @param name defines the name of the mesh
  61209. * @param options defines the options used to create the mesh
  61210. * @param scene defines the hosting scene
  61211. * @returns the icosahedron mesh
  61212. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61213. */
  61214. static CreateIcoSphere(name: string, options: {
  61215. radius?: number;
  61216. radiusX?: number;
  61217. radiusY?: number;
  61218. radiusZ?: number;
  61219. flat?: boolean;
  61220. subdivisions?: number;
  61221. sideOrientation?: number;
  61222. frontUVs?: Vector4;
  61223. backUVs?: Vector4;
  61224. updatable?: boolean;
  61225. }, scene?: Nullable<Scene>): Mesh;
  61226. /**
  61227. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61228. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61229. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61230. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61231. * * 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
  61232. * * 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
  61233. * * 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
  61234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61235. * * 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
  61236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61237. * * 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
  61238. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61239. * * 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
  61240. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61242. * @param name defines the name of the mesh
  61243. * @param options defines the options used to create the mesh
  61244. * @param scene defines the hosting scene
  61245. * @returns the ribbon mesh
  61246. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61247. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61248. */
  61249. static CreateRibbon(name: string, options: {
  61250. pathArray: Vector3[][];
  61251. closeArray?: boolean;
  61252. closePath?: boolean;
  61253. offset?: number;
  61254. updatable?: boolean;
  61255. sideOrientation?: number;
  61256. frontUVs?: Vector4;
  61257. backUVs?: Vector4;
  61258. instance?: Mesh;
  61259. invertUV?: boolean;
  61260. uvs?: Vector2[];
  61261. colors?: Color4[];
  61262. }, scene?: Nullable<Scene>): Mesh;
  61263. /**
  61264. * Creates a cylinder or a cone mesh
  61265. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61266. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61267. * * 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.
  61268. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61269. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61270. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61271. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61272. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  61273. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61274. * * 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).
  61275. * * 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
  61276. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61277. * * 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
  61278. * * 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.
  61279. * * If `enclose` is false, a ring surface is one element.
  61280. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61281. * * 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
  61282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61283. * * 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
  61284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61285. * @param name defines the name of the mesh
  61286. * @param options defines the options used to create the mesh
  61287. * @param scene defines the hosting scene
  61288. * @returns the cylinder mesh
  61289. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61290. */
  61291. static CreateCylinder(name: string, options: {
  61292. height?: number;
  61293. diameterTop?: number;
  61294. diameterBottom?: number;
  61295. diameter?: number;
  61296. tessellation?: number;
  61297. subdivisions?: number;
  61298. arc?: number;
  61299. faceColors?: Color4[];
  61300. faceUV?: Vector4[];
  61301. updatable?: boolean;
  61302. hasRings?: boolean;
  61303. enclose?: boolean;
  61304. cap?: number;
  61305. sideOrientation?: number;
  61306. frontUVs?: Vector4;
  61307. backUVs?: Vector4;
  61308. }, scene?: Nullable<Scene>): Mesh;
  61309. /**
  61310. * Creates a torus mesh
  61311. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61312. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61313. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61315. * * 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
  61316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61317. * @param name defines the name of the mesh
  61318. * @param options defines the options used to create the mesh
  61319. * @param scene defines the hosting scene
  61320. * @returns the torus mesh
  61321. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61322. */
  61323. static CreateTorus(name: string, options: {
  61324. diameter?: number;
  61325. thickness?: number;
  61326. tessellation?: number;
  61327. updatable?: boolean;
  61328. sideOrientation?: number;
  61329. frontUVs?: Vector4;
  61330. backUVs?: Vector4;
  61331. }, scene?: Nullable<Scene>): Mesh;
  61332. /**
  61333. * Creates a torus knot mesh
  61334. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61335. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61336. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61337. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61339. * * 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
  61340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61341. * @param name defines the name of the mesh
  61342. * @param options defines the options used to create the mesh
  61343. * @param scene defines the hosting scene
  61344. * @returns the torus knot mesh
  61345. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61346. */
  61347. static CreateTorusKnot(name: string, options: {
  61348. radius?: number;
  61349. tube?: number;
  61350. radialSegments?: number;
  61351. tubularSegments?: number;
  61352. p?: number;
  61353. q?: number;
  61354. updatable?: boolean;
  61355. sideOrientation?: number;
  61356. frontUVs?: Vector4;
  61357. backUVs?: Vector4;
  61358. }, scene?: Nullable<Scene>): Mesh;
  61359. /**
  61360. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61361. * * 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
  61362. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61363. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61364. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61365. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61366. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61367. * * 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
  61368. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61371. * @param name defines the name of the new line system
  61372. * @param options defines the options used to create the line system
  61373. * @param scene defines the hosting scene
  61374. * @returns a new line system mesh
  61375. */
  61376. static CreateLineSystem(name: string, options: {
  61377. lines: Vector3[][];
  61378. updatable?: boolean;
  61379. instance?: Nullable<LinesMesh>;
  61380. colors?: Nullable<Color4[][]>;
  61381. useVertexAlpha?: boolean;
  61382. }, scene: Nullable<Scene>): LinesMesh;
  61383. /**
  61384. * Creates a line mesh
  61385. * 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
  61386. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61387. * * The parameter `points` is an array successive Vector3
  61388. * * 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
  61389. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61390. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61391. * * When updating an instance, remember that only point positions can change, not the number of points
  61392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61394. * @param name defines the name of the new line system
  61395. * @param options defines the options used to create the line system
  61396. * @param scene defines the hosting scene
  61397. * @returns a new line mesh
  61398. */
  61399. static CreateLines(name: string, options: {
  61400. points: Vector3[];
  61401. updatable?: boolean;
  61402. instance?: Nullable<LinesMesh>;
  61403. colors?: Color4[];
  61404. useVertexAlpha?: boolean;
  61405. }, scene?: Nullable<Scene>): LinesMesh;
  61406. /**
  61407. * Creates a dashed line mesh
  61408. * * 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
  61409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61410. * * The parameter `points` is an array successive Vector3
  61411. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61412. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61413. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61414. * * 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
  61415. * * When updating an instance, remember that only point positions can change, not the number of points
  61416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61417. * @param name defines the name of the mesh
  61418. * @param options defines the options used to create the mesh
  61419. * @param scene defines the hosting scene
  61420. * @returns the dashed line mesh
  61421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61422. */
  61423. static CreateDashedLines(name: string, options: {
  61424. points: Vector3[];
  61425. dashSize?: number;
  61426. gapSize?: number;
  61427. dashNb?: number;
  61428. updatable?: boolean;
  61429. instance?: LinesMesh;
  61430. }, scene?: Nullable<Scene>): LinesMesh;
  61431. /**
  61432. * 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.
  61433. * * 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.
  61434. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61435. * * 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.
  61436. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61437. * * 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
  61438. * * 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
  61439. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61441. * * 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
  61442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61444. * @param name defines the name of the mesh
  61445. * @param options defines the options used to create the mesh
  61446. * @param scene defines the hosting scene
  61447. * @returns the extruded shape mesh
  61448. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61450. */
  61451. static ExtrudeShape(name: string, options: {
  61452. shape: Vector3[];
  61453. path: Vector3[];
  61454. scale?: number;
  61455. rotation?: number;
  61456. cap?: number;
  61457. updatable?: boolean;
  61458. sideOrientation?: number;
  61459. frontUVs?: Vector4;
  61460. backUVs?: Vector4;
  61461. instance?: Mesh;
  61462. invertUV?: boolean;
  61463. }, scene?: Nullable<Scene>): Mesh;
  61464. /**
  61465. * Creates an custom extruded shape mesh.
  61466. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61467. * * 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.
  61468. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61469. * * 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
  61470. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61471. * * 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
  61472. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61473. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61474. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61475. * * 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
  61476. * * 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
  61477. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61479. * * 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
  61480. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61482. * @param name defines the name of the mesh
  61483. * @param options defines the options used to create the mesh
  61484. * @param scene defines the hosting scene
  61485. * @returns the custom extruded shape mesh
  61486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61489. */
  61490. static ExtrudeShapeCustom(name: string, options: {
  61491. shape: Vector3[];
  61492. path: Vector3[];
  61493. scaleFunction?: any;
  61494. rotationFunction?: any;
  61495. ribbonCloseArray?: boolean;
  61496. ribbonClosePath?: boolean;
  61497. cap?: number;
  61498. updatable?: boolean;
  61499. sideOrientation?: number;
  61500. frontUVs?: Vector4;
  61501. backUVs?: Vector4;
  61502. instance?: Mesh;
  61503. invertUV?: boolean;
  61504. }, scene?: Nullable<Scene>): Mesh;
  61505. /**
  61506. * Creates lathe mesh.
  61507. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61508. * * 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
  61509. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61510. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61511. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61512. * * 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
  61513. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61514. * * 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
  61515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61516. * * 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
  61517. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61519. * @param name defines the name of the mesh
  61520. * @param options defines the options used to create the mesh
  61521. * @param scene defines the hosting scene
  61522. * @returns the lathe mesh
  61523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61524. */
  61525. static CreateLathe(name: string, options: {
  61526. shape: Vector3[];
  61527. radius?: number;
  61528. tessellation?: number;
  61529. clip?: number;
  61530. arc?: number;
  61531. closed?: boolean;
  61532. updatable?: boolean;
  61533. sideOrientation?: number;
  61534. frontUVs?: Vector4;
  61535. backUVs?: Vector4;
  61536. cap?: number;
  61537. invertUV?: boolean;
  61538. }, scene?: Nullable<Scene>): Mesh;
  61539. /**
  61540. * Creates a tiled plane mesh
  61541. * * You can set a limited pattern arrangement with the tiles
  61542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61543. * * 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
  61544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61545. * @param name defines the name of the mesh
  61546. * @param options defines the options used to create the mesh
  61547. * @param scene defines the hosting scene
  61548. * @returns the plane mesh
  61549. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61550. */
  61551. static CreateTiledPlane(name: string, options: {
  61552. pattern?: number;
  61553. tileSize?: number;
  61554. tileWidth?: number;
  61555. tileHeight?: number;
  61556. size?: number;
  61557. width?: number;
  61558. height?: number;
  61559. alignHorizontal?: number;
  61560. alignVertical?: number;
  61561. sideOrientation?: number;
  61562. frontUVs?: Vector4;
  61563. backUVs?: Vector4;
  61564. updatable?: boolean;
  61565. }, scene?: Nullable<Scene>): Mesh;
  61566. /**
  61567. * Creates a plane mesh
  61568. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61569. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61570. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61572. * * 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
  61573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61574. * @param name defines the name of the mesh
  61575. * @param options defines the options used to create the mesh
  61576. * @param scene defines the hosting scene
  61577. * @returns the plane mesh
  61578. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61579. */
  61580. static CreatePlane(name: string, options: {
  61581. size?: number;
  61582. width?: number;
  61583. height?: number;
  61584. sideOrientation?: number;
  61585. frontUVs?: Vector4;
  61586. backUVs?: Vector4;
  61587. updatable?: boolean;
  61588. sourcePlane?: Plane;
  61589. }, scene?: Nullable<Scene>): Mesh;
  61590. /**
  61591. * Creates a ground mesh
  61592. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61593. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61595. * @param name defines the name of the mesh
  61596. * @param options defines the options used to create the mesh
  61597. * @param scene defines the hosting scene
  61598. * @returns the ground mesh
  61599. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61600. */
  61601. static CreateGround(name: string, options: {
  61602. width?: number;
  61603. height?: number;
  61604. subdivisions?: number;
  61605. subdivisionsX?: number;
  61606. subdivisionsY?: number;
  61607. updatable?: boolean;
  61608. }, scene?: Nullable<Scene>): Mesh;
  61609. /**
  61610. * Creates a tiled ground mesh
  61611. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61612. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61613. * * 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
  61614. * * 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
  61615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61616. * @param name defines the name of the mesh
  61617. * @param options defines the options used to create the mesh
  61618. * @param scene defines the hosting scene
  61619. * @returns the tiled ground mesh
  61620. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61621. */
  61622. static CreateTiledGround(name: string, options: {
  61623. xmin: number;
  61624. zmin: number;
  61625. xmax: number;
  61626. zmax: number;
  61627. subdivisions?: {
  61628. w: number;
  61629. h: number;
  61630. };
  61631. precision?: {
  61632. w: number;
  61633. h: number;
  61634. };
  61635. updatable?: boolean;
  61636. }, scene?: Nullable<Scene>): Mesh;
  61637. /**
  61638. * Creates a ground mesh from a height map
  61639. * * The parameter `url` sets the URL of the height map image resource.
  61640. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61641. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61642. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61643. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61644. * * 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.
  61645. * * 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).
  61646. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61648. * @param name defines the name of the mesh
  61649. * @param url defines the url to the height map
  61650. * @param options defines the options used to create the mesh
  61651. * @param scene defines the hosting scene
  61652. * @returns the ground mesh
  61653. * @see https://doc.babylonjs.com/babylon101/height_map
  61654. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61655. */
  61656. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61657. width?: number;
  61658. height?: number;
  61659. subdivisions?: number;
  61660. minHeight?: number;
  61661. maxHeight?: number;
  61662. colorFilter?: Color3;
  61663. alphaFilter?: number;
  61664. updatable?: boolean;
  61665. onReady?: (mesh: GroundMesh) => void;
  61666. }, scene?: Nullable<Scene>): GroundMesh;
  61667. /**
  61668. * Creates a polygon mesh
  61669. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61670. * * 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
  61671. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61673. * * 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)
  61674. * * Remember you can only change the shape positions, not their number when updating a polygon
  61675. * @param name defines the name of the mesh
  61676. * @param options defines the options used to create the mesh
  61677. * @param scene defines the hosting scene
  61678. * @param earcutInjection can be used to inject your own earcut reference
  61679. * @returns the polygon mesh
  61680. */
  61681. static CreatePolygon(name: string, options: {
  61682. shape: Vector3[];
  61683. holes?: Vector3[][];
  61684. depth?: number;
  61685. faceUV?: Vector4[];
  61686. faceColors?: Color4[];
  61687. updatable?: boolean;
  61688. sideOrientation?: number;
  61689. frontUVs?: Vector4;
  61690. backUVs?: Vector4;
  61691. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61692. /**
  61693. * Creates an extruded polygon mesh, with depth in the Y direction.
  61694. * * 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)
  61695. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61696. * @param name defines the name of the mesh
  61697. * @param options defines the options used to create the mesh
  61698. * @param scene defines the hosting scene
  61699. * @param earcutInjection can be used to inject your own earcut reference
  61700. * @returns the polygon mesh
  61701. */
  61702. static ExtrudePolygon(name: string, options: {
  61703. shape: Vector3[];
  61704. holes?: Vector3[][];
  61705. depth?: number;
  61706. faceUV?: Vector4[];
  61707. faceColors?: Color4[];
  61708. updatable?: boolean;
  61709. sideOrientation?: number;
  61710. frontUVs?: Vector4;
  61711. backUVs?: Vector4;
  61712. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61713. /**
  61714. * Creates a tube mesh.
  61715. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61716. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61717. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61718. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61719. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61720. * * 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)
  61721. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61722. * * 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
  61723. * * 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
  61724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61725. * * 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
  61726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61728. * @param name defines the name of the mesh
  61729. * @param options defines the options used to create the mesh
  61730. * @param scene defines the hosting scene
  61731. * @returns the tube mesh
  61732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61733. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61734. */
  61735. static CreateTube(name: string, options: {
  61736. path: Vector3[];
  61737. radius?: number;
  61738. tessellation?: number;
  61739. radiusFunction?: {
  61740. (i: number, distance: number): number;
  61741. };
  61742. cap?: number;
  61743. arc?: number;
  61744. updatable?: boolean;
  61745. sideOrientation?: number;
  61746. frontUVs?: Vector4;
  61747. backUVs?: Vector4;
  61748. instance?: Mesh;
  61749. invertUV?: boolean;
  61750. }, scene?: Nullable<Scene>): Mesh;
  61751. /**
  61752. * Creates a polyhedron mesh
  61753. * * 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
  61754. * * The parameter `size` (positive float, default 1) sets the polygon size
  61755. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61756. * * 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`
  61757. * * 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
  61758. * * 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)`)
  61759. * * 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
  61760. * * 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
  61761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61762. * * 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
  61763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61764. * @param name defines the name of the mesh
  61765. * @param options defines the options used to create the mesh
  61766. * @param scene defines the hosting scene
  61767. * @returns the polyhedron mesh
  61768. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61769. */
  61770. static CreatePolyhedron(name: string, options: {
  61771. type?: number;
  61772. size?: number;
  61773. sizeX?: number;
  61774. sizeY?: number;
  61775. sizeZ?: number;
  61776. custom?: any;
  61777. faceUV?: Vector4[];
  61778. faceColors?: Color4[];
  61779. flat?: boolean;
  61780. updatable?: boolean;
  61781. sideOrientation?: number;
  61782. frontUVs?: Vector4;
  61783. backUVs?: Vector4;
  61784. }, scene?: Nullable<Scene>): Mesh;
  61785. /**
  61786. * Creates a decal mesh.
  61787. * 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
  61788. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61789. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61790. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61791. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61792. * @param name defines the name of the mesh
  61793. * @param sourceMesh defines the mesh where the decal must be applied
  61794. * @param options defines the options used to create the mesh
  61795. * @param scene defines the hosting scene
  61796. * @returns the decal mesh
  61797. * @see https://doc.babylonjs.com/how_to/decals
  61798. */
  61799. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61800. position?: Vector3;
  61801. normal?: Vector3;
  61802. size?: Vector3;
  61803. angle?: number;
  61804. }): Mesh;
  61805. }
  61806. }
  61807. declare module BABYLON {
  61808. /**
  61809. * A simplifier interface for future simplification implementations
  61810. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61811. */
  61812. export interface ISimplifier {
  61813. /**
  61814. * Simplification of a given mesh according to the given settings.
  61815. * Since this requires computation, it is assumed that the function runs async.
  61816. * @param settings The settings of the simplification, including quality and distance
  61817. * @param successCallback A callback that will be called after the mesh was simplified.
  61818. * @param errorCallback in case of an error, this callback will be called. optional.
  61819. */
  61820. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61821. }
  61822. /**
  61823. * Expected simplification settings.
  61824. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61825. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61826. */
  61827. export interface ISimplificationSettings {
  61828. /**
  61829. * Gets or sets the expected quality
  61830. */
  61831. quality: number;
  61832. /**
  61833. * Gets or sets the distance when this optimized version should be used
  61834. */
  61835. distance: number;
  61836. /**
  61837. * Gets an already optimized mesh
  61838. */
  61839. optimizeMesh?: boolean;
  61840. }
  61841. /**
  61842. * Class used to specify simplification options
  61843. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61844. */
  61845. export class SimplificationSettings implements ISimplificationSettings {
  61846. /** expected quality */
  61847. quality: number;
  61848. /** distance when this optimized version should be used */
  61849. distance: number;
  61850. /** already optimized mesh */
  61851. optimizeMesh?: boolean | undefined;
  61852. /**
  61853. * Creates a SimplificationSettings
  61854. * @param quality expected quality
  61855. * @param distance distance when this optimized version should be used
  61856. * @param optimizeMesh already optimized mesh
  61857. */
  61858. constructor(
  61859. /** expected quality */
  61860. quality: number,
  61861. /** distance when this optimized version should be used */
  61862. distance: number,
  61863. /** already optimized mesh */
  61864. optimizeMesh?: boolean | undefined);
  61865. }
  61866. /**
  61867. * Interface used to define a simplification task
  61868. */
  61869. export interface ISimplificationTask {
  61870. /**
  61871. * Array of settings
  61872. */
  61873. settings: Array<ISimplificationSettings>;
  61874. /**
  61875. * Simplification type
  61876. */
  61877. simplificationType: SimplificationType;
  61878. /**
  61879. * Mesh to simplify
  61880. */
  61881. mesh: Mesh;
  61882. /**
  61883. * Callback called on success
  61884. */
  61885. successCallback?: () => void;
  61886. /**
  61887. * Defines if parallel processing can be used
  61888. */
  61889. parallelProcessing: boolean;
  61890. }
  61891. /**
  61892. * Queue used to order the simplification tasks
  61893. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61894. */
  61895. export class SimplificationQueue {
  61896. private _simplificationArray;
  61897. /**
  61898. * Gets a boolean indicating that the process is still running
  61899. */
  61900. running: boolean;
  61901. /**
  61902. * Creates a new queue
  61903. */
  61904. constructor();
  61905. /**
  61906. * Adds a new simplification task
  61907. * @param task defines a task to add
  61908. */
  61909. addTask(task: ISimplificationTask): void;
  61910. /**
  61911. * Execute next task
  61912. */
  61913. executeNext(): void;
  61914. /**
  61915. * Execute a simplification task
  61916. * @param task defines the task to run
  61917. */
  61918. runSimplification(task: ISimplificationTask): void;
  61919. private getSimplifier;
  61920. }
  61921. /**
  61922. * The implemented types of simplification
  61923. * At the moment only Quadratic Error Decimation is implemented
  61924. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61925. */
  61926. export enum SimplificationType {
  61927. /** Quadratic error decimation */
  61928. QUADRATIC = 0
  61929. }
  61930. /**
  61931. * An implementation of the Quadratic Error simplification algorithm.
  61932. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  61933. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  61934. * @author RaananW
  61935. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61936. */
  61937. export class QuadraticErrorSimplification implements ISimplifier {
  61938. private _mesh;
  61939. private triangles;
  61940. private vertices;
  61941. private references;
  61942. private _reconstructedMesh;
  61943. /** Gets or sets the number pf sync interations */
  61944. syncIterations: number;
  61945. /** Gets or sets the aggressiveness of the simplifier */
  61946. aggressiveness: number;
  61947. /** Gets or sets the number of allowed iterations for decimation */
  61948. decimationIterations: number;
  61949. /** Gets or sets the espilon to use for bounding box computation */
  61950. boundingBoxEpsilon: number;
  61951. /**
  61952. * Creates a new QuadraticErrorSimplification
  61953. * @param _mesh defines the target mesh
  61954. */
  61955. constructor(_mesh: Mesh);
  61956. /**
  61957. * Simplification of a given mesh according to the given settings.
  61958. * Since this requires computation, it is assumed that the function runs async.
  61959. * @param settings The settings of the simplification, including quality and distance
  61960. * @param successCallback A callback that will be called after the mesh was simplified.
  61961. */
  61962. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  61963. private runDecimation;
  61964. private initWithMesh;
  61965. private init;
  61966. private reconstructMesh;
  61967. private initDecimatedMesh;
  61968. private isFlipped;
  61969. private updateTriangles;
  61970. private identifyBorder;
  61971. private updateMesh;
  61972. private vertexError;
  61973. private calculateError;
  61974. }
  61975. }
  61976. declare module BABYLON {
  61977. interface Scene {
  61978. /** @hidden (Backing field) */
  61979. _simplificationQueue: SimplificationQueue;
  61980. /**
  61981. * Gets or sets the simplification queue attached to the scene
  61982. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61983. */
  61984. simplificationQueue: SimplificationQueue;
  61985. }
  61986. interface Mesh {
  61987. /**
  61988. * Simplify the mesh according to the given array of settings.
  61989. * Function will return immediately and will simplify async
  61990. * @param settings a collection of simplification settings
  61991. * @param parallelProcessing should all levels calculate parallel or one after the other
  61992. * @param simplificationType the type of simplification to run
  61993. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61994. * @returns the current mesh
  61995. */
  61996. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61997. }
  61998. /**
  61999. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62000. * created in a scene
  62001. */
  62002. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62003. /**
  62004. * The component name helpfull to identify the component in the list of scene components.
  62005. */
  62006. readonly name: string;
  62007. /**
  62008. * The scene the component belongs to.
  62009. */
  62010. scene: Scene;
  62011. /**
  62012. * Creates a new instance of the component for the given scene
  62013. * @param scene Defines the scene to register the component in
  62014. */
  62015. constructor(scene: Scene);
  62016. /**
  62017. * Registers the component in a given scene
  62018. */
  62019. register(): void;
  62020. /**
  62021. * Rebuilds the elements related to this component in case of
  62022. * context lost for instance.
  62023. */
  62024. rebuild(): void;
  62025. /**
  62026. * Disposes the component and the associated ressources
  62027. */
  62028. dispose(): void;
  62029. private _beforeCameraUpdate;
  62030. }
  62031. }
  62032. declare module BABYLON {
  62033. /**
  62034. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62035. */
  62036. export interface INavigationEnginePlugin {
  62037. /**
  62038. * plugin name
  62039. */
  62040. name: string;
  62041. /**
  62042. * Creates a navigation mesh
  62043. * @param meshes array of all the geometry used to compute the navigatio mesh
  62044. * @param parameters bunch of parameters used to filter geometry
  62045. */
  62046. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62047. /**
  62048. * Create a navigation mesh debug mesh
  62049. * @param scene is where the mesh will be added
  62050. * @returns debug display mesh
  62051. */
  62052. createDebugNavMesh(scene: Scene): Mesh;
  62053. /**
  62054. * Get a navigation mesh constrained position, closest to the parameter position
  62055. * @param position world position
  62056. * @returns the closest point to position constrained by the navigation mesh
  62057. */
  62058. getClosestPoint(position: Vector3): Vector3;
  62059. /**
  62060. * Get a navigation mesh constrained position, within a particular radius
  62061. * @param position world position
  62062. * @param maxRadius the maximum distance to the constrained world position
  62063. * @returns the closest point to position constrained by the navigation mesh
  62064. */
  62065. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62066. /**
  62067. * Compute the final position from a segment made of destination-position
  62068. * @param position world position
  62069. * @param destination world position
  62070. * @returns the resulting point along the navmesh
  62071. */
  62072. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62073. /**
  62074. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62075. * @param start world position
  62076. * @param end world position
  62077. * @returns array containing world position composing the path
  62078. */
  62079. computePath(start: Vector3, end: Vector3): Vector3[];
  62080. /**
  62081. * If this plugin is supported
  62082. * @returns true if plugin is supported
  62083. */
  62084. isSupported(): boolean;
  62085. /**
  62086. * Create a new Crowd so you can add agents
  62087. * @param maxAgents the maximum agent count in the crowd
  62088. * @param maxAgentRadius the maximum radius an agent can have
  62089. * @param scene to attach the crowd to
  62090. * @returns the crowd you can add agents to
  62091. */
  62092. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62093. /**
  62094. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62095. * The queries will try to find a solution within those bounds
  62096. * default is (1,1,1)
  62097. * @param extent x,y,z value that define the extent around the queries point of reference
  62098. */
  62099. setDefaultQueryExtent(extent: Vector3): void;
  62100. /**
  62101. * Get the Bounding box extent specified by setDefaultQueryExtent
  62102. * @returns the box extent values
  62103. */
  62104. getDefaultQueryExtent(): Vector3;
  62105. /**
  62106. * Release all resources
  62107. */
  62108. dispose(): void;
  62109. }
  62110. /**
  62111. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62112. */
  62113. export interface ICrowd {
  62114. /**
  62115. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62116. * You can attach anything to that node. The node position is updated in the scene update tick.
  62117. * @param pos world position that will be constrained by the navigation mesh
  62118. * @param parameters agent parameters
  62119. * @param transform hooked to the agent that will be update by the scene
  62120. * @returns agent index
  62121. */
  62122. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62123. /**
  62124. * Returns the agent position in world space
  62125. * @param index agent index returned by addAgent
  62126. * @returns world space position
  62127. */
  62128. getAgentPosition(index: number): Vector3;
  62129. /**
  62130. * Gets the agent velocity in world space
  62131. * @param index agent index returned by addAgent
  62132. * @returns world space velocity
  62133. */
  62134. getAgentVelocity(index: number): Vector3;
  62135. /**
  62136. * remove a particular agent previously created
  62137. * @param index agent index returned by addAgent
  62138. */
  62139. removeAgent(index: number): void;
  62140. /**
  62141. * get the list of all agents attached to this crowd
  62142. * @returns list of agent indices
  62143. */
  62144. getAgents(): number[];
  62145. /**
  62146. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62147. * @param deltaTime in seconds
  62148. */
  62149. update(deltaTime: number): void;
  62150. /**
  62151. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62152. * @param index agent index returned by addAgent
  62153. * @param destination targeted world position
  62154. */
  62155. agentGoto(index: number, destination: Vector3): void;
  62156. /**
  62157. * Teleport the agent to a new position
  62158. * @param index agent index returned by addAgent
  62159. * @param destination targeted world position
  62160. */
  62161. agentTeleport(index: number, destination: Vector3): void;
  62162. /**
  62163. * Update agent parameters
  62164. * @param index agent index returned by addAgent
  62165. * @param parameters agent parameters
  62166. */
  62167. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62168. /**
  62169. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62170. * The queries will try to find a solution within those bounds
  62171. * default is (1,1,1)
  62172. * @param extent x,y,z value that define the extent around the queries point of reference
  62173. */
  62174. setDefaultQueryExtent(extent: Vector3): void;
  62175. /**
  62176. * Get the Bounding box extent specified by setDefaultQueryExtent
  62177. * @returns the box extent values
  62178. */
  62179. getDefaultQueryExtent(): Vector3;
  62180. /**
  62181. * Release all resources
  62182. */
  62183. dispose(): void;
  62184. }
  62185. /**
  62186. * Configures an agent
  62187. */
  62188. export interface IAgentParameters {
  62189. /**
  62190. * Agent radius. [Limit: >= 0]
  62191. */
  62192. radius: number;
  62193. /**
  62194. * Agent height. [Limit: > 0]
  62195. */
  62196. height: number;
  62197. /**
  62198. * Maximum allowed acceleration. [Limit: >= 0]
  62199. */
  62200. maxAcceleration: number;
  62201. /**
  62202. * Maximum allowed speed. [Limit: >= 0]
  62203. */
  62204. maxSpeed: number;
  62205. /**
  62206. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62207. */
  62208. collisionQueryRange: number;
  62209. /**
  62210. * The path visibility optimization range. [Limit: > 0]
  62211. */
  62212. pathOptimizationRange: number;
  62213. /**
  62214. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62215. */
  62216. separationWeight: number;
  62217. }
  62218. /**
  62219. * Configures the navigation mesh creation
  62220. */
  62221. export interface INavMeshParameters {
  62222. /**
  62223. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62224. */
  62225. cs: number;
  62226. /**
  62227. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62228. */
  62229. ch: number;
  62230. /**
  62231. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62232. */
  62233. walkableSlopeAngle: number;
  62234. /**
  62235. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62236. * be considered walkable. [Limit: >= 3] [Units: vx]
  62237. */
  62238. walkableHeight: number;
  62239. /**
  62240. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62241. */
  62242. walkableClimb: number;
  62243. /**
  62244. * The distance to erode/shrink the walkable area of the heightfield away from
  62245. * obstructions. [Limit: >=0] [Units: vx]
  62246. */
  62247. walkableRadius: number;
  62248. /**
  62249. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62250. */
  62251. maxEdgeLen: number;
  62252. /**
  62253. * The maximum distance a simplfied contour's border edges should deviate
  62254. * the original raw contour. [Limit: >=0] [Units: vx]
  62255. */
  62256. maxSimplificationError: number;
  62257. /**
  62258. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62259. */
  62260. minRegionArea: number;
  62261. /**
  62262. * Any regions with a span count smaller than this value will, if possible,
  62263. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62264. */
  62265. mergeRegionArea: number;
  62266. /**
  62267. * The maximum number of vertices allowed for polygons generated during the
  62268. * contour to polygon conversion process. [Limit: >= 3]
  62269. */
  62270. maxVertsPerPoly: number;
  62271. /**
  62272. * Sets the sampling distance to use when generating the detail mesh.
  62273. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62274. */
  62275. detailSampleDist: number;
  62276. /**
  62277. * The maximum distance the detail mesh surface should deviate from heightfield
  62278. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62279. */
  62280. detailSampleMaxError: number;
  62281. }
  62282. }
  62283. declare module BABYLON {
  62284. /**
  62285. * RecastJS navigation plugin
  62286. */
  62287. export class RecastJSPlugin implements INavigationEnginePlugin {
  62288. /**
  62289. * Reference to the Recast library
  62290. */
  62291. bjsRECAST: any;
  62292. /**
  62293. * plugin name
  62294. */
  62295. name: string;
  62296. /**
  62297. * the first navmesh created. We might extend this to support multiple navmeshes
  62298. */
  62299. navMesh: any;
  62300. /**
  62301. * Initializes the recastJS plugin
  62302. * @param recastInjection can be used to inject your own recast reference
  62303. */
  62304. constructor(recastInjection?: any);
  62305. /**
  62306. * Creates a navigation mesh
  62307. * @param meshes array of all the geometry used to compute the navigatio mesh
  62308. * @param parameters bunch of parameters used to filter geometry
  62309. */
  62310. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62311. /**
  62312. * Create a navigation mesh debug mesh
  62313. * @param scene is where the mesh will be added
  62314. * @returns debug display mesh
  62315. */
  62316. createDebugNavMesh(scene: Scene): Mesh;
  62317. /**
  62318. * Get a navigation mesh constrained position, closest to the parameter position
  62319. * @param position world position
  62320. * @returns the closest point to position constrained by the navigation mesh
  62321. */
  62322. getClosestPoint(position: Vector3): Vector3;
  62323. /**
  62324. * Get a navigation mesh constrained position, within a particular radius
  62325. * @param position world position
  62326. * @param maxRadius the maximum distance to the constrained world position
  62327. * @returns the closest point to position constrained by the navigation mesh
  62328. */
  62329. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62330. /**
  62331. * Compute the final position from a segment made of destination-position
  62332. * @param position world position
  62333. * @param destination world position
  62334. * @returns the resulting point along the navmesh
  62335. */
  62336. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62337. /**
  62338. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62339. * @param start world position
  62340. * @param end world position
  62341. * @returns array containing world position composing the path
  62342. */
  62343. computePath(start: Vector3, end: Vector3): Vector3[];
  62344. /**
  62345. * Create a new Crowd so you can add agents
  62346. * @param maxAgents the maximum agent count in the crowd
  62347. * @param maxAgentRadius the maximum radius an agent can have
  62348. * @param scene to attach the crowd to
  62349. * @returns the crowd you can add agents to
  62350. */
  62351. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62352. /**
  62353. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62354. * The queries will try to find a solution within those bounds
  62355. * default is (1,1,1)
  62356. * @param extent x,y,z value that define the extent around the queries point of reference
  62357. */
  62358. setDefaultQueryExtent(extent: Vector3): void;
  62359. /**
  62360. * Get the Bounding box extent specified by setDefaultQueryExtent
  62361. * @returns the box extent values
  62362. */
  62363. getDefaultQueryExtent(): Vector3;
  62364. /**
  62365. * Disposes
  62366. */
  62367. dispose(): void;
  62368. /**
  62369. * If this plugin is supported
  62370. * @returns true if plugin is supported
  62371. */
  62372. isSupported(): boolean;
  62373. }
  62374. /**
  62375. * Recast detour crowd implementation
  62376. */
  62377. export class RecastJSCrowd implements ICrowd {
  62378. /**
  62379. * Recast/detour plugin
  62380. */
  62381. bjsRECASTPlugin: RecastJSPlugin;
  62382. /**
  62383. * Link to the detour crowd
  62384. */
  62385. recastCrowd: any;
  62386. /**
  62387. * One transform per agent
  62388. */
  62389. transforms: TransformNode[];
  62390. /**
  62391. * All agents created
  62392. */
  62393. agents: number[];
  62394. /**
  62395. * Link to the scene is kept to unregister the crowd from the scene
  62396. */
  62397. private _scene;
  62398. /**
  62399. * Observer for crowd updates
  62400. */
  62401. private _onBeforeAnimationsObserver;
  62402. /**
  62403. * Constructor
  62404. * @param plugin recastJS plugin
  62405. * @param maxAgents the maximum agent count in the crowd
  62406. * @param maxAgentRadius the maximum radius an agent can have
  62407. * @param scene to attach the crowd to
  62408. * @returns the crowd you can add agents to
  62409. */
  62410. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62411. /**
  62412. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62413. * You can attach anything to that node. The node position is updated in the scene update tick.
  62414. * @param pos world position that will be constrained by the navigation mesh
  62415. * @param parameters agent parameters
  62416. * @param transform hooked to the agent that will be update by the scene
  62417. * @returns agent index
  62418. */
  62419. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62420. /**
  62421. * Returns the agent position in world space
  62422. * @param index agent index returned by addAgent
  62423. * @returns world space position
  62424. */
  62425. getAgentPosition(index: number): Vector3;
  62426. /**
  62427. * Returns the agent velocity in world space
  62428. * @param index agent index returned by addAgent
  62429. * @returns world space velocity
  62430. */
  62431. getAgentVelocity(index: number): Vector3;
  62432. /**
  62433. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62434. * @param index agent index returned by addAgent
  62435. * @param destination targeted world position
  62436. */
  62437. agentGoto(index: number, destination: Vector3): void;
  62438. /**
  62439. * Teleport the agent to a new position
  62440. * @param index agent index returned by addAgent
  62441. * @param destination targeted world position
  62442. */
  62443. agentTeleport(index: number, destination: Vector3): void;
  62444. /**
  62445. * Update agent parameters
  62446. * @param index agent index returned by addAgent
  62447. * @param parameters agent parameters
  62448. */
  62449. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62450. /**
  62451. * remove a particular agent previously created
  62452. * @param index agent index returned by addAgent
  62453. */
  62454. removeAgent(index: number): void;
  62455. /**
  62456. * get the list of all agents attached to this crowd
  62457. * @returns list of agent indices
  62458. */
  62459. getAgents(): number[];
  62460. /**
  62461. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62462. * @param deltaTime in seconds
  62463. */
  62464. update(deltaTime: number): void;
  62465. /**
  62466. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62467. * The queries will try to find a solution within those bounds
  62468. * default is (1,1,1)
  62469. * @param extent x,y,z value that define the extent around the queries point of reference
  62470. */
  62471. setDefaultQueryExtent(extent: Vector3): void;
  62472. /**
  62473. * Get the Bounding box extent specified by setDefaultQueryExtent
  62474. * @returns the box extent values
  62475. */
  62476. getDefaultQueryExtent(): Vector3;
  62477. /**
  62478. * Release all resources
  62479. */
  62480. dispose(): void;
  62481. }
  62482. }
  62483. declare module BABYLON {
  62484. /**
  62485. * Class used to enable access to IndexedDB
  62486. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62487. */
  62488. export class Database implements IOfflineProvider {
  62489. private _callbackManifestChecked;
  62490. private _currentSceneUrl;
  62491. private _db;
  62492. private _enableSceneOffline;
  62493. private _enableTexturesOffline;
  62494. private _manifestVersionFound;
  62495. private _mustUpdateRessources;
  62496. private _hasReachedQuota;
  62497. private _isSupported;
  62498. private _idbFactory;
  62499. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62500. private static IsUASupportingBlobStorage;
  62501. /**
  62502. * Gets a boolean indicating if Database storate is enabled (off by default)
  62503. */
  62504. static IDBStorageEnabled: boolean;
  62505. /**
  62506. * Gets a boolean indicating if scene must be saved in the database
  62507. */
  62508. get enableSceneOffline(): boolean;
  62509. /**
  62510. * Gets a boolean indicating if textures must be saved in the database
  62511. */
  62512. get enableTexturesOffline(): boolean;
  62513. /**
  62514. * Creates a new Database
  62515. * @param urlToScene defines the url to load the scene
  62516. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62517. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62518. */
  62519. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62520. private static _ParseURL;
  62521. private static _ReturnFullUrlLocation;
  62522. private _checkManifestFile;
  62523. /**
  62524. * Open the database and make it available
  62525. * @param successCallback defines the callback to call on success
  62526. * @param errorCallback defines the callback to call on error
  62527. */
  62528. open(successCallback: () => void, errorCallback: () => void): void;
  62529. /**
  62530. * Loads an image from the database
  62531. * @param url defines the url to load from
  62532. * @param image defines the target DOM image
  62533. */
  62534. loadImage(url: string, image: HTMLImageElement): void;
  62535. private _loadImageFromDBAsync;
  62536. private _saveImageIntoDBAsync;
  62537. private _checkVersionFromDB;
  62538. private _loadVersionFromDBAsync;
  62539. private _saveVersionIntoDBAsync;
  62540. /**
  62541. * Loads a file from database
  62542. * @param url defines the URL to load from
  62543. * @param sceneLoaded defines a callback to call on success
  62544. * @param progressCallBack defines a callback to call when progress changed
  62545. * @param errorCallback defines a callback to call on error
  62546. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62547. */
  62548. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62549. private _loadFileAsync;
  62550. private _saveFileAsync;
  62551. /**
  62552. * Validates if xhr data is correct
  62553. * @param xhr defines the request to validate
  62554. * @param dataType defines the expected data type
  62555. * @returns true if data is correct
  62556. */
  62557. private static _ValidateXHRData;
  62558. }
  62559. }
  62560. declare module BABYLON {
  62561. /** @hidden */
  62562. export var gpuUpdateParticlesPixelShader: {
  62563. name: string;
  62564. shader: string;
  62565. };
  62566. }
  62567. declare module BABYLON {
  62568. /** @hidden */
  62569. export var gpuUpdateParticlesVertexShader: {
  62570. name: string;
  62571. shader: string;
  62572. };
  62573. }
  62574. declare module BABYLON {
  62575. /** @hidden */
  62576. export var clipPlaneFragmentDeclaration2: {
  62577. name: string;
  62578. shader: string;
  62579. };
  62580. }
  62581. declare module BABYLON {
  62582. /** @hidden */
  62583. export var gpuRenderParticlesPixelShader: {
  62584. name: string;
  62585. shader: string;
  62586. };
  62587. }
  62588. declare module BABYLON {
  62589. /** @hidden */
  62590. export var clipPlaneVertexDeclaration2: {
  62591. name: string;
  62592. shader: string;
  62593. };
  62594. }
  62595. declare module BABYLON {
  62596. /** @hidden */
  62597. export var gpuRenderParticlesVertexShader: {
  62598. name: string;
  62599. shader: string;
  62600. };
  62601. }
  62602. declare module BABYLON {
  62603. /**
  62604. * This represents a GPU particle system in Babylon
  62605. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62606. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62607. */
  62608. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62609. /**
  62610. * The layer mask we are rendering the particles through.
  62611. */
  62612. layerMask: number;
  62613. private _capacity;
  62614. private _activeCount;
  62615. private _currentActiveCount;
  62616. private _accumulatedCount;
  62617. private _renderEffect;
  62618. private _updateEffect;
  62619. private _buffer0;
  62620. private _buffer1;
  62621. private _spriteBuffer;
  62622. private _updateVAO;
  62623. private _renderVAO;
  62624. private _targetIndex;
  62625. private _sourceBuffer;
  62626. private _targetBuffer;
  62627. private _engine;
  62628. private _currentRenderId;
  62629. private _started;
  62630. private _stopped;
  62631. private _timeDelta;
  62632. private _randomTexture;
  62633. private _randomTexture2;
  62634. private _attributesStrideSize;
  62635. private _updateEffectOptions;
  62636. private _randomTextureSize;
  62637. private _actualFrame;
  62638. private readonly _rawTextureWidth;
  62639. /**
  62640. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62641. */
  62642. static get IsSupported(): boolean;
  62643. /**
  62644. * An event triggered when the system is disposed.
  62645. */
  62646. onDisposeObservable: Observable<GPUParticleSystem>;
  62647. /**
  62648. * Gets the maximum number of particles active at the same time.
  62649. * @returns The max number of active particles.
  62650. */
  62651. getCapacity(): number;
  62652. /**
  62653. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62654. * to override the particles.
  62655. */
  62656. forceDepthWrite: boolean;
  62657. /**
  62658. * Gets or set the number of active particles
  62659. */
  62660. get activeParticleCount(): number;
  62661. set activeParticleCount(value: number);
  62662. private _preWarmDone;
  62663. /**
  62664. * Specifies if the particles are updated in emitter local space or world space.
  62665. * This is always false for GPU particles
  62666. */
  62667. get isLocal(): boolean;
  62668. set isLocal(value: boolean);
  62669. /**
  62670. * Is this system ready to be used/rendered
  62671. * @return true if the system is ready
  62672. */
  62673. isReady(): boolean;
  62674. /**
  62675. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62676. * @returns True if it has been started, otherwise false.
  62677. */
  62678. isStarted(): boolean;
  62679. /**
  62680. * Starts the particle system and begins to emit
  62681. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62682. */
  62683. start(delay?: number): void;
  62684. /**
  62685. * Stops the particle system.
  62686. */
  62687. stop(): void;
  62688. /**
  62689. * Remove all active particles
  62690. */
  62691. reset(): void;
  62692. /**
  62693. * Returns the string "GPUParticleSystem"
  62694. * @returns a string containing the class name
  62695. */
  62696. getClassName(): string;
  62697. private _colorGradientsTexture;
  62698. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62699. /**
  62700. * Adds a new color gradient
  62701. * @param gradient defines the gradient to use (between 0 and 1)
  62702. * @param color1 defines the color to affect to the specified gradient
  62703. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62704. * @returns the current particle system
  62705. */
  62706. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62707. /**
  62708. * Remove a specific color gradient
  62709. * @param gradient defines the gradient to remove
  62710. * @returns the current particle system
  62711. */
  62712. removeColorGradient(gradient: number): GPUParticleSystem;
  62713. private _angularSpeedGradientsTexture;
  62714. private _sizeGradientsTexture;
  62715. private _velocityGradientsTexture;
  62716. private _limitVelocityGradientsTexture;
  62717. private _dragGradientsTexture;
  62718. private _addFactorGradient;
  62719. /**
  62720. * Adds a new size gradient
  62721. * @param gradient defines the gradient to use (between 0 and 1)
  62722. * @param factor defines the size factor to affect to the specified gradient
  62723. * @returns the current particle system
  62724. */
  62725. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62726. /**
  62727. * Remove a specific size gradient
  62728. * @param gradient defines the gradient to remove
  62729. * @returns the current particle system
  62730. */
  62731. removeSizeGradient(gradient: number): GPUParticleSystem;
  62732. /**
  62733. * Adds a new angular speed gradient
  62734. * @param gradient defines the gradient to use (between 0 and 1)
  62735. * @param factor defines the angular speed to affect to the specified gradient
  62736. * @returns the current particle system
  62737. */
  62738. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62739. /**
  62740. * Remove a specific angular speed gradient
  62741. * @param gradient defines the gradient to remove
  62742. * @returns the current particle system
  62743. */
  62744. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62745. /**
  62746. * Adds a new velocity gradient
  62747. * @param gradient defines the gradient to use (between 0 and 1)
  62748. * @param factor defines the velocity to affect to the specified gradient
  62749. * @returns the current particle system
  62750. */
  62751. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62752. /**
  62753. * Remove a specific velocity gradient
  62754. * @param gradient defines the gradient to remove
  62755. * @returns the current particle system
  62756. */
  62757. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62758. /**
  62759. * Adds a new limit velocity gradient
  62760. * @param gradient defines the gradient to use (between 0 and 1)
  62761. * @param factor defines the limit velocity value to affect to the specified gradient
  62762. * @returns the current particle system
  62763. */
  62764. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62765. /**
  62766. * Remove a specific limit velocity gradient
  62767. * @param gradient defines the gradient to remove
  62768. * @returns the current particle system
  62769. */
  62770. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62771. /**
  62772. * Adds a new drag gradient
  62773. * @param gradient defines the gradient to use (between 0 and 1)
  62774. * @param factor defines the drag value to affect to the specified gradient
  62775. * @returns the current particle system
  62776. */
  62777. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62778. /**
  62779. * Remove a specific drag gradient
  62780. * @param gradient defines the gradient to remove
  62781. * @returns the current particle system
  62782. */
  62783. removeDragGradient(gradient: number): GPUParticleSystem;
  62784. /**
  62785. * Not supported by GPUParticleSystem
  62786. * @param gradient defines the gradient to use (between 0 and 1)
  62787. * @param factor defines the emit rate value to affect to the specified gradient
  62788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62789. * @returns the current particle system
  62790. */
  62791. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62792. /**
  62793. * Not supported by GPUParticleSystem
  62794. * @param gradient defines the gradient to remove
  62795. * @returns the current particle system
  62796. */
  62797. removeEmitRateGradient(gradient: number): IParticleSystem;
  62798. /**
  62799. * Not supported by GPUParticleSystem
  62800. * @param gradient defines the gradient to use (between 0 and 1)
  62801. * @param factor defines the start size value to affect to the specified gradient
  62802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62803. * @returns the current particle system
  62804. */
  62805. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62806. /**
  62807. * Not supported by GPUParticleSystem
  62808. * @param gradient defines the gradient to remove
  62809. * @returns the current particle system
  62810. */
  62811. removeStartSizeGradient(gradient: number): IParticleSystem;
  62812. /**
  62813. * Not supported by GPUParticleSystem
  62814. * @param gradient defines the gradient to use (between 0 and 1)
  62815. * @param min defines the color remap minimal range
  62816. * @param max defines the color remap maximal range
  62817. * @returns the current particle system
  62818. */
  62819. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62820. /**
  62821. * Not supported by GPUParticleSystem
  62822. * @param gradient defines the gradient to remove
  62823. * @returns the current particle system
  62824. */
  62825. removeColorRemapGradient(): IParticleSystem;
  62826. /**
  62827. * Not supported by GPUParticleSystem
  62828. * @param gradient defines the gradient to use (between 0 and 1)
  62829. * @param min defines the alpha remap minimal range
  62830. * @param max defines the alpha remap maximal range
  62831. * @returns the current particle system
  62832. */
  62833. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62834. /**
  62835. * Not supported by GPUParticleSystem
  62836. * @param gradient defines the gradient to remove
  62837. * @returns the current particle system
  62838. */
  62839. removeAlphaRemapGradient(): IParticleSystem;
  62840. /**
  62841. * Not supported by GPUParticleSystem
  62842. * @param gradient defines the gradient to use (between 0 and 1)
  62843. * @param color defines the color to affect to the specified gradient
  62844. * @returns the current particle system
  62845. */
  62846. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62847. /**
  62848. * Not supported by GPUParticleSystem
  62849. * @param gradient defines the gradient to remove
  62850. * @returns the current particle system
  62851. */
  62852. removeRampGradient(): IParticleSystem;
  62853. /**
  62854. * Not supported by GPUParticleSystem
  62855. * @returns the list of ramp gradients
  62856. */
  62857. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62858. /**
  62859. * Not supported by GPUParticleSystem
  62860. * Gets or sets a boolean indicating that ramp gradients must be used
  62861. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62862. */
  62863. get useRampGradients(): boolean;
  62864. set useRampGradients(value: boolean);
  62865. /**
  62866. * Not supported by GPUParticleSystem
  62867. * @param gradient defines the gradient to use (between 0 and 1)
  62868. * @param factor defines the life time factor to affect to the specified gradient
  62869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62870. * @returns the current particle system
  62871. */
  62872. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62873. /**
  62874. * Not supported by GPUParticleSystem
  62875. * @param gradient defines the gradient to remove
  62876. * @returns the current particle system
  62877. */
  62878. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62879. /**
  62880. * Instantiates a GPU particle system.
  62881. * 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.
  62882. * @param name The name of the particle system
  62883. * @param options The options used to create the system
  62884. * @param scene The scene the particle system belongs to
  62885. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62886. */
  62887. constructor(name: string, options: Partial<{
  62888. capacity: number;
  62889. randomTextureSize: number;
  62890. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62891. protected _reset(): void;
  62892. private _createUpdateVAO;
  62893. private _createRenderVAO;
  62894. private _initialize;
  62895. /** @hidden */
  62896. _recreateUpdateEffect(): void;
  62897. /** @hidden */
  62898. _recreateRenderEffect(): void;
  62899. /**
  62900. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62901. * @param preWarm defines if we are in the pre-warmimg phase
  62902. */
  62903. animate(preWarm?: boolean): void;
  62904. private _createFactorGradientTexture;
  62905. private _createSizeGradientTexture;
  62906. private _createAngularSpeedGradientTexture;
  62907. private _createVelocityGradientTexture;
  62908. private _createLimitVelocityGradientTexture;
  62909. private _createDragGradientTexture;
  62910. private _createColorGradientTexture;
  62911. /**
  62912. * Renders the particle system in its current state
  62913. * @param preWarm defines if the system should only update the particles but not render them
  62914. * @returns the current number of particles
  62915. */
  62916. render(preWarm?: boolean): number;
  62917. /**
  62918. * Rebuilds the particle system
  62919. */
  62920. rebuild(): void;
  62921. private _releaseBuffers;
  62922. private _releaseVAOs;
  62923. /**
  62924. * Disposes the particle system and free the associated resources
  62925. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62926. */
  62927. dispose(disposeTexture?: boolean): void;
  62928. /**
  62929. * Clones the particle system.
  62930. * @param name The name of the cloned object
  62931. * @param newEmitter The new emitter to use
  62932. * @returns the cloned particle system
  62933. */
  62934. clone(name: string, newEmitter: any): GPUParticleSystem;
  62935. /**
  62936. * Serializes the particle system to a JSON object.
  62937. * @returns the JSON object
  62938. */
  62939. serialize(): any;
  62940. /**
  62941. * Parses a JSON object to create a GPU particle system.
  62942. * @param parsedParticleSystem The JSON object to parse
  62943. * @param scene The scene to create the particle system in
  62944. * @param rootUrl The root url to use to load external dependencies like texture
  62945. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62946. * @returns the parsed GPU particle system
  62947. */
  62948. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62949. }
  62950. }
  62951. declare module BABYLON {
  62952. /**
  62953. * Represents a set of particle systems working together to create a specific effect
  62954. */
  62955. export class ParticleSystemSet implements IDisposable {
  62956. /**
  62957. * Gets or sets base Assets URL
  62958. */
  62959. static BaseAssetsUrl: string;
  62960. private _emitterCreationOptions;
  62961. private _emitterNode;
  62962. /**
  62963. * Gets the particle system list
  62964. */
  62965. systems: IParticleSystem[];
  62966. /**
  62967. * Gets the emitter node used with this set
  62968. */
  62969. get emitterNode(): Nullable<TransformNode>;
  62970. /**
  62971. * Creates a new emitter mesh as a sphere
  62972. * @param options defines the options used to create the sphere
  62973. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62974. * @param scene defines the hosting scene
  62975. */
  62976. setEmitterAsSphere(options: {
  62977. diameter: number;
  62978. segments: number;
  62979. color: Color3;
  62980. }, renderingGroupId: number, scene: Scene): void;
  62981. /**
  62982. * Starts all particle systems of the set
  62983. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62984. */
  62985. start(emitter?: AbstractMesh): void;
  62986. /**
  62987. * Release all associated resources
  62988. */
  62989. dispose(): void;
  62990. /**
  62991. * Serialize the set into a JSON compatible object
  62992. * @returns a JSON compatible representation of the set
  62993. */
  62994. serialize(): any;
  62995. /**
  62996. * Parse a new ParticleSystemSet from a serialized source
  62997. * @param data defines a JSON compatible representation of the set
  62998. * @param scene defines the hosting scene
  62999. * @param gpu defines if we want GPU particles or CPU particles
  63000. * @returns a new ParticleSystemSet
  63001. */
  63002. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63003. }
  63004. }
  63005. declare module BABYLON {
  63006. /**
  63007. * This class is made for on one-liner static method to help creating particle system set.
  63008. */
  63009. export class ParticleHelper {
  63010. /**
  63011. * Gets or sets base Assets URL
  63012. */
  63013. static BaseAssetsUrl: string;
  63014. /**
  63015. * Create a default particle system that you can tweak
  63016. * @param emitter defines the emitter to use
  63017. * @param capacity defines the system capacity (default is 500 particles)
  63018. * @param scene defines the hosting scene
  63019. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63020. * @returns the new Particle system
  63021. */
  63022. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63023. /**
  63024. * This is the main static method (one-liner) of this helper to create different particle systems
  63025. * @param type This string represents the type to the particle system to create
  63026. * @param scene The scene where the particle system should live
  63027. * @param gpu If the system will use gpu
  63028. * @returns the ParticleSystemSet created
  63029. */
  63030. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63031. /**
  63032. * Static function used to export a particle system to a ParticleSystemSet variable.
  63033. * Please note that the emitter shape is not exported
  63034. * @param systems defines the particle systems to export
  63035. * @returns the created particle system set
  63036. */
  63037. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63038. }
  63039. }
  63040. declare module BABYLON {
  63041. interface Engine {
  63042. /**
  63043. * Create an effect to use with particle systems.
  63044. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63045. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63046. * @param uniformsNames defines a list of attribute names
  63047. * @param samplers defines an array of string used to represent textures
  63048. * @param defines defines the string containing the defines to use to compile the shaders
  63049. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63050. * @param onCompiled defines a function to call when the effect creation is successful
  63051. * @param onError defines a function to call when the effect creation has failed
  63052. * @returns the new Effect
  63053. */
  63054. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63055. }
  63056. interface Mesh {
  63057. /**
  63058. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63059. * @returns an array of IParticleSystem
  63060. */
  63061. getEmittedParticleSystems(): IParticleSystem[];
  63062. /**
  63063. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63064. * @returns an array of IParticleSystem
  63065. */
  63066. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63067. }
  63068. /**
  63069. * @hidden
  63070. */
  63071. export var _IDoNeedToBeInTheBuild: number;
  63072. }
  63073. declare module BABYLON {
  63074. /** Defines the 4 color options */
  63075. export enum PointColor {
  63076. /** color value */
  63077. Color = 2,
  63078. /** uv value */
  63079. UV = 1,
  63080. /** random value */
  63081. Random = 0,
  63082. /** stated value */
  63083. Stated = 3
  63084. }
  63085. /**
  63086. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63087. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  63088. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63089. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63090. *
  63091. * Full documentation here : TO BE ENTERED
  63092. */
  63093. export class PointsCloudSystem implements IDisposable {
  63094. /**
  63095. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63096. * Example : var p = SPS.particles[i];
  63097. */
  63098. particles: CloudPoint[];
  63099. /**
  63100. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63101. */
  63102. nbParticles: number;
  63103. /**
  63104. * This a counter for your own usage. It's not set by any SPS functions.
  63105. */
  63106. counter: number;
  63107. /**
  63108. * The PCS name. This name is also given to the underlying mesh.
  63109. */
  63110. name: string;
  63111. /**
  63112. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63113. */
  63114. mesh: Mesh;
  63115. /**
  63116. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63117. * Please read :
  63118. */
  63119. vars: any;
  63120. /**
  63121. * @hidden
  63122. */
  63123. _size: number;
  63124. private _scene;
  63125. private _promises;
  63126. private _positions;
  63127. private _indices;
  63128. private _normals;
  63129. private _colors;
  63130. private _uvs;
  63131. private _indices32;
  63132. private _positions32;
  63133. private _colors32;
  63134. private _uvs32;
  63135. private _updatable;
  63136. private _isVisibilityBoxLocked;
  63137. private _alwaysVisible;
  63138. private _groups;
  63139. private _groupCounter;
  63140. private _computeParticleColor;
  63141. private _computeParticleTexture;
  63142. private _computeParticleRotation;
  63143. private _computeBoundingBox;
  63144. private _isReady;
  63145. /**
  63146. * Creates a PCS (Points Cloud System) object
  63147. * @param name (String) is the PCS name, this will be the underlying mesh name
  63148. * @param pointSize (number) is the size for each point
  63149. * @param scene (Scene) is the scene in which the PCS is added
  63150. * @param options defines the options of the PCS e.g.
  63151. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63152. */
  63153. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63154. updatable?: boolean;
  63155. });
  63156. /**
  63157. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63158. * If no points were added to the PCS, the returned mesh is just a single point.
  63159. * @returns a promise for the created mesh
  63160. */
  63161. buildMeshAsync(): Promise<Mesh>;
  63162. /**
  63163. * @hidden
  63164. */
  63165. private _buildMesh;
  63166. private _addParticle;
  63167. private _randomUnitVector;
  63168. private _getColorIndicesForCoord;
  63169. private _setPointsColorOrUV;
  63170. private _colorFromTexture;
  63171. private _calculateDensity;
  63172. /**
  63173. * Adds points to the PCS in random positions within a unit sphere
  63174. * @param nb (positive integer) the number of particles to be created from this model
  63175. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63176. * @returns the number of groups in the system
  63177. */
  63178. addPoints(nb: number, pointFunction?: any): number;
  63179. /**
  63180. * Adds points to the PCS from the surface of the model shape
  63181. * @param mesh is any Mesh object that will be used as a surface model for the points
  63182. * @param nb (positive integer) the number of particles to be created from this model
  63183. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63184. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63185. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63186. * @returns the number of groups in the system
  63187. */
  63188. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63189. /**
  63190. * Adds points to the PCS inside the model shape
  63191. * @param mesh is any Mesh object that will be used as a surface model for the points
  63192. * @param nb (positive integer) the number of particles to be created from this model
  63193. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63194. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63195. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63196. * @returns the number of groups in the system
  63197. */
  63198. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63199. /**
  63200. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63201. * This method calls `updateParticle()` for each particle of the SPS.
  63202. * For an animated SPS, it is usually called within the render loop.
  63203. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63204. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63205. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63206. * @returns the PCS.
  63207. */
  63208. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63209. /**
  63210. * Disposes the PCS.
  63211. */
  63212. dispose(): void;
  63213. /**
  63214. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63215. * doc :
  63216. * @returns the PCS.
  63217. */
  63218. refreshVisibleSize(): PointsCloudSystem;
  63219. /**
  63220. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63221. * @param size the size (float) of the visibility box
  63222. * note : this doesn't lock the PCS mesh bounding box.
  63223. * doc :
  63224. */
  63225. setVisibilityBox(size: number): void;
  63226. /**
  63227. * Gets whether the PCS is always visible or not
  63228. * doc :
  63229. */
  63230. get isAlwaysVisible(): boolean;
  63231. /**
  63232. * Sets the PCS as always visible or not
  63233. * doc :
  63234. */
  63235. set isAlwaysVisible(val: boolean);
  63236. /**
  63237. * Tells to `setParticles()` to compute the particle rotations or not
  63238. * Default value : false. The PCS is faster when it's set to false
  63239. * Note : particle rotations are only applied to parent particles
  63240. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63241. */
  63242. set computeParticleRotation(val: boolean);
  63243. /**
  63244. * Tells to `setParticles()` to compute the particle colors or not.
  63245. * Default value : true. The PCS is faster when it's set to false.
  63246. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63247. */
  63248. set computeParticleColor(val: boolean);
  63249. set computeParticleTexture(val: boolean);
  63250. /**
  63251. * Gets if `setParticles()` computes the particle colors or not.
  63252. * Default value : false. The PCS is faster when it's set to false.
  63253. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63254. */
  63255. get computeParticleColor(): boolean;
  63256. /**
  63257. * Gets if `setParticles()` computes the particle textures or not.
  63258. * Default value : false. The PCS is faster when it's set to false.
  63259. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63260. */
  63261. get computeParticleTexture(): boolean;
  63262. /**
  63263. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63264. */
  63265. set computeBoundingBox(val: boolean);
  63266. /**
  63267. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63268. */
  63269. get computeBoundingBox(): boolean;
  63270. /**
  63271. * This function does nothing. It may be overwritten to set all the particle first values.
  63272. * The PCS doesn't call this function, you may have to call it by your own.
  63273. * doc :
  63274. */
  63275. initParticles(): void;
  63276. /**
  63277. * This function does nothing. It may be overwritten to recycle a particle
  63278. * The PCS doesn't call this function, you can to call it
  63279. * doc :
  63280. * @param particle The particle to recycle
  63281. * @returns the recycled particle
  63282. */
  63283. recycleParticle(particle: CloudPoint): CloudPoint;
  63284. /**
  63285. * Updates a particle : this function should be overwritten by the user.
  63286. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63287. * doc :
  63288. * @example : just set a particle position or velocity and recycle conditions
  63289. * @param particle The particle to update
  63290. * @returns the updated particle
  63291. */
  63292. updateParticle(particle: CloudPoint): CloudPoint;
  63293. /**
  63294. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63295. * This does nothing and may be overwritten by the user.
  63296. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63297. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63298. * @param update the boolean update value actually passed to setParticles()
  63299. */
  63300. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63301. /**
  63302. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63303. * This will be passed three parameters.
  63304. * This does nothing and may be overwritten by the user.
  63305. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63306. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63307. * @param update the boolean update value actually passed to setParticles()
  63308. */
  63309. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63310. }
  63311. }
  63312. declare module BABYLON {
  63313. /**
  63314. * Represents one particle of a points cloud system.
  63315. */
  63316. export class CloudPoint {
  63317. /**
  63318. * particle global index
  63319. */
  63320. idx: number;
  63321. /**
  63322. * The color of the particle
  63323. */
  63324. color: Nullable<Color4>;
  63325. /**
  63326. * The world space position of the particle.
  63327. */
  63328. position: Vector3;
  63329. /**
  63330. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63331. */
  63332. rotation: Vector3;
  63333. /**
  63334. * The world space rotation quaternion of the particle.
  63335. */
  63336. rotationQuaternion: Nullable<Quaternion>;
  63337. /**
  63338. * The uv of the particle.
  63339. */
  63340. uv: Nullable<Vector2>;
  63341. /**
  63342. * The current speed of the particle.
  63343. */
  63344. velocity: Vector3;
  63345. /**
  63346. * The pivot point in the particle local space.
  63347. */
  63348. pivot: Vector3;
  63349. /**
  63350. * Must the particle be translated from its pivot point in its local space ?
  63351. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63352. * Default : false
  63353. */
  63354. translateFromPivot: boolean;
  63355. /**
  63356. * Index of this particle in the global "positions" array (Internal use)
  63357. * @hidden
  63358. */
  63359. _pos: number;
  63360. /**
  63361. * @hidden Index of this particle in the global "indices" array (Internal use)
  63362. */
  63363. _ind: number;
  63364. /**
  63365. * Group this particle belongs to
  63366. */
  63367. _group: PointsGroup;
  63368. /**
  63369. * Group id of this particle
  63370. */
  63371. groupId: number;
  63372. /**
  63373. * Index of the particle in its group id (Internal use)
  63374. */
  63375. idxInGroup: number;
  63376. /**
  63377. * @hidden Particle BoundingInfo object (Internal use)
  63378. */
  63379. _boundingInfo: BoundingInfo;
  63380. /**
  63381. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63382. */
  63383. _pcs: PointsCloudSystem;
  63384. /**
  63385. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63386. */
  63387. _stillInvisible: boolean;
  63388. /**
  63389. * @hidden Last computed particle rotation matrix
  63390. */
  63391. _rotationMatrix: number[];
  63392. /**
  63393. * Parent particle Id, if any.
  63394. * Default null.
  63395. */
  63396. parentId: Nullable<number>;
  63397. /**
  63398. * @hidden Internal global position in the PCS.
  63399. */
  63400. _globalPosition: Vector3;
  63401. /**
  63402. * Creates a Point Cloud object.
  63403. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63404. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63405. * @param group (PointsGroup) is the group the particle belongs to
  63406. * @param groupId (integer) is the group identifier in the PCS.
  63407. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63408. * @param pcs defines the PCS it is associated to
  63409. */
  63410. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63411. /**
  63412. * get point size
  63413. */
  63414. get size(): Vector3;
  63415. /**
  63416. * Set point size
  63417. */
  63418. set size(scale: Vector3);
  63419. /**
  63420. * Legacy support, changed quaternion to rotationQuaternion
  63421. */
  63422. get quaternion(): Nullable<Quaternion>;
  63423. /**
  63424. * Legacy support, changed quaternion to rotationQuaternion
  63425. */
  63426. set quaternion(q: Nullable<Quaternion>);
  63427. /**
  63428. * Returns a boolean. True if the particle intersects a mesh, else false
  63429. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63430. * @param target is the object (point or mesh) what the intersection is computed against
  63431. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63432. * @returns true if it intersects
  63433. */
  63434. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63435. /**
  63436. * get the rotation matrix of the particle
  63437. * @hidden
  63438. */
  63439. getRotationMatrix(m: Matrix): void;
  63440. }
  63441. /**
  63442. * Represents a group of points in a points cloud system
  63443. * * PCS internal tool, don't use it manually.
  63444. */
  63445. export class PointsGroup {
  63446. /**
  63447. * The group id
  63448. * @hidden
  63449. */
  63450. groupID: number;
  63451. /**
  63452. * image data for group (internal use)
  63453. * @hidden
  63454. */
  63455. _groupImageData: Nullable<ArrayBufferView>;
  63456. /**
  63457. * Image Width (internal use)
  63458. * @hidden
  63459. */
  63460. _groupImgWidth: number;
  63461. /**
  63462. * Image Height (internal use)
  63463. * @hidden
  63464. */
  63465. _groupImgHeight: number;
  63466. /**
  63467. * Custom position function (internal use)
  63468. * @hidden
  63469. */
  63470. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63471. /**
  63472. * density per facet for surface points
  63473. * @hidden
  63474. */
  63475. _groupDensity: number[];
  63476. /**
  63477. * Only when points are colored by texture carries pointer to texture list array
  63478. * @hidden
  63479. */
  63480. _textureNb: number;
  63481. /**
  63482. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63483. * PCS internal tool, don't use it manually.
  63484. * @hidden
  63485. */
  63486. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63487. }
  63488. }
  63489. declare module BABYLON {
  63490. interface Scene {
  63491. /** @hidden (Backing field) */
  63492. _physicsEngine: Nullable<IPhysicsEngine>;
  63493. /** @hidden */
  63494. _physicsTimeAccumulator: number;
  63495. /**
  63496. * Gets the current physics engine
  63497. * @returns a IPhysicsEngine or null if none attached
  63498. */
  63499. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63500. /**
  63501. * Enables physics to the current scene
  63502. * @param gravity defines the scene's gravity for the physics engine
  63503. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63504. * @return a boolean indicating if the physics engine was initialized
  63505. */
  63506. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63507. /**
  63508. * Disables and disposes the physics engine associated with the scene
  63509. */
  63510. disablePhysicsEngine(): void;
  63511. /**
  63512. * Gets a boolean indicating if there is an active physics engine
  63513. * @returns a boolean indicating if there is an active physics engine
  63514. */
  63515. isPhysicsEnabled(): boolean;
  63516. /**
  63517. * Deletes a physics compound impostor
  63518. * @param compound defines the compound to delete
  63519. */
  63520. deleteCompoundImpostor(compound: any): void;
  63521. /**
  63522. * An event triggered when physic simulation is about to be run
  63523. */
  63524. onBeforePhysicsObservable: Observable<Scene>;
  63525. /**
  63526. * An event triggered when physic simulation has been done
  63527. */
  63528. onAfterPhysicsObservable: Observable<Scene>;
  63529. }
  63530. interface AbstractMesh {
  63531. /** @hidden */
  63532. _physicsImpostor: Nullable<PhysicsImpostor>;
  63533. /**
  63534. * Gets or sets impostor used for physic simulation
  63535. * @see http://doc.babylonjs.com/features/physics_engine
  63536. */
  63537. physicsImpostor: Nullable<PhysicsImpostor>;
  63538. /**
  63539. * Gets the current physics impostor
  63540. * @see http://doc.babylonjs.com/features/physics_engine
  63541. * @returns a physics impostor or null
  63542. */
  63543. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63544. /** Apply a physic impulse to the mesh
  63545. * @param force defines the force to apply
  63546. * @param contactPoint defines where to apply the force
  63547. * @returns the current mesh
  63548. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63549. */
  63550. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63551. /**
  63552. * Creates a physic joint between two meshes
  63553. * @param otherMesh defines the other mesh to use
  63554. * @param pivot1 defines the pivot to use on this mesh
  63555. * @param pivot2 defines the pivot to use on the other mesh
  63556. * @param options defines additional options (can be plugin dependent)
  63557. * @returns the current mesh
  63558. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63559. */
  63560. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63561. /** @hidden */
  63562. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63563. }
  63564. /**
  63565. * Defines the physics engine scene component responsible to manage a physics engine
  63566. */
  63567. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63568. /**
  63569. * The component name helpful to identify the component in the list of scene components.
  63570. */
  63571. readonly name: string;
  63572. /**
  63573. * The scene the component belongs to.
  63574. */
  63575. scene: Scene;
  63576. /**
  63577. * Creates a new instance of the component for the given scene
  63578. * @param scene Defines the scene to register the component in
  63579. */
  63580. constructor(scene: Scene);
  63581. /**
  63582. * Registers the component in a given scene
  63583. */
  63584. register(): void;
  63585. /**
  63586. * Rebuilds the elements related to this component in case of
  63587. * context lost for instance.
  63588. */
  63589. rebuild(): void;
  63590. /**
  63591. * Disposes the component and the associated ressources
  63592. */
  63593. dispose(): void;
  63594. }
  63595. }
  63596. declare module BABYLON {
  63597. /**
  63598. * A helper for physics simulations
  63599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63600. */
  63601. export class PhysicsHelper {
  63602. private _scene;
  63603. private _physicsEngine;
  63604. /**
  63605. * Initializes the Physics helper
  63606. * @param scene Babylon.js scene
  63607. */
  63608. constructor(scene: Scene);
  63609. /**
  63610. * Applies a radial explosion impulse
  63611. * @param origin the origin of the explosion
  63612. * @param radiusOrEventOptions the radius or the options of radial explosion
  63613. * @param strength the explosion strength
  63614. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63615. * @returns A physics radial explosion event, or null
  63616. */
  63617. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63618. /**
  63619. * Applies a radial explosion force
  63620. * @param origin the origin of the explosion
  63621. * @param radiusOrEventOptions the radius or the options of radial explosion
  63622. * @param strength the explosion strength
  63623. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63624. * @returns A physics radial explosion event, or null
  63625. */
  63626. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63627. /**
  63628. * Creates a gravitational field
  63629. * @param origin the origin of the explosion
  63630. * @param radiusOrEventOptions the radius or the options of radial explosion
  63631. * @param strength the explosion strength
  63632. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63633. * @returns A physics gravitational field event, or null
  63634. */
  63635. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63636. /**
  63637. * Creates a physics updraft event
  63638. * @param origin the origin of the updraft
  63639. * @param radiusOrEventOptions the radius or the options of the updraft
  63640. * @param strength the strength of the updraft
  63641. * @param height the height of the updraft
  63642. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63643. * @returns A physics updraft event, or null
  63644. */
  63645. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63646. /**
  63647. * Creates a physics vortex event
  63648. * @param origin the of the vortex
  63649. * @param radiusOrEventOptions the radius or the options of the vortex
  63650. * @param strength the strength of the vortex
  63651. * @param height the height of the vortex
  63652. * @returns a Physics vortex event, or null
  63653. * A physics vortex event or null
  63654. */
  63655. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63656. }
  63657. /**
  63658. * Represents a physics radial explosion event
  63659. */
  63660. class PhysicsRadialExplosionEvent {
  63661. private _scene;
  63662. private _options;
  63663. private _sphere;
  63664. private _dataFetched;
  63665. /**
  63666. * Initializes a radial explosioin event
  63667. * @param _scene BabylonJS scene
  63668. * @param _options The options for the vortex event
  63669. */
  63670. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63671. /**
  63672. * Returns the data related to the radial explosion event (sphere).
  63673. * @returns The radial explosion event data
  63674. */
  63675. getData(): PhysicsRadialExplosionEventData;
  63676. /**
  63677. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63678. * @param impostor A physics imposter
  63679. * @param origin the origin of the explosion
  63680. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63681. */
  63682. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63683. /**
  63684. * Triggers affecterd impostors callbacks
  63685. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63686. */
  63687. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63688. /**
  63689. * Disposes the sphere.
  63690. * @param force Specifies if the sphere should be disposed by force
  63691. */
  63692. dispose(force?: boolean): void;
  63693. /*** Helpers ***/
  63694. private _prepareSphere;
  63695. private _intersectsWithSphere;
  63696. }
  63697. /**
  63698. * Represents a gravitational field event
  63699. */
  63700. class PhysicsGravitationalFieldEvent {
  63701. private _physicsHelper;
  63702. private _scene;
  63703. private _origin;
  63704. private _options;
  63705. private _tickCallback;
  63706. private _sphere;
  63707. private _dataFetched;
  63708. /**
  63709. * Initializes the physics gravitational field event
  63710. * @param _physicsHelper A physics helper
  63711. * @param _scene BabylonJS scene
  63712. * @param _origin The origin position of the gravitational field event
  63713. * @param _options The options for the vortex event
  63714. */
  63715. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63716. /**
  63717. * Returns the data related to the gravitational field event (sphere).
  63718. * @returns A gravitational field event
  63719. */
  63720. getData(): PhysicsGravitationalFieldEventData;
  63721. /**
  63722. * Enables the gravitational field.
  63723. */
  63724. enable(): void;
  63725. /**
  63726. * Disables the gravitational field.
  63727. */
  63728. disable(): void;
  63729. /**
  63730. * Disposes the sphere.
  63731. * @param force The force to dispose from the gravitational field event
  63732. */
  63733. dispose(force?: boolean): void;
  63734. private _tick;
  63735. }
  63736. /**
  63737. * Represents a physics updraft event
  63738. */
  63739. class PhysicsUpdraftEvent {
  63740. private _scene;
  63741. private _origin;
  63742. private _options;
  63743. private _physicsEngine;
  63744. private _originTop;
  63745. private _originDirection;
  63746. private _tickCallback;
  63747. private _cylinder;
  63748. private _cylinderPosition;
  63749. private _dataFetched;
  63750. /**
  63751. * Initializes the physics updraft event
  63752. * @param _scene BabylonJS scene
  63753. * @param _origin The origin position of the updraft
  63754. * @param _options The options for the updraft event
  63755. */
  63756. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63757. /**
  63758. * Returns the data related to the updraft event (cylinder).
  63759. * @returns A physics updraft event
  63760. */
  63761. getData(): PhysicsUpdraftEventData;
  63762. /**
  63763. * Enables the updraft.
  63764. */
  63765. enable(): void;
  63766. /**
  63767. * Disables the updraft.
  63768. */
  63769. disable(): void;
  63770. /**
  63771. * Disposes the cylinder.
  63772. * @param force Specifies if the updraft should be disposed by force
  63773. */
  63774. dispose(force?: boolean): void;
  63775. private getImpostorHitData;
  63776. private _tick;
  63777. /*** Helpers ***/
  63778. private _prepareCylinder;
  63779. private _intersectsWithCylinder;
  63780. }
  63781. /**
  63782. * Represents a physics vortex event
  63783. */
  63784. class PhysicsVortexEvent {
  63785. private _scene;
  63786. private _origin;
  63787. private _options;
  63788. private _physicsEngine;
  63789. private _originTop;
  63790. private _tickCallback;
  63791. private _cylinder;
  63792. private _cylinderPosition;
  63793. private _dataFetched;
  63794. /**
  63795. * Initializes the physics vortex event
  63796. * @param _scene The BabylonJS scene
  63797. * @param _origin The origin position of the vortex
  63798. * @param _options The options for the vortex event
  63799. */
  63800. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63801. /**
  63802. * Returns the data related to the vortex event (cylinder).
  63803. * @returns The physics vortex event data
  63804. */
  63805. getData(): PhysicsVortexEventData;
  63806. /**
  63807. * Enables the vortex.
  63808. */
  63809. enable(): void;
  63810. /**
  63811. * Disables the cortex.
  63812. */
  63813. disable(): void;
  63814. /**
  63815. * Disposes the sphere.
  63816. * @param force
  63817. */
  63818. dispose(force?: boolean): void;
  63819. private getImpostorHitData;
  63820. private _tick;
  63821. /*** Helpers ***/
  63822. private _prepareCylinder;
  63823. private _intersectsWithCylinder;
  63824. }
  63825. /**
  63826. * Options fot the radial explosion event
  63827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63828. */
  63829. export class PhysicsRadialExplosionEventOptions {
  63830. /**
  63831. * The radius of the sphere for the radial explosion.
  63832. */
  63833. radius: number;
  63834. /**
  63835. * The strenth of the explosion.
  63836. */
  63837. strength: number;
  63838. /**
  63839. * The strenght of the force in correspondence to the distance of the affected object
  63840. */
  63841. falloff: PhysicsRadialImpulseFalloff;
  63842. /**
  63843. * Sphere options for the radial explosion.
  63844. */
  63845. sphere: {
  63846. segments: number;
  63847. diameter: number;
  63848. };
  63849. /**
  63850. * Sphere options for the radial explosion.
  63851. */
  63852. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63853. }
  63854. /**
  63855. * Options fot the updraft event
  63856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63857. */
  63858. export class PhysicsUpdraftEventOptions {
  63859. /**
  63860. * The radius of the cylinder for the vortex
  63861. */
  63862. radius: number;
  63863. /**
  63864. * The strenth of the updraft.
  63865. */
  63866. strength: number;
  63867. /**
  63868. * The height of the cylinder for the updraft.
  63869. */
  63870. height: number;
  63871. /**
  63872. * The mode for the the updraft.
  63873. */
  63874. updraftMode: PhysicsUpdraftMode;
  63875. }
  63876. /**
  63877. * Options fot the vortex event
  63878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63879. */
  63880. export class PhysicsVortexEventOptions {
  63881. /**
  63882. * The radius of the cylinder for the vortex
  63883. */
  63884. radius: number;
  63885. /**
  63886. * The strenth of the vortex.
  63887. */
  63888. strength: number;
  63889. /**
  63890. * The height of the cylinder for the vortex.
  63891. */
  63892. height: number;
  63893. /**
  63894. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63895. */
  63896. centripetalForceThreshold: number;
  63897. /**
  63898. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63899. */
  63900. centripetalForceMultiplier: number;
  63901. /**
  63902. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63903. */
  63904. centrifugalForceMultiplier: number;
  63905. /**
  63906. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63907. */
  63908. updraftForceMultiplier: number;
  63909. }
  63910. /**
  63911. * The strenght of the force in correspondence to the distance of the affected object
  63912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63913. */
  63914. export enum PhysicsRadialImpulseFalloff {
  63915. /** Defines that impulse is constant in strength across it's whole radius */
  63916. Constant = 0,
  63917. /** Defines that impulse gets weaker if it's further from the origin */
  63918. Linear = 1
  63919. }
  63920. /**
  63921. * The strength of the force in correspondence to the distance of the affected object
  63922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63923. */
  63924. export enum PhysicsUpdraftMode {
  63925. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63926. Center = 0,
  63927. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63928. Perpendicular = 1
  63929. }
  63930. /**
  63931. * Interface for a physics hit data
  63932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63933. */
  63934. export interface PhysicsHitData {
  63935. /**
  63936. * The force applied at the contact point
  63937. */
  63938. force: Vector3;
  63939. /**
  63940. * The contact point
  63941. */
  63942. contactPoint: Vector3;
  63943. /**
  63944. * The distance from the origin to the contact point
  63945. */
  63946. distanceFromOrigin: number;
  63947. }
  63948. /**
  63949. * Interface for radial explosion event data
  63950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63951. */
  63952. export interface PhysicsRadialExplosionEventData {
  63953. /**
  63954. * A sphere used for the radial explosion event
  63955. */
  63956. sphere: Mesh;
  63957. }
  63958. /**
  63959. * Interface for gravitational field event data
  63960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63961. */
  63962. export interface PhysicsGravitationalFieldEventData {
  63963. /**
  63964. * A sphere mesh used for the gravitational field event
  63965. */
  63966. sphere: Mesh;
  63967. }
  63968. /**
  63969. * Interface for updraft event data
  63970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63971. */
  63972. export interface PhysicsUpdraftEventData {
  63973. /**
  63974. * A cylinder used for the updraft event
  63975. */
  63976. cylinder: Mesh;
  63977. }
  63978. /**
  63979. * Interface for vortex event data
  63980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63981. */
  63982. export interface PhysicsVortexEventData {
  63983. /**
  63984. * A cylinder used for the vortex event
  63985. */
  63986. cylinder: Mesh;
  63987. }
  63988. /**
  63989. * Interface for an affected physics impostor
  63990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63991. */
  63992. export interface PhysicsAffectedImpostorWithData {
  63993. /**
  63994. * The impostor affected by the effect
  63995. */
  63996. impostor: PhysicsImpostor;
  63997. /**
  63998. * The data about the hit/horce from the explosion
  63999. */
  64000. hitData: PhysicsHitData;
  64001. }
  64002. }
  64003. declare module BABYLON {
  64004. /** @hidden */
  64005. export var blackAndWhitePixelShader: {
  64006. name: string;
  64007. shader: string;
  64008. };
  64009. }
  64010. declare module BABYLON {
  64011. /**
  64012. * Post process used to render in black and white
  64013. */
  64014. export class BlackAndWhitePostProcess extends PostProcess {
  64015. /**
  64016. * Linear about to convert he result to black and white (default: 1)
  64017. */
  64018. degree: number;
  64019. /**
  64020. * Creates a black and white post process
  64021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64022. * @param name The name of the effect.
  64023. * @param options The required width/height ratio to downsize to before computing the render pass.
  64024. * @param camera The camera to apply the render pass to.
  64025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64026. * @param engine The engine which the post process will be applied. (default: current engine)
  64027. * @param reusable If the post process can be reused on the same frame. (default: false)
  64028. */
  64029. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64030. }
  64031. }
  64032. declare module BABYLON {
  64033. /**
  64034. * This represents a set of one or more post processes in Babylon.
  64035. * A post process can be used to apply a shader to a texture after it is rendered.
  64036. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64037. */
  64038. export class PostProcessRenderEffect {
  64039. private _postProcesses;
  64040. private _getPostProcesses;
  64041. private _singleInstance;
  64042. private _cameras;
  64043. private _indicesForCamera;
  64044. /**
  64045. * Name of the effect
  64046. * @hidden
  64047. */
  64048. _name: string;
  64049. /**
  64050. * Instantiates a post process render effect.
  64051. * A post process can be used to apply a shader to a texture after it is rendered.
  64052. * @param engine The engine the effect is tied to
  64053. * @param name The name of the effect
  64054. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64055. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64056. */
  64057. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64058. /**
  64059. * Checks if all the post processes in the effect are supported.
  64060. */
  64061. get isSupported(): boolean;
  64062. /**
  64063. * Updates the current state of the effect
  64064. * @hidden
  64065. */
  64066. _update(): void;
  64067. /**
  64068. * Attaches the effect on cameras
  64069. * @param cameras The camera to attach to.
  64070. * @hidden
  64071. */
  64072. _attachCameras(cameras: Camera): void;
  64073. /**
  64074. * Attaches the effect on cameras
  64075. * @param cameras The camera to attach to.
  64076. * @hidden
  64077. */
  64078. _attachCameras(cameras: Camera[]): void;
  64079. /**
  64080. * Detaches the effect on cameras
  64081. * @param cameras The camera to detatch from.
  64082. * @hidden
  64083. */
  64084. _detachCameras(cameras: Camera): void;
  64085. /**
  64086. * Detatches the effect on cameras
  64087. * @param cameras The camera to detatch from.
  64088. * @hidden
  64089. */
  64090. _detachCameras(cameras: Camera[]): void;
  64091. /**
  64092. * Enables the effect on given cameras
  64093. * @param cameras The camera to enable.
  64094. * @hidden
  64095. */
  64096. _enable(cameras: Camera): void;
  64097. /**
  64098. * Enables the effect on given cameras
  64099. * @param cameras The camera to enable.
  64100. * @hidden
  64101. */
  64102. _enable(cameras: Nullable<Camera[]>): void;
  64103. /**
  64104. * Disables the effect on the given cameras
  64105. * @param cameras The camera to disable.
  64106. * @hidden
  64107. */
  64108. _disable(cameras: Camera): void;
  64109. /**
  64110. * Disables the effect on the given cameras
  64111. * @param cameras The camera to disable.
  64112. * @hidden
  64113. */
  64114. _disable(cameras: Nullable<Camera[]>): void;
  64115. /**
  64116. * Gets a list of the post processes contained in the effect.
  64117. * @param camera The camera to get the post processes on.
  64118. * @returns The list of the post processes in the effect.
  64119. */
  64120. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64121. }
  64122. }
  64123. declare module BABYLON {
  64124. /** @hidden */
  64125. export var extractHighlightsPixelShader: {
  64126. name: string;
  64127. shader: string;
  64128. };
  64129. }
  64130. declare module BABYLON {
  64131. /**
  64132. * 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.
  64133. */
  64134. export class ExtractHighlightsPostProcess extends PostProcess {
  64135. /**
  64136. * The luminance threshold, pixels below this value will be set to black.
  64137. */
  64138. threshold: number;
  64139. /** @hidden */
  64140. _exposure: number;
  64141. /**
  64142. * Post process which has the input texture to be used when performing highlight extraction
  64143. * @hidden
  64144. */
  64145. _inputPostProcess: Nullable<PostProcess>;
  64146. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64147. }
  64148. }
  64149. declare module BABYLON {
  64150. /** @hidden */
  64151. export var bloomMergePixelShader: {
  64152. name: string;
  64153. shader: string;
  64154. };
  64155. }
  64156. declare module BABYLON {
  64157. /**
  64158. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64159. */
  64160. export class BloomMergePostProcess extends PostProcess {
  64161. /** Weight of the bloom to be added to the original input. */
  64162. weight: number;
  64163. /**
  64164. * Creates a new instance of @see BloomMergePostProcess
  64165. * @param name The name of the effect.
  64166. * @param originalFromInput Post process which's input will be used for the merge.
  64167. * @param blurred Blurred highlights post process which's output will be used.
  64168. * @param weight Weight of the bloom to be added to the original input.
  64169. * @param options The required width/height ratio to downsize to before computing the render pass.
  64170. * @param camera The camera to apply the render pass to.
  64171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64172. * @param engine The engine which the post process will be applied. (default: current engine)
  64173. * @param reusable If the post process can be reused on the same frame. (default: false)
  64174. * @param textureType Type of textures used when performing the post process. (default: 0)
  64175. * @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)
  64176. */
  64177. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64178. /** Weight of the bloom to be added to the original input. */
  64179. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64180. }
  64181. }
  64182. declare module BABYLON {
  64183. /**
  64184. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64185. */
  64186. export class BloomEffect extends PostProcessRenderEffect {
  64187. private bloomScale;
  64188. /**
  64189. * @hidden Internal
  64190. */
  64191. _effects: Array<PostProcess>;
  64192. /**
  64193. * @hidden Internal
  64194. */
  64195. _downscale: ExtractHighlightsPostProcess;
  64196. private _blurX;
  64197. private _blurY;
  64198. private _merge;
  64199. /**
  64200. * The luminance threshold to find bright areas of the image to bloom.
  64201. */
  64202. get threshold(): number;
  64203. set threshold(value: number);
  64204. /**
  64205. * The strength of the bloom.
  64206. */
  64207. get weight(): number;
  64208. set weight(value: number);
  64209. /**
  64210. * Specifies the size of the bloom blur kernel, relative to the final output size
  64211. */
  64212. get kernel(): number;
  64213. set kernel(value: number);
  64214. /**
  64215. * Creates a new instance of @see BloomEffect
  64216. * @param scene The scene the effect belongs to.
  64217. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64218. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64219. * @param bloomWeight The the strength of bloom.
  64220. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64221. * @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)
  64222. */
  64223. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64224. /**
  64225. * Disposes each of the internal effects for a given camera.
  64226. * @param camera The camera to dispose the effect on.
  64227. */
  64228. disposeEffects(camera: Camera): void;
  64229. /**
  64230. * @hidden Internal
  64231. */
  64232. _updateEffects(): void;
  64233. /**
  64234. * Internal
  64235. * @returns if all the contained post processes are ready.
  64236. * @hidden
  64237. */
  64238. _isReady(): boolean;
  64239. }
  64240. }
  64241. declare module BABYLON {
  64242. /** @hidden */
  64243. export var chromaticAberrationPixelShader: {
  64244. name: string;
  64245. shader: string;
  64246. };
  64247. }
  64248. declare module BABYLON {
  64249. /**
  64250. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64251. */
  64252. export class ChromaticAberrationPostProcess extends PostProcess {
  64253. /**
  64254. * The amount of seperation of rgb channels (default: 30)
  64255. */
  64256. aberrationAmount: number;
  64257. /**
  64258. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64259. */
  64260. radialIntensity: number;
  64261. /**
  64262. * 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))
  64263. */
  64264. direction: Vector2;
  64265. /**
  64266. * 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))
  64267. */
  64268. centerPosition: Vector2;
  64269. /**
  64270. * Creates a new instance ChromaticAberrationPostProcess
  64271. * @param name The name of the effect.
  64272. * @param screenWidth The width of the screen to apply the effect on.
  64273. * @param screenHeight The height of the screen to apply the effect on.
  64274. * @param options The required width/height ratio to downsize to before computing the render pass.
  64275. * @param camera The camera to apply the render pass to.
  64276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64277. * @param engine The engine which the post process will be applied. (default: current engine)
  64278. * @param reusable If the post process can be reused on the same frame. (default: false)
  64279. * @param textureType Type of textures used when performing the post process. (default: 0)
  64280. * @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)
  64281. */
  64282. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64283. }
  64284. }
  64285. declare module BABYLON {
  64286. /** @hidden */
  64287. export var circleOfConfusionPixelShader: {
  64288. name: string;
  64289. shader: string;
  64290. };
  64291. }
  64292. declare module BABYLON {
  64293. /**
  64294. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64295. */
  64296. export class CircleOfConfusionPostProcess extends PostProcess {
  64297. /**
  64298. * 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.
  64299. */
  64300. lensSize: number;
  64301. /**
  64302. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64303. */
  64304. fStop: number;
  64305. /**
  64306. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64307. */
  64308. focusDistance: number;
  64309. /**
  64310. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64311. */
  64312. focalLength: number;
  64313. private _depthTexture;
  64314. /**
  64315. * Creates a new instance CircleOfConfusionPostProcess
  64316. * @param name The name of the effect.
  64317. * @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.
  64318. * @param options The required width/height ratio to downsize to before computing the render pass.
  64319. * @param camera The camera to apply the render pass to.
  64320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64321. * @param engine The engine which the post process will be applied. (default: current engine)
  64322. * @param reusable If the post process can be reused on the same frame. (default: false)
  64323. * @param textureType Type of textures used when performing the post process. (default: 0)
  64324. * @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)
  64325. */
  64326. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64327. /**
  64328. * 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.
  64329. */
  64330. set depthTexture(value: RenderTargetTexture);
  64331. }
  64332. }
  64333. declare module BABYLON {
  64334. /** @hidden */
  64335. export var colorCorrectionPixelShader: {
  64336. name: string;
  64337. shader: string;
  64338. };
  64339. }
  64340. declare module BABYLON {
  64341. /**
  64342. *
  64343. * This post-process allows the modification of rendered colors by using
  64344. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64345. *
  64346. * The object needs to be provided an url to a texture containing the color
  64347. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64348. * Use an image editing software to tweak the LUT to match your needs.
  64349. *
  64350. * For an example of a color LUT, see here:
  64351. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64352. * For explanations on color grading, see here:
  64353. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64354. *
  64355. */
  64356. export class ColorCorrectionPostProcess extends PostProcess {
  64357. private _colorTableTexture;
  64358. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64359. }
  64360. }
  64361. declare module BABYLON {
  64362. /** @hidden */
  64363. export var convolutionPixelShader: {
  64364. name: string;
  64365. shader: string;
  64366. };
  64367. }
  64368. declare module BABYLON {
  64369. /**
  64370. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64371. * input texture to perform effects such as edge detection or sharpening
  64372. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64373. */
  64374. export class ConvolutionPostProcess extends PostProcess {
  64375. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64376. kernel: number[];
  64377. /**
  64378. * Creates a new instance ConvolutionPostProcess
  64379. * @param name The name of the effect.
  64380. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64381. * @param options The required width/height ratio to downsize to before computing the render pass.
  64382. * @param camera The camera to apply the render pass to.
  64383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64384. * @param engine The engine which the post process will be applied. (default: current engine)
  64385. * @param reusable If the post process can be reused on the same frame. (default: false)
  64386. * @param textureType Type of textures used when performing the post process. (default: 0)
  64387. */
  64388. constructor(name: string,
  64389. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64390. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64391. /**
  64392. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64393. */
  64394. static EdgeDetect0Kernel: number[];
  64395. /**
  64396. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64397. */
  64398. static EdgeDetect1Kernel: number[];
  64399. /**
  64400. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64401. */
  64402. static EdgeDetect2Kernel: number[];
  64403. /**
  64404. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64405. */
  64406. static SharpenKernel: number[];
  64407. /**
  64408. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64409. */
  64410. static EmbossKernel: number[];
  64411. /**
  64412. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64413. */
  64414. static GaussianKernel: number[];
  64415. }
  64416. }
  64417. declare module BABYLON {
  64418. /**
  64419. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64420. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64421. * based on samples that have a large difference in distance than the center pixel.
  64422. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64423. */
  64424. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64425. direction: Vector2;
  64426. /**
  64427. * Creates a new instance CircleOfConfusionPostProcess
  64428. * @param name The name of the effect.
  64429. * @param scene The scene the effect belongs to.
  64430. * @param direction The direction the blur should be applied.
  64431. * @param kernel The size of the kernel used to blur.
  64432. * @param options The required width/height ratio to downsize to before computing the render pass.
  64433. * @param camera The camera to apply the render pass to.
  64434. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64435. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64437. * @param engine The engine which the post process will be applied. (default: current engine)
  64438. * @param reusable If the post process can be reused on the same frame. (default: false)
  64439. * @param textureType Type of textures used when performing the post process. (default: 0)
  64440. * @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)
  64441. */
  64442. 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);
  64443. }
  64444. }
  64445. declare module BABYLON {
  64446. /** @hidden */
  64447. export var depthOfFieldMergePixelShader: {
  64448. name: string;
  64449. shader: string;
  64450. };
  64451. }
  64452. declare module BABYLON {
  64453. /**
  64454. * Options to be set when merging outputs from the default pipeline.
  64455. */
  64456. export class DepthOfFieldMergePostProcessOptions {
  64457. /**
  64458. * The original image to merge on top of
  64459. */
  64460. originalFromInput: PostProcess;
  64461. /**
  64462. * Parameters to perform the merge of the depth of field effect
  64463. */
  64464. depthOfField?: {
  64465. circleOfConfusion: PostProcess;
  64466. blurSteps: Array<PostProcess>;
  64467. };
  64468. /**
  64469. * Parameters to perform the merge of bloom effect
  64470. */
  64471. bloom?: {
  64472. blurred: PostProcess;
  64473. weight: number;
  64474. };
  64475. }
  64476. /**
  64477. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64478. */
  64479. export class DepthOfFieldMergePostProcess extends PostProcess {
  64480. private blurSteps;
  64481. /**
  64482. * Creates a new instance of DepthOfFieldMergePostProcess
  64483. * @param name The name of the effect.
  64484. * @param originalFromInput Post process which's input will be used for the merge.
  64485. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64486. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64487. * @param options The required width/height ratio to downsize to before computing the render pass.
  64488. * @param camera The camera to apply the render pass to.
  64489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64490. * @param engine The engine which the post process will be applied. (default: current engine)
  64491. * @param reusable If the post process can be reused on the same frame. (default: false)
  64492. * @param textureType Type of textures used when performing the post process. (default: 0)
  64493. * @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)
  64494. */
  64495. 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);
  64496. /**
  64497. * Updates the effect with the current post process compile time values and recompiles the shader.
  64498. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64499. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64500. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64501. * @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
  64502. * @param onCompiled Called when the shader has been compiled.
  64503. * @param onError Called if there is an error when compiling a shader.
  64504. */
  64505. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64506. }
  64507. }
  64508. declare module BABYLON {
  64509. /**
  64510. * Specifies the level of max blur that should be applied when using the depth of field effect
  64511. */
  64512. export enum DepthOfFieldEffectBlurLevel {
  64513. /**
  64514. * Subtle blur
  64515. */
  64516. Low = 0,
  64517. /**
  64518. * Medium blur
  64519. */
  64520. Medium = 1,
  64521. /**
  64522. * Large blur
  64523. */
  64524. High = 2
  64525. }
  64526. /**
  64527. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64528. */
  64529. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64530. private _circleOfConfusion;
  64531. /**
  64532. * @hidden Internal, blurs from high to low
  64533. */
  64534. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64535. private _depthOfFieldBlurY;
  64536. private _dofMerge;
  64537. /**
  64538. * @hidden Internal post processes in depth of field effect
  64539. */
  64540. _effects: Array<PostProcess>;
  64541. /**
  64542. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64543. */
  64544. set focalLength(value: number);
  64545. get focalLength(): number;
  64546. /**
  64547. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64548. */
  64549. set fStop(value: number);
  64550. get fStop(): number;
  64551. /**
  64552. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64553. */
  64554. set focusDistance(value: number);
  64555. get focusDistance(): number;
  64556. /**
  64557. * 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.
  64558. */
  64559. set lensSize(value: number);
  64560. get lensSize(): number;
  64561. /**
  64562. * Creates a new instance DepthOfFieldEffect
  64563. * @param scene The scene the effect belongs to.
  64564. * @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.
  64565. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64566. * @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)
  64567. */
  64568. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64569. /**
  64570. * Get the current class name of the current effet
  64571. * @returns "DepthOfFieldEffect"
  64572. */
  64573. getClassName(): string;
  64574. /**
  64575. * 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.
  64576. */
  64577. set depthTexture(value: RenderTargetTexture);
  64578. /**
  64579. * Disposes each of the internal effects for a given camera.
  64580. * @param camera The camera to dispose the effect on.
  64581. */
  64582. disposeEffects(camera: Camera): void;
  64583. /**
  64584. * @hidden Internal
  64585. */
  64586. _updateEffects(): void;
  64587. /**
  64588. * Internal
  64589. * @returns if all the contained post processes are ready.
  64590. * @hidden
  64591. */
  64592. _isReady(): boolean;
  64593. }
  64594. }
  64595. declare module BABYLON {
  64596. /** @hidden */
  64597. export var displayPassPixelShader: {
  64598. name: string;
  64599. shader: string;
  64600. };
  64601. }
  64602. declare module BABYLON {
  64603. /**
  64604. * DisplayPassPostProcess which produces an output the same as it's input
  64605. */
  64606. export class DisplayPassPostProcess extends PostProcess {
  64607. /**
  64608. * Creates the DisplayPassPostProcess
  64609. * @param name The name of the effect.
  64610. * @param options The required width/height ratio to downsize to before computing the render pass.
  64611. * @param camera The camera to apply the render pass to.
  64612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64613. * @param engine The engine which the post process will be applied. (default: current engine)
  64614. * @param reusable If the post process can be reused on the same frame. (default: false)
  64615. */
  64616. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64617. }
  64618. }
  64619. declare module BABYLON {
  64620. /** @hidden */
  64621. export var filterPixelShader: {
  64622. name: string;
  64623. shader: string;
  64624. };
  64625. }
  64626. declare module BABYLON {
  64627. /**
  64628. * Applies a kernel filter to the image
  64629. */
  64630. export class FilterPostProcess extends PostProcess {
  64631. /** The matrix to be applied to the image */
  64632. kernelMatrix: Matrix;
  64633. /**
  64634. *
  64635. * @param name The name of the effect.
  64636. * @param kernelMatrix The matrix to be applied to the image
  64637. * @param options The required width/height ratio to downsize to before computing the render pass.
  64638. * @param camera The camera to apply the render pass to.
  64639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64640. * @param engine The engine which the post process will be applied. (default: current engine)
  64641. * @param reusable If the post process can be reused on the same frame. (default: false)
  64642. */
  64643. constructor(name: string,
  64644. /** The matrix to be applied to the image */
  64645. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64646. }
  64647. }
  64648. declare module BABYLON {
  64649. /** @hidden */
  64650. export var fxaaPixelShader: {
  64651. name: string;
  64652. shader: string;
  64653. };
  64654. }
  64655. declare module BABYLON {
  64656. /** @hidden */
  64657. export var fxaaVertexShader: {
  64658. name: string;
  64659. shader: string;
  64660. };
  64661. }
  64662. declare module BABYLON {
  64663. /**
  64664. * Fxaa post process
  64665. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64666. */
  64667. export class FxaaPostProcess extends PostProcess {
  64668. /** @hidden */
  64669. texelWidth: number;
  64670. /** @hidden */
  64671. texelHeight: number;
  64672. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64673. private _getDefines;
  64674. }
  64675. }
  64676. declare module BABYLON {
  64677. /** @hidden */
  64678. export var grainPixelShader: {
  64679. name: string;
  64680. shader: string;
  64681. };
  64682. }
  64683. declare module BABYLON {
  64684. /**
  64685. * The GrainPostProcess adds noise to the image at mid luminance levels
  64686. */
  64687. export class GrainPostProcess extends PostProcess {
  64688. /**
  64689. * The intensity of the grain added (default: 30)
  64690. */
  64691. intensity: number;
  64692. /**
  64693. * If the grain should be randomized on every frame
  64694. */
  64695. animated: boolean;
  64696. /**
  64697. * Creates a new instance of @see GrainPostProcess
  64698. * @param name The name of the effect.
  64699. * @param options The required width/height ratio to downsize to before computing the render pass.
  64700. * @param camera The camera to apply the render pass to.
  64701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64702. * @param engine The engine which the post process will be applied. (default: current engine)
  64703. * @param reusable If the post process can be reused on the same frame. (default: false)
  64704. * @param textureType Type of textures used when performing the post process. (default: 0)
  64705. * @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)
  64706. */
  64707. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64708. }
  64709. }
  64710. declare module BABYLON {
  64711. /** @hidden */
  64712. export var highlightsPixelShader: {
  64713. name: string;
  64714. shader: string;
  64715. };
  64716. }
  64717. declare module BABYLON {
  64718. /**
  64719. * Extracts highlights from the image
  64720. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64721. */
  64722. export class HighlightsPostProcess extends PostProcess {
  64723. /**
  64724. * Extracts highlights from the image
  64725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64726. * @param name The name of the effect.
  64727. * @param options The required width/height ratio to downsize to before computing the render pass.
  64728. * @param camera The camera to apply the render pass to.
  64729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64730. * @param engine The engine which the post process will be applied. (default: current engine)
  64731. * @param reusable If the post process can be reused on the same frame. (default: false)
  64732. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64733. */
  64734. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64735. }
  64736. }
  64737. declare module BABYLON {
  64738. /** @hidden */
  64739. export var mrtFragmentDeclaration: {
  64740. name: string;
  64741. shader: string;
  64742. };
  64743. }
  64744. declare module BABYLON {
  64745. /** @hidden */
  64746. export var geometryPixelShader: {
  64747. name: string;
  64748. shader: string;
  64749. };
  64750. }
  64751. declare module BABYLON {
  64752. /** @hidden */
  64753. export var geometryVertexShader: {
  64754. name: string;
  64755. shader: string;
  64756. };
  64757. }
  64758. declare module BABYLON {
  64759. /** @hidden */
  64760. interface ISavedTransformationMatrix {
  64761. world: Matrix;
  64762. viewProjection: Matrix;
  64763. }
  64764. /**
  64765. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64766. */
  64767. export class GeometryBufferRenderer {
  64768. /**
  64769. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64770. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64771. */
  64772. static readonly POSITION_TEXTURE_TYPE: number;
  64773. /**
  64774. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64775. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64776. */
  64777. static readonly VELOCITY_TEXTURE_TYPE: number;
  64778. /**
  64779. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64780. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64781. */
  64782. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64783. /**
  64784. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64785. * in order to compute objects velocities when enableVelocity is set to "true"
  64786. * @hidden
  64787. */
  64788. _previousTransformationMatrices: {
  64789. [index: number]: ISavedTransformationMatrix;
  64790. };
  64791. /**
  64792. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64793. * in order to compute objects velocities when enableVelocity is set to "true"
  64794. * @hidden
  64795. */
  64796. _previousBonesTransformationMatrices: {
  64797. [index: number]: Float32Array;
  64798. };
  64799. /**
  64800. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64801. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64802. */
  64803. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64804. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64805. renderTransparentMeshes: boolean;
  64806. private _scene;
  64807. private _multiRenderTarget;
  64808. private _ratio;
  64809. private _enablePosition;
  64810. private _enableVelocity;
  64811. private _enableReflectivity;
  64812. private _positionIndex;
  64813. private _velocityIndex;
  64814. private _reflectivityIndex;
  64815. protected _effect: Effect;
  64816. protected _cachedDefines: string;
  64817. /**
  64818. * Set the render list (meshes to be rendered) used in the G buffer.
  64819. */
  64820. set renderList(meshes: Mesh[]);
  64821. /**
  64822. * Gets wether or not G buffer are supported by the running hardware.
  64823. * This requires draw buffer supports
  64824. */
  64825. get isSupported(): boolean;
  64826. /**
  64827. * Returns the index of the given texture type in the G-Buffer textures array
  64828. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64829. * @returns the index of the given texture type in the G-Buffer textures array
  64830. */
  64831. getTextureIndex(textureType: number): number;
  64832. /**
  64833. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64834. */
  64835. get enablePosition(): boolean;
  64836. /**
  64837. * Sets whether or not objects positions are enabled for the G buffer.
  64838. */
  64839. set enablePosition(enable: boolean);
  64840. /**
  64841. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64842. */
  64843. get enableVelocity(): boolean;
  64844. /**
  64845. * Sets wether or not objects velocities are enabled for the G buffer.
  64846. */
  64847. set enableVelocity(enable: boolean);
  64848. /**
  64849. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64850. */
  64851. get enableReflectivity(): boolean;
  64852. /**
  64853. * Sets wether or not objects roughness are enabled for the G buffer.
  64854. */
  64855. set enableReflectivity(enable: boolean);
  64856. /**
  64857. * Gets the scene associated with the buffer.
  64858. */
  64859. get scene(): Scene;
  64860. /**
  64861. * Gets the ratio used by the buffer during its creation.
  64862. * How big is the buffer related to the main canvas.
  64863. */
  64864. get ratio(): number;
  64865. /** @hidden */
  64866. static _SceneComponentInitialization: (scene: Scene) => void;
  64867. /**
  64868. * Creates a new G Buffer for the scene
  64869. * @param scene The scene the buffer belongs to
  64870. * @param ratio How big is the buffer related to the main canvas.
  64871. */
  64872. constructor(scene: Scene, ratio?: number);
  64873. /**
  64874. * Checks wether everything is ready to render a submesh to the G buffer.
  64875. * @param subMesh the submesh to check readiness for
  64876. * @param useInstances is the mesh drawn using instance or not
  64877. * @returns true if ready otherwise false
  64878. */
  64879. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64880. /**
  64881. * Gets the current underlying G Buffer.
  64882. * @returns the buffer
  64883. */
  64884. getGBuffer(): MultiRenderTarget;
  64885. /**
  64886. * Gets the number of samples used to render the buffer (anti aliasing).
  64887. */
  64888. get samples(): number;
  64889. /**
  64890. * Sets the number of samples used to render the buffer (anti aliasing).
  64891. */
  64892. set samples(value: number);
  64893. /**
  64894. * Disposes the renderer and frees up associated resources.
  64895. */
  64896. dispose(): void;
  64897. protected _createRenderTargets(): void;
  64898. private _copyBonesTransformationMatrices;
  64899. }
  64900. }
  64901. declare module BABYLON {
  64902. interface Scene {
  64903. /** @hidden (Backing field) */
  64904. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64905. /**
  64906. * Gets or Sets the current geometry buffer associated to the scene.
  64907. */
  64908. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64909. /**
  64910. * Enables a GeometryBufferRender and associates it with the scene
  64911. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64912. * @returns the GeometryBufferRenderer
  64913. */
  64914. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64915. /**
  64916. * Disables the GeometryBufferRender associated with the scene
  64917. */
  64918. disableGeometryBufferRenderer(): void;
  64919. }
  64920. /**
  64921. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64922. * in several rendering techniques.
  64923. */
  64924. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64925. /**
  64926. * The component name helpful to identify the component in the list of scene components.
  64927. */
  64928. readonly name: string;
  64929. /**
  64930. * The scene the component belongs to.
  64931. */
  64932. scene: Scene;
  64933. /**
  64934. * Creates a new instance of the component for the given scene
  64935. * @param scene Defines the scene to register the component in
  64936. */
  64937. constructor(scene: Scene);
  64938. /**
  64939. * Registers the component in a given scene
  64940. */
  64941. register(): void;
  64942. /**
  64943. * Rebuilds the elements related to this component in case of
  64944. * context lost for instance.
  64945. */
  64946. rebuild(): void;
  64947. /**
  64948. * Disposes the component and the associated ressources
  64949. */
  64950. dispose(): void;
  64951. private _gatherRenderTargets;
  64952. }
  64953. }
  64954. declare module BABYLON {
  64955. /** @hidden */
  64956. export var motionBlurPixelShader: {
  64957. name: string;
  64958. shader: string;
  64959. };
  64960. }
  64961. declare module BABYLON {
  64962. /**
  64963. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64964. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64965. * As an example, all you have to do is to create the post-process:
  64966. * var mb = new BABYLON.MotionBlurPostProcess(
  64967. * 'mb', // The name of the effect.
  64968. * scene, // The scene containing the objects to blur according to their velocity.
  64969. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64970. * camera // The camera to apply the render pass to.
  64971. * );
  64972. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64973. */
  64974. export class MotionBlurPostProcess extends PostProcess {
  64975. /**
  64976. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64977. */
  64978. motionStrength: number;
  64979. /**
  64980. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64981. */
  64982. get motionBlurSamples(): number;
  64983. /**
  64984. * Sets the number of iterations to be used for motion blur quality
  64985. */
  64986. set motionBlurSamples(samples: number);
  64987. private _motionBlurSamples;
  64988. private _geometryBufferRenderer;
  64989. /**
  64990. * Creates a new instance MotionBlurPostProcess
  64991. * @param name The name of the effect.
  64992. * @param scene The scene containing the objects to blur according to their velocity.
  64993. * @param options The required width/height ratio to downsize to before computing the render pass.
  64994. * @param camera The camera to apply the render pass to.
  64995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64996. * @param engine The engine which the post process will be applied. (default: current engine)
  64997. * @param reusable If the post process can be reused on the same frame. (default: false)
  64998. * @param textureType Type of textures used when performing the post process. (default: 0)
  64999. * @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)
  65000. */
  65001. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65002. /**
  65003. * Excludes the given skinned mesh from computing bones velocities.
  65004. * 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.
  65005. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65006. */
  65007. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65008. /**
  65009. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65010. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65011. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65012. */
  65013. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65014. /**
  65015. * Disposes the post process.
  65016. * @param camera The camera to dispose the post process on.
  65017. */
  65018. dispose(camera?: Camera): void;
  65019. }
  65020. }
  65021. declare module BABYLON {
  65022. /** @hidden */
  65023. export var refractionPixelShader: {
  65024. name: string;
  65025. shader: string;
  65026. };
  65027. }
  65028. declare module BABYLON {
  65029. /**
  65030. * Post process which applies a refractin texture
  65031. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65032. */
  65033. export class RefractionPostProcess extends PostProcess {
  65034. /** the base color of the refraction (used to taint the rendering) */
  65035. color: Color3;
  65036. /** simulated refraction depth */
  65037. depth: number;
  65038. /** the coefficient of the base color (0 to remove base color tainting) */
  65039. colorLevel: number;
  65040. private _refTexture;
  65041. private _ownRefractionTexture;
  65042. /**
  65043. * Gets or sets the refraction texture
  65044. * Please note that you are responsible for disposing the texture if you set it manually
  65045. */
  65046. get refractionTexture(): Texture;
  65047. set refractionTexture(value: Texture);
  65048. /**
  65049. * Initializes the RefractionPostProcess
  65050. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65051. * @param name The name of the effect.
  65052. * @param refractionTextureUrl Url of the refraction texture to use
  65053. * @param color the base color of the refraction (used to taint the rendering)
  65054. * @param depth simulated refraction depth
  65055. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65056. * @param camera The camera to apply the render pass to.
  65057. * @param options The required width/height ratio to downsize to before computing the render pass.
  65058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65059. * @param engine The engine which the post process will be applied. (default: current engine)
  65060. * @param reusable If the post process can be reused on the same frame. (default: false)
  65061. */
  65062. constructor(name: string, refractionTextureUrl: string,
  65063. /** the base color of the refraction (used to taint the rendering) */
  65064. color: Color3,
  65065. /** simulated refraction depth */
  65066. depth: number,
  65067. /** the coefficient of the base color (0 to remove base color tainting) */
  65068. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65069. /**
  65070. * Disposes of the post process
  65071. * @param camera Camera to dispose post process on
  65072. */
  65073. dispose(camera: Camera): void;
  65074. }
  65075. }
  65076. declare module BABYLON {
  65077. /** @hidden */
  65078. export var sharpenPixelShader: {
  65079. name: string;
  65080. shader: string;
  65081. };
  65082. }
  65083. declare module BABYLON {
  65084. /**
  65085. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65086. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65087. */
  65088. export class SharpenPostProcess extends PostProcess {
  65089. /**
  65090. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65091. */
  65092. colorAmount: number;
  65093. /**
  65094. * How much sharpness should be applied (default: 0.3)
  65095. */
  65096. edgeAmount: number;
  65097. /**
  65098. * Creates a new instance ConvolutionPostProcess
  65099. * @param name The name of the effect.
  65100. * @param options The required width/height ratio to downsize to before computing the render pass.
  65101. * @param camera The camera to apply the render pass to.
  65102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65103. * @param engine The engine which the post process will be applied. (default: current engine)
  65104. * @param reusable If the post process can be reused on the same frame. (default: false)
  65105. * @param textureType Type of textures used when performing the post process. (default: 0)
  65106. * @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)
  65107. */
  65108. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65109. }
  65110. }
  65111. declare module BABYLON {
  65112. /**
  65113. * PostProcessRenderPipeline
  65114. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65115. */
  65116. export class PostProcessRenderPipeline {
  65117. private engine;
  65118. private _renderEffects;
  65119. private _renderEffectsForIsolatedPass;
  65120. /**
  65121. * List of inspectable custom properties (used by the Inspector)
  65122. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65123. */
  65124. inspectableCustomProperties: IInspectable[];
  65125. /**
  65126. * @hidden
  65127. */
  65128. protected _cameras: Camera[];
  65129. /** @hidden */
  65130. _name: string;
  65131. /**
  65132. * Gets pipeline name
  65133. */
  65134. get name(): string;
  65135. /** Gets the list of attached cameras */
  65136. get cameras(): Camera[];
  65137. /**
  65138. * Initializes a PostProcessRenderPipeline
  65139. * @param engine engine to add the pipeline to
  65140. * @param name name of the pipeline
  65141. */
  65142. constructor(engine: Engine, name: string);
  65143. /**
  65144. * Gets the class name
  65145. * @returns "PostProcessRenderPipeline"
  65146. */
  65147. getClassName(): string;
  65148. /**
  65149. * If all the render effects in the pipeline are supported
  65150. */
  65151. get isSupported(): boolean;
  65152. /**
  65153. * Adds an effect to the pipeline
  65154. * @param renderEffect the effect to add
  65155. */
  65156. addEffect(renderEffect: PostProcessRenderEffect): void;
  65157. /** @hidden */
  65158. _rebuild(): void;
  65159. /** @hidden */
  65160. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65161. /** @hidden */
  65162. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65163. /** @hidden */
  65164. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65165. /** @hidden */
  65166. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65167. /** @hidden */
  65168. _attachCameras(cameras: Camera, unique: boolean): void;
  65169. /** @hidden */
  65170. _attachCameras(cameras: Camera[], unique: boolean): void;
  65171. /** @hidden */
  65172. _detachCameras(cameras: Camera): void;
  65173. /** @hidden */
  65174. _detachCameras(cameras: Nullable<Camera[]>): void;
  65175. /** @hidden */
  65176. _update(): void;
  65177. /** @hidden */
  65178. _reset(): void;
  65179. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65180. /**
  65181. * Disposes of the pipeline
  65182. */
  65183. dispose(): void;
  65184. }
  65185. }
  65186. declare module BABYLON {
  65187. /**
  65188. * PostProcessRenderPipelineManager class
  65189. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65190. */
  65191. export class PostProcessRenderPipelineManager {
  65192. private _renderPipelines;
  65193. /**
  65194. * Initializes a PostProcessRenderPipelineManager
  65195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65196. */
  65197. constructor();
  65198. /**
  65199. * Gets the list of supported render pipelines
  65200. */
  65201. get supportedPipelines(): PostProcessRenderPipeline[];
  65202. /**
  65203. * Adds a pipeline to the manager
  65204. * @param renderPipeline The pipeline to add
  65205. */
  65206. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65207. /**
  65208. * Attaches a camera to the pipeline
  65209. * @param renderPipelineName The name of the pipeline to attach to
  65210. * @param cameras the camera to attach
  65211. * @param unique if the camera can be attached multiple times to the pipeline
  65212. */
  65213. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65214. /**
  65215. * Detaches a camera from the pipeline
  65216. * @param renderPipelineName The name of the pipeline to detach from
  65217. * @param cameras the camera to detach
  65218. */
  65219. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65220. /**
  65221. * Enables an effect by name on a pipeline
  65222. * @param renderPipelineName the name of the pipeline to enable the effect in
  65223. * @param renderEffectName the name of the effect to enable
  65224. * @param cameras the cameras that the effect should be enabled on
  65225. */
  65226. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65227. /**
  65228. * Disables an effect by name on a pipeline
  65229. * @param renderPipelineName the name of the pipeline to disable the effect in
  65230. * @param renderEffectName the name of the effect to disable
  65231. * @param cameras the cameras that the effect should be disabled on
  65232. */
  65233. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65234. /**
  65235. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65236. */
  65237. update(): void;
  65238. /** @hidden */
  65239. _rebuild(): void;
  65240. /**
  65241. * Disposes of the manager and pipelines
  65242. */
  65243. dispose(): void;
  65244. }
  65245. }
  65246. declare module BABYLON {
  65247. interface Scene {
  65248. /** @hidden (Backing field) */
  65249. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65250. /**
  65251. * Gets the postprocess render pipeline manager
  65252. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65253. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65254. */
  65255. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65256. }
  65257. /**
  65258. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65259. */
  65260. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65261. /**
  65262. * The component name helpfull to identify the component in the list of scene components.
  65263. */
  65264. readonly name: string;
  65265. /**
  65266. * The scene the component belongs to.
  65267. */
  65268. scene: Scene;
  65269. /**
  65270. * Creates a new instance of the component for the given scene
  65271. * @param scene Defines the scene to register the component in
  65272. */
  65273. constructor(scene: Scene);
  65274. /**
  65275. * Registers the component in a given scene
  65276. */
  65277. register(): void;
  65278. /**
  65279. * Rebuilds the elements related to this component in case of
  65280. * context lost for instance.
  65281. */
  65282. rebuild(): void;
  65283. /**
  65284. * Disposes the component and the associated ressources
  65285. */
  65286. dispose(): void;
  65287. private _gatherRenderTargets;
  65288. }
  65289. }
  65290. declare module BABYLON {
  65291. /**
  65292. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65293. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65294. */
  65295. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65296. private _scene;
  65297. private _camerasToBeAttached;
  65298. /**
  65299. * ID of the sharpen post process,
  65300. */
  65301. private readonly SharpenPostProcessId;
  65302. /**
  65303. * @ignore
  65304. * ID of the image processing post process;
  65305. */
  65306. readonly ImageProcessingPostProcessId: string;
  65307. /**
  65308. * @ignore
  65309. * ID of the Fast Approximate Anti-Aliasing post process;
  65310. */
  65311. readonly FxaaPostProcessId: string;
  65312. /**
  65313. * ID of the chromatic aberration post process,
  65314. */
  65315. private readonly ChromaticAberrationPostProcessId;
  65316. /**
  65317. * ID of the grain post process
  65318. */
  65319. private readonly GrainPostProcessId;
  65320. /**
  65321. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65322. */
  65323. sharpen: SharpenPostProcess;
  65324. private _sharpenEffect;
  65325. private bloom;
  65326. /**
  65327. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65328. */
  65329. depthOfField: DepthOfFieldEffect;
  65330. /**
  65331. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65332. */
  65333. fxaa: FxaaPostProcess;
  65334. /**
  65335. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65336. */
  65337. imageProcessing: ImageProcessingPostProcess;
  65338. /**
  65339. * Chromatic aberration post process which will shift rgb colors in the image
  65340. */
  65341. chromaticAberration: ChromaticAberrationPostProcess;
  65342. private _chromaticAberrationEffect;
  65343. /**
  65344. * Grain post process which add noise to the image
  65345. */
  65346. grain: GrainPostProcess;
  65347. private _grainEffect;
  65348. /**
  65349. * Glow post process which adds a glow to emissive areas of the image
  65350. */
  65351. private _glowLayer;
  65352. /**
  65353. * Animations which can be used to tweak settings over a period of time
  65354. */
  65355. animations: Animation[];
  65356. private _imageProcessingConfigurationObserver;
  65357. private _sharpenEnabled;
  65358. private _bloomEnabled;
  65359. private _depthOfFieldEnabled;
  65360. private _depthOfFieldBlurLevel;
  65361. private _fxaaEnabled;
  65362. private _imageProcessingEnabled;
  65363. private _defaultPipelineTextureType;
  65364. private _bloomScale;
  65365. private _chromaticAberrationEnabled;
  65366. private _grainEnabled;
  65367. private _buildAllowed;
  65368. /**
  65369. * Gets active scene
  65370. */
  65371. get scene(): Scene;
  65372. /**
  65373. * Enable or disable the sharpen process from the pipeline
  65374. */
  65375. set sharpenEnabled(enabled: boolean);
  65376. get sharpenEnabled(): boolean;
  65377. private _resizeObserver;
  65378. private _hardwareScaleLevel;
  65379. private _bloomKernel;
  65380. /**
  65381. * Specifies the size of the bloom blur kernel, relative to the final output size
  65382. */
  65383. get bloomKernel(): number;
  65384. set bloomKernel(value: number);
  65385. /**
  65386. * Specifies the weight of the bloom in the final rendering
  65387. */
  65388. private _bloomWeight;
  65389. /**
  65390. * Specifies the luma threshold for the area that will be blurred by the bloom
  65391. */
  65392. private _bloomThreshold;
  65393. private _hdr;
  65394. /**
  65395. * The strength of the bloom.
  65396. */
  65397. set bloomWeight(value: number);
  65398. get bloomWeight(): number;
  65399. /**
  65400. * The strength of the bloom.
  65401. */
  65402. set bloomThreshold(value: number);
  65403. get bloomThreshold(): number;
  65404. /**
  65405. * The scale of the bloom, lower value will provide better performance.
  65406. */
  65407. set bloomScale(value: number);
  65408. get bloomScale(): number;
  65409. /**
  65410. * Enable or disable the bloom from the pipeline
  65411. */
  65412. set bloomEnabled(enabled: boolean);
  65413. get bloomEnabled(): boolean;
  65414. private _rebuildBloom;
  65415. /**
  65416. * If the depth of field is enabled.
  65417. */
  65418. get depthOfFieldEnabled(): boolean;
  65419. set depthOfFieldEnabled(enabled: boolean);
  65420. /**
  65421. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65422. */
  65423. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65424. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65425. /**
  65426. * If the anti aliasing is enabled.
  65427. */
  65428. set fxaaEnabled(enabled: boolean);
  65429. get fxaaEnabled(): boolean;
  65430. private _samples;
  65431. /**
  65432. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65433. */
  65434. set samples(sampleCount: number);
  65435. get samples(): number;
  65436. /**
  65437. * If image processing is enabled.
  65438. */
  65439. set imageProcessingEnabled(enabled: boolean);
  65440. get imageProcessingEnabled(): boolean;
  65441. /**
  65442. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65443. */
  65444. set glowLayerEnabled(enabled: boolean);
  65445. get glowLayerEnabled(): boolean;
  65446. /**
  65447. * Gets the glow layer (or null if not defined)
  65448. */
  65449. get glowLayer(): Nullable<GlowLayer>;
  65450. /**
  65451. * Enable or disable the chromaticAberration process from the pipeline
  65452. */
  65453. set chromaticAberrationEnabled(enabled: boolean);
  65454. get chromaticAberrationEnabled(): boolean;
  65455. /**
  65456. * Enable or disable the grain process from the pipeline
  65457. */
  65458. set grainEnabled(enabled: boolean);
  65459. get grainEnabled(): boolean;
  65460. /**
  65461. * @constructor
  65462. * @param name - The rendering pipeline name (default: "")
  65463. * @param hdr - If high dynamic range textures should be used (default: true)
  65464. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65465. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65466. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65467. */
  65468. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65469. /**
  65470. * Get the class name
  65471. * @returns "DefaultRenderingPipeline"
  65472. */
  65473. getClassName(): string;
  65474. /**
  65475. * Force the compilation of the entire pipeline.
  65476. */
  65477. prepare(): void;
  65478. private _hasCleared;
  65479. private _prevPostProcess;
  65480. private _prevPrevPostProcess;
  65481. private _setAutoClearAndTextureSharing;
  65482. private _depthOfFieldSceneObserver;
  65483. private _buildPipeline;
  65484. private _disposePostProcesses;
  65485. /**
  65486. * Adds a camera to the pipeline
  65487. * @param camera the camera to be added
  65488. */
  65489. addCamera(camera: Camera): void;
  65490. /**
  65491. * Removes a camera from the pipeline
  65492. * @param camera the camera to remove
  65493. */
  65494. removeCamera(camera: Camera): void;
  65495. /**
  65496. * Dispose of the pipeline and stop all post processes
  65497. */
  65498. dispose(): void;
  65499. /**
  65500. * Serialize the rendering pipeline (Used when exporting)
  65501. * @returns the serialized object
  65502. */
  65503. serialize(): any;
  65504. /**
  65505. * Parse the serialized pipeline
  65506. * @param source Source pipeline.
  65507. * @param scene The scene to load the pipeline to.
  65508. * @param rootUrl The URL of the serialized pipeline.
  65509. * @returns An instantiated pipeline from the serialized object.
  65510. */
  65511. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65512. }
  65513. }
  65514. declare module BABYLON {
  65515. /** @hidden */
  65516. export var lensHighlightsPixelShader: {
  65517. name: string;
  65518. shader: string;
  65519. };
  65520. }
  65521. declare module BABYLON {
  65522. /** @hidden */
  65523. export var depthOfFieldPixelShader: {
  65524. name: string;
  65525. shader: string;
  65526. };
  65527. }
  65528. declare module BABYLON {
  65529. /**
  65530. * BABYLON.JS Chromatic Aberration GLSL Shader
  65531. * Author: Olivier Guyot
  65532. * Separates very slightly R, G and B colors on the edges of the screen
  65533. * Inspired by Francois Tarlier & Martins Upitis
  65534. */
  65535. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65536. /**
  65537. * @ignore
  65538. * The chromatic aberration PostProcess id in the pipeline
  65539. */
  65540. LensChromaticAberrationEffect: string;
  65541. /**
  65542. * @ignore
  65543. * The highlights enhancing PostProcess id in the pipeline
  65544. */
  65545. HighlightsEnhancingEffect: string;
  65546. /**
  65547. * @ignore
  65548. * The depth-of-field PostProcess id in the pipeline
  65549. */
  65550. LensDepthOfFieldEffect: string;
  65551. private _scene;
  65552. private _depthTexture;
  65553. private _grainTexture;
  65554. private _chromaticAberrationPostProcess;
  65555. private _highlightsPostProcess;
  65556. private _depthOfFieldPostProcess;
  65557. private _edgeBlur;
  65558. private _grainAmount;
  65559. private _chromaticAberration;
  65560. private _distortion;
  65561. private _highlightsGain;
  65562. private _highlightsThreshold;
  65563. private _dofDistance;
  65564. private _dofAperture;
  65565. private _dofDarken;
  65566. private _dofPentagon;
  65567. private _blurNoise;
  65568. /**
  65569. * @constructor
  65570. *
  65571. * Effect parameters are as follow:
  65572. * {
  65573. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65574. * edge_blur: number; // from 0 to x (1 for realism)
  65575. * distortion: number; // from 0 to x (1 for realism)
  65576. * grain_amount: number; // from 0 to 1
  65577. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65578. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65579. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65580. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65581. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65582. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65583. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65584. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65585. * }
  65586. * Note: if an effect parameter is unset, effect is disabled
  65587. *
  65588. * @param name The rendering pipeline name
  65589. * @param parameters - An object containing all parameters (see above)
  65590. * @param scene The scene linked to this pipeline
  65591. * @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)
  65592. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65593. */
  65594. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65595. /**
  65596. * Get the class name
  65597. * @returns "LensRenderingPipeline"
  65598. */
  65599. getClassName(): string;
  65600. /**
  65601. * Gets associated scene
  65602. */
  65603. get scene(): Scene;
  65604. /**
  65605. * Gets or sets the edge blur
  65606. */
  65607. get edgeBlur(): number;
  65608. set edgeBlur(value: number);
  65609. /**
  65610. * Gets or sets the grain amount
  65611. */
  65612. get grainAmount(): number;
  65613. set grainAmount(value: number);
  65614. /**
  65615. * Gets or sets the chromatic aberration amount
  65616. */
  65617. get chromaticAberration(): number;
  65618. set chromaticAberration(value: number);
  65619. /**
  65620. * Gets or sets the depth of field aperture
  65621. */
  65622. get dofAperture(): number;
  65623. set dofAperture(value: number);
  65624. /**
  65625. * Gets or sets the edge distortion
  65626. */
  65627. get edgeDistortion(): number;
  65628. set edgeDistortion(value: number);
  65629. /**
  65630. * Gets or sets the depth of field distortion
  65631. */
  65632. get dofDistortion(): number;
  65633. set dofDistortion(value: number);
  65634. /**
  65635. * Gets or sets the darken out of focus amount
  65636. */
  65637. get darkenOutOfFocus(): number;
  65638. set darkenOutOfFocus(value: number);
  65639. /**
  65640. * Gets or sets a boolean indicating if blur noise is enabled
  65641. */
  65642. get blurNoise(): boolean;
  65643. set blurNoise(value: boolean);
  65644. /**
  65645. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65646. */
  65647. get pentagonBokeh(): boolean;
  65648. set pentagonBokeh(value: boolean);
  65649. /**
  65650. * Gets or sets the highlight grain amount
  65651. */
  65652. get highlightsGain(): number;
  65653. set highlightsGain(value: number);
  65654. /**
  65655. * Gets or sets the highlight threshold
  65656. */
  65657. get highlightsThreshold(): number;
  65658. set highlightsThreshold(value: number);
  65659. /**
  65660. * Sets the amount of blur at the edges
  65661. * @param amount blur amount
  65662. */
  65663. setEdgeBlur(amount: number): void;
  65664. /**
  65665. * Sets edge blur to 0
  65666. */
  65667. disableEdgeBlur(): void;
  65668. /**
  65669. * Sets the amout of grain
  65670. * @param amount Amount of grain
  65671. */
  65672. setGrainAmount(amount: number): void;
  65673. /**
  65674. * Set grain amount to 0
  65675. */
  65676. disableGrain(): void;
  65677. /**
  65678. * Sets the chromatic aberration amount
  65679. * @param amount amount of chromatic aberration
  65680. */
  65681. setChromaticAberration(amount: number): void;
  65682. /**
  65683. * Sets chromatic aberration amount to 0
  65684. */
  65685. disableChromaticAberration(): void;
  65686. /**
  65687. * Sets the EdgeDistortion amount
  65688. * @param amount amount of EdgeDistortion
  65689. */
  65690. setEdgeDistortion(amount: number): void;
  65691. /**
  65692. * Sets edge distortion to 0
  65693. */
  65694. disableEdgeDistortion(): void;
  65695. /**
  65696. * Sets the FocusDistance amount
  65697. * @param amount amount of FocusDistance
  65698. */
  65699. setFocusDistance(amount: number): void;
  65700. /**
  65701. * Disables depth of field
  65702. */
  65703. disableDepthOfField(): void;
  65704. /**
  65705. * Sets the Aperture amount
  65706. * @param amount amount of Aperture
  65707. */
  65708. setAperture(amount: number): void;
  65709. /**
  65710. * Sets the DarkenOutOfFocus amount
  65711. * @param amount amount of DarkenOutOfFocus
  65712. */
  65713. setDarkenOutOfFocus(amount: number): void;
  65714. private _pentagonBokehIsEnabled;
  65715. /**
  65716. * Creates a pentagon bokeh effect
  65717. */
  65718. enablePentagonBokeh(): void;
  65719. /**
  65720. * Disables the pentagon bokeh effect
  65721. */
  65722. disablePentagonBokeh(): void;
  65723. /**
  65724. * Enables noise blur
  65725. */
  65726. enableNoiseBlur(): void;
  65727. /**
  65728. * Disables noise blur
  65729. */
  65730. disableNoiseBlur(): void;
  65731. /**
  65732. * Sets the HighlightsGain amount
  65733. * @param amount amount of HighlightsGain
  65734. */
  65735. setHighlightsGain(amount: number): void;
  65736. /**
  65737. * Sets the HighlightsThreshold amount
  65738. * @param amount amount of HighlightsThreshold
  65739. */
  65740. setHighlightsThreshold(amount: number): void;
  65741. /**
  65742. * Disables highlights
  65743. */
  65744. disableHighlights(): void;
  65745. /**
  65746. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65747. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65748. */
  65749. dispose(disableDepthRender?: boolean): void;
  65750. private _createChromaticAberrationPostProcess;
  65751. private _createHighlightsPostProcess;
  65752. private _createDepthOfFieldPostProcess;
  65753. private _createGrainTexture;
  65754. }
  65755. }
  65756. declare module BABYLON {
  65757. /** @hidden */
  65758. export var ssao2PixelShader: {
  65759. name: string;
  65760. shader: string;
  65761. };
  65762. }
  65763. declare module BABYLON {
  65764. /** @hidden */
  65765. export var ssaoCombinePixelShader: {
  65766. name: string;
  65767. shader: string;
  65768. };
  65769. }
  65770. declare module BABYLON {
  65771. /**
  65772. * Render pipeline to produce ssao effect
  65773. */
  65774. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65775. /**
  65776. * @ignore
  65777. * The PassPostProcess id in the pipeline that contains the original scene color
  65778. */
  65779. SSAOOriginalSceneColorEffect: string;
  65780. /**
  65781. * @ignore
  65782. * The SSAO PostProcess id in the pipeline
  65783. */
  65784. SSAORenderEffect: string;
  65785. /**
  65786. * @ignore
  65787. * The horizontal blur PostProcess id in the pipeline
  65788. */
  65789. SSAOBlurHRenderEffect: string;
  65790. /**
  65791. * @ignore
  65792. * The vertical blur PostProcess id in the pipeline
  65793. */
  65794. SSAOBlurVRenderEffect: string;
  65795. /**
  65796. * @ignore
  65797. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65798. */
  65799. SSAOCombineRenderEffect: string;
  65800. /**
  65801. * The output strength of the SSAO post-process. Default value is 1.0.
  65802. */
  65803. totalStrength: number;
  65804. /**
  65805. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65806. */
  65807. maxZ: number;
  65808. /**
  65809. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65810. */
  65811. minZAspect: number;
  65812. private _samples;
  65813. /**
  65814. * Number of samples used for the SSAO calculations. Default value is 8
  65815. */
  65816. set samples(n: number);
  65817. get samples(): number;
  65818. private _textureSamples;
  65819. /**
  65820. * Number of samples to use for antialiasing
  65821. */
  65822. set textureSamples(n: number);
  65823. get textureSamples(): number;
  65824. /**
  65825. * Ratio object used for SSAO ratio and blur ratio
  65826. */
  65827. private _ratio;
  65828. /**
  65829. * Dynamically generated sphere sampler.
  65830. */
  65831. private _sampleSphere;
  65832. /**
  65833. * Blur filter offsets
  65834. */
  65835. private _samplerOffsets;
  65836. private _expensiveBlur;
  65837. /**
  65838. * If bilateral blur should be used
  65839. */
  65840. set expensiveBlur(b: boolean);
  65841. get expensiveBlur(): boolean;
  65842. /**
  65843. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65844. */
  65845. radius: number;
  65846. /**
  65847. * The base color of the SSAO post-process
  65848. * The final result is "base + ssao" between [0, 1]
  65849. */
  65850. base: number;
  65851. /**
  65852. * Support test.
  65853. */
  65854. static get IsSupported(): boolean;
  65855. private _scene;
  65856. private _depthTexture;
  65857. private _normalTexture;
  65858. private _randomTexture;
  65859. private _originalColorPostProcess;
  65860. private _ssaoPostProcess;
  65861. private _blurHPostProcess;
  65862. private _blurVPostProcess;
  65863. private _ssaoCombinePostProcess;
  65864. /**
  65865. * Gets active scene
  65866. */
  65867. get scene(): Scene;
  65868. /**
  65869. * @constructor
  65870. * @param name The rendering pipeline name
  65871. * @param scene The scene linked to this pipeline
  65872. * @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 }
  65873. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65874. */
  65875. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65876. /**
  65877. * Get the class name
  65878. * @returns "SSAO2RenderingPipeline"
  65879. */
  65880. getClassName(): string;
  65881. /**
  65882. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65883. */
  65884. dispose(disableGeometryBufferRenderer?: boolean): void;
  65885. private _createBlurPostProcess;
  65886. /** @hidden */
  65887. _rebuild(): void;
  65888. private _bits;
  65889. private _radicalInverse_VdC;
  65890. private _hammersley;
  65891. private _hemisphereSample_uniform;
  65892. private _generateHemisphere;
  65893. private _createSSAOPostProcess;
  65894. private _createSSAOCombinePostProcess;
  65895. private _createRandomTexture;
  65896. /**
  65897. * Serialize the rendering pipeline (Used when exporting)
  65898. * @returns the serialized object
  65899. */
  65900. serialize(): any;
  65901. /**
  65902. * Parse the serialized pipeline
  65903. * @param source Source pipeline.
  65904. * @param scene The scene to load the pipeline to.
  65905. * @param rootUrl The URL of the serialized pipeline.
  65906. * @returns An instantiated pipeline from the serialized object.
  65907. */
  65908. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65909. }
  65910. }
  65911. declare module BABYLON {
  65912. /** @hidden */
  65913. export var ssaoPixelShader: {
  65914. name: string;
  65915. shader: string;
  65916. };
  65917. }
  65918. declare module BABYLON {
  65919. /**
  65920. * Render pipeline to produce ssao effect
  65921. */
  65922. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65923. /**
  65924. * @ignore
  65925. * The PassPostProcess id in the pipeline that contains the original scene color
  65926. */
  65927. SSAOOriginalSceneColorEffect: string;
  65928. /**
  65929. * @ignore
  65930. * The SSAO PostProcess id in the pipeline
  65931. */
  65932. SSAORenderEffect: string;
  65933. /**
  65934. * @ignore
  65935. * The horizontal blur PostProcess id in the pipeline
  65936. */
  65937. SSAOBlurHRenderEffect: string;
  65938. /**
  65939. * @ignore
  65940. * The vertical blur PostProcess id in the pipeline
  65941. */
  65942. SSAOBlurVRenderEffect: string;
  65943. /**
  65944. * @ignore
  65945. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65946. */
  65947. SSAOCombineRenderEffect: string;
  65948. /**
  65949. * The output strength of the SSAO post-process. Default value is 1.0.
  65950. */
  65951. totalStrength: number;
  65952. /**
  65953. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65954. */
  65955. radius: number;
  65956. /**
  65957. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65958. * Must not be equal to fallOff and superior to fallOff.
  65959. * Default value is 0.0075
  65960. */
  65961. area: number;
  65962. /**
  65963. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65964. * Must not be equal to area and inferior to area.
  65965. * Default value is 0.000001
  65966. */
  65967. fallOff: number;
  65968. /**
  65969. * The base color of the SSAO post-process
  65970. * The final result is "base + ssao" between [0, 1]
  65971. */
  65972. base: number;
  65973. private _scene;
  65974. private _depthTexture;
  65975. private _randomTexture;
  65976. private _originalColorPostProcess;
  65977. private _ssaoPostProcess;
  65978. private _blurHPostProcess;
  65979. private _blurVPostProcess;
  65980. private _ssaoCombinePostProcess;
  65981. private _firstUpdate;
  65982. /**
  65983. * Gets active scene
  65984. */
  65985. get scene(): Scene;
  65986. /**
  65987. * @constructor
  65988. * @param name - The rendering pipeline name
  65989. * @param scene - The scene linked to this pipeline
  65990. * @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 }
  65991. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65992. */
  65993. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65994. /**
  65995. * Get the class name
  65996. * @returns "SSAORenderingPipeline"
  65997. */
  65998. getClassName(): string;
  65999. /**
  66000. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66001. */
  66002. dispose(disableDepthRender?: boolean): void;
  66003. private _createBlurPostProcess;
  66004. /** @hidden */
  66005. _rebuild(): void;
  66006. private _createSSAOPostProcess;
  66007. private _createSSAOCombinePostProcess;
  66008. private _createRandomTexture;
  66009. }
  66010. }
  66011. declare module BABYLON {
  66012. /** @hidden */
  66013. export var screenSpaceReflectionPixelShader: {
  66014. name: string;
  66015. shader: string;
  66016. };
  66017. }
  66018. declare module BABYLON {
  66019. /**
  66020. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66021. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66022. */
  66023. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66024. /**
  66025. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66026. */
  66027. threshold: number;
  66028. /**
  66029. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66030. */
  66031. strength: number;
  66032. /**
  66033. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66034. */
  66035. reflectionSpecularFalloffExponent: number;
  66036. /**
  66037. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  66038. */
  66039. step: number;
  66040. /**
  66041. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66042. */
  66043. roughnessFactor: number;
  66044. private _geometryBufferRenderer;
  66045. private _enableSmoothReflections;
  66046. private _reflectionSamples;
  66047. private _smoothSteps;
  66048. /**
  66049. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66050. * @param name The name of the effect.
  66051. * @param scene The scene containing the objects to calculate reflections.
  66052. * @param options The required width/height ratio to downsize to before computing the render pass.
  66053. * @param camera The camera to apply the render pass to.
  66054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66055. * @param engine The engine which the post process will be applied. (default: current engine)
  66056. * @param reusable If the post process can be reused on the same frame. (default: false)
  66057. * @param textureType Type of textures used when performing the post process. (default: 0)
  66058. * @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)
  66059. */
  66060. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66061. /**
  66062. * Gets wether or not smoothing reflections is enabled.
  66063. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66064. */
  66065. get enableSmoothReflections(): boolean;
  66066. /**
  66067. * Sets wether or not smoothing reflections is enabled.
  66068. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66069. */
  66070. set enableSmoothReflections(enabled: boolean);
  66071. /**
  66072. * Gets the number of samples taken while computing reflections. More samples count is high,
  66073. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66074. */
  66075. get reflectionSamples(): number;
  66076. /**
  66077. * Sets the number of samples taken while computing reflections. More samples count is high,
  66078. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66079. */
  66080. set reflectionSamples(samples: number);
  66081. /**
  66082. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66083. * more the post-process will require GPU power and can generate a drop in FPS.
  66084. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66085. */
  66086. get smoothSteps(): number;
  66087. set smoothSteps(steps: number);
  66088. private _updateEffectDefines;
  66089. }
  66090. }
  66091. declare module BABYLON {
  66092. /** @hidden */
  66093. export var standardPixelShader: {
  66094. name: string;
  66095. shader: string;
  66096. };
  66097. }
  66098. declare module BABYLON {
  66099. /**
  66100. * Standard rendering pipeline
  66101. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66102. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66103. */
  66104. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66105. /**
  66106. * Public members
  66107. */
  66108. /**
  66109. * Post-process which contains the original scene color before the pipeline applies all the effects
  66110. */
  66111. originalPostProcess: Nullable<PostProcess>;
  66112. /**
  66113. * Post-process used to down scale an image x4
  66114. */
  66115. downSampleX4PostProcess: Nullable<PostProcess>;
  66116. /**
  66117. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66118. */
  66119. brightPassPostProcess: Nullable<PostProcess>;
  66120. /**
  66121. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66122. */
  66123. blurHPostProcesses: PostProcess[];
  66124. /**
  66125. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66126. */
  66127. blurVPostProcesses: PostProcess[];
  66128. /**
  66129. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66130. */
  66131. textureAdderPostProcess: Nullable<PostProcess>;
  66132. /**
  66133. * Post-process used to create volumetric lighting effect
  66134. */
  66135. volumetricLightPostProcess: Nullable<PostProcess>;
  66136. /**
  66137. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66138. */
  66139. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66140. /**
  66141. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66142. */
  66143. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66144. /**
  66145. * Post-process used to merge the volumetric light effect and the real scene color
  66146. */
  66147. volumetricLightMergePostProces: Nullable<PostProcess>;
  66148. /**
  66149. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66150. */
  66151. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66152. /**
  66153. * Base post-process used to calculate the average luminance of the final image for HDR
  66154. */
  66155. luminancePostProcess: Nullable<PostProcess>;
  66156. /**
  66157. * Post-processes used to create down sample post-processes in order to get
  66158. * the average luminance of the final image for HDR
  66159. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66160. */
  66161. luminanceDownSamplePostProcesses: PostProcess[];
  66162. /**
  66163. * Post-process used to create a HDR effect (light adaptation)
  66164. */
  66165. hdrPostProcess: Nullable<PostProcess>;
  66166. /**
  66167. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66168. */
  66169. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66170. /**
  66171. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66172. */
  66173. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66174. /**
  66175. * Post-process used to merge the final HDR post-process and the real scene color
  66176. */
  66177. hdrFinalPostProcess: Nullable<PostProcess>;
  66178. /**
  66179. * Post-process used to create a lens flare effect
  66180. */
  66181. lensFlarePostProcess: Nullable<PostProcess>;
  66182. /**
  66183. * Post-process that merges the result of the lens flare post-process and the real scene color
  66184. */
  66185. lensFlareComposePostProcess: Nullable<PostProcess>;
  66186. /**
  66187. * Post-process used to create a motion blur effect
  66188. */
  66189. motionBlurPostProcess: Nullable<PostProcess>;
  66190. /**
  66191. * Post-process used to create a depth of field effect
  66192. */
  66193. depthOfFieldPostProcess: Nullable<PostProcess>;
  66194. /**
  66195. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66196. */
  66197. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66198. /**
  66199. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66200. */
  66201. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66202. /**
  66203. * Represents the brightness threshold in order to configure the illuminated surfaces
  66204. */
  66205. brightThreshold: number;
  66206. /**
  66207. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66208. */
  66209. blurWidth: number;
  66210. /**
  66211. * Sets if the blur for highlighted surfaces must be only horizontal
  66212. */
  66213. horizontalBlur: boolean;
  66214. /**
  66215. * Gets the overall exposure used by the pipeline
  66216. */
  66217. get exposure(): number;
  66218. /**
  66219. * Sets the overall exposure used by the pipeline
  66220. */
  66221. set exposure(value: number);
  66222. /**
  66223. * Texture used typically to simulate "dirty" on camera lens
  66224. */
  66225. lensTexture: Nullable<Texture>;
  66226. /**
  66227. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66228. */
  66229. volumetricLightCoefficient: number;
  66230. /**
  66231. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66232. */
  66233. volumetricLightPower: number;
  66234. /**
  66235. * Used the set the blur intensity to smooth the volumetric lights
  66236. */
  66237. volumetricLightBlurScale: number;
  66238. /**
  66239. * Light (spot or directional) used to generate the volumetric lights rays
  66240. * The source light must have a shadow generate so the pipeline can get its
  66241. * depth map
  66242. */
  66243. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66244. /**
  66245. * For eye adaptation, represents the minimum luminance the eye can see
  66246. */
  66247. hdrMinimumLuminance: number;
  66248. /**
  66249. * For eye adaptation, represents the decrease luminance speed
  66250. */
  66251. hdrDecreaseRate: number;
  66252. /**
  66253. * For eye adaptation, represents the increase luminance speed
  66254. */
  66255. hdrIncreaseRate: number;
  66256. /**
  66257. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66258. */
  66259. get hdrAutoExposure(): boolean;
  66260. /**
  66261. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66262. */
  66263. set hdrAutoExposure(value: boolean);
  66264. /**
  66265. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66266. */
  66267. lensColorTexture: Nullable<Texture>;
  66268. /**
  66269. * The overall strengh for the lens flare effect
  66270. */
  66271. lensFlareStrength: number;
  66272. /**
  66273. * Dispersion coefficient for lens flare ghosts
  66274. */
  66275. lensFlareGhostDispersal: number;
  66276. /**
  66277. * Main lens flare halo width
  66278. */
  66279. lensFlareHaloWidth: number;
  66280. /**
  66281. * Based on the lens distortion effect, defines how much the lens flare result
  66282. * is distorted
  66283. */
  66284. lensFlareDistortionStrength: number;
  66285. /**
  66286. * Configures the blur intensity used for for lens flare (halo)
  66287. */
  66288. lensFlareBlurWidth: number;
  66289. /**
  66290. * Lens star texture must be used to simulate rays on the flares and is available
  66291. * in the documentation
  66292. */
  66293. lensStarTexture: Nullable<Texture>;
  66294. /**
  66295. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66296. * flare effect by taking account of the dirt texture
  66297. */
  66298. lensFlareDirtTexture: Nullable<Texture>;
  66299. /**
  66300. * Represents the focal length for the depth of field effect
  66301. */
  66302. depthOfFieldDistance: number;
  66303. /**
  66304. * Represents the blur intensity for the blurred part of the depth of field effect
  66305. */
  66306. depthOfFieldBlurWidth: number;
  66307. /**
  66308. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66309. */
  66310. get motionStrength(): number;
  66311. /**
  66312. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66313. */
  66314. set motionStrength(strength: number);
  66315. /**
  66316. * Gets wether or not the motion blur post-process is object based or screen based.
  66317. */
  66318. get objectBasedMotionBlur(): boolean;
  66319. /**
  66320. * Sets wether or not the motion blur post-process should be object based or screen based
  66321. */
  66322. set objectBasedMotionBlur(value: boolean);
  66323. /**
  66324. * List of animations for the pipeline (IAnimatable implementation)
  66325. */
  66326. animations: Animation[];
  66327. /**
  66328. * Private members
  66329. */
  66330. private _scene;
  66331. private _currentDepthOfFieldSource;
  66332. private _basePostProcess;
  66333. private _fixedExposure;
  66334. private _currentExposure;
  66335. private _hdrAutoExposure;
  66336. private _hdrCurrentLuminance;
  66337. private _motionStrength;
  66338. private _isObjectBasedMotionBlur;
  66339. private _floatTextureType;
  66340. private _camerasToBeAttached;
  66341. private _ratio;
  66342. private _bloomEnabled;
  66343. private _depthOfFieldEnabled;
  66344. private _vlsEnabled;
  66345. private _lensFlareEnabled;
  66346. private _hdrEnabled;
  66347. private _motionBlurEnabled;
  66348. private _fxaaEnabled;
  66349. private _screenSpaceReflectionsEnabled;
  66350. private _motionBlurSamples;
  66351. private _volumetricLightStepsCount;
  66352. private _samples;
  66353. /**
  66354. * @ignore
  66355. * Specifies if the bloom pipeline is enabled
  66356. */
  66357. get BloomEnabled(): boolean;
  66358. set BloomEnabled(enabled: boolean);
  66359. /**
  66360. * @ignore
  66361. * Specifies if the depth of field pipeline is enabed
  66362. */
  66363. get DepthOfFieldEnabled(): boolean;
  66364. set DepthOfFieldEnabled(enabled: boolean);
  66365. /**
  66366. * @ignore
  66367. * Specifies if the lens flare pipeline is enabed
  66368. */
  66369. get LensFlareEnabled(): boolean;
  66370. set LensFlareEnabled(enabled: boolean);
  66371. /**
  66372. * @ignore
  66373. * Specifies if the HDR pipeline is enabled
  66374. */
  66375. get HDREnabled(): boolean;
  66376. set HDREnabled(enabled: boolean);
  66377. /**
  66378. * @ignore
  66379. * Specifies if the volumetric lights scattering effect is enabled
  66380. */
  66381. get VLSEnabled(): boolean;
  66382. set VLSEnabled(enabled: boolean);
  66383. /**
  66384. * @ignore
  66385. * Specifies if the motion blur effect is enabled
  66386. */
  66387. get MotionBlurEnabled(): boolean;
  66388. set MotionBlurEnabled(enabled: boolean);
  66389. /**
  66390. * Specifies if anti-aliasing is enabled
  66391. */
  66392. get fxaaEnabled(): boolean;
  66393. set fxaaEnabled(enabled: boolean);
  66394. /**
  66395. * Specifies if screen space reflections are enabled.
  66396. */
  66397. get screenSpaceReflectionsEnabled(): boolean;
  66398. set screenSpaceReflectionsEnabled(enabled: boolean);
  66399. /**
  66400. * Specifies the number of steps used to calculate the volumetric lights
  66401. * Typically in interval [50, 200]
  66402. */
  66403. get volumetricLightStepsCount(): number;
  66404. set volumetricLightStepsCount(count: number);
  66405. /**
  66406. * Specifies the number of samples used for the motion blur effect
  66407. * Typically in interval [16, 64]
  66408. */
  66409. get motionBlurSamples(): number;
  66410. set motionBlurSamples(samples: number);
  66411. /**
  66412. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66413. */
  66414. get samples(): number;
  66415. set samples(sampleCount: number);
  66416. /**
  66417. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66418. * @constructor
  66419. * @param name The rendering pipeline name
  66420. * @param scene The scene linked to this pipeline
  66421. * @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)
  66422. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66423. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66424. */
  66425. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66426. private _buildPipeline;
  66427. private _createDownSampleX4PostProcess;
  66428. private _createBrightPassPostProcess;
  66429. private _createBlurPostProcesses;
  66430. private _createTextureAdderPostProcess;
  66431. private _createVolumetricLightPostProcess;
  66432. private _createLuminancePostProcesses;
  66433. private _createHdrPostProcess;
  66434. private _createLensFlarePostProcess;
  66435. private _createDepthOfFieldPostProcess;
  66436. private _createMotionBlurPostProcess;
  66437. private _getDepthTexture;
  66438. private _disposePostProcesses;
  66439. /**
  66440. * Dispose of the pipeline and stop all post processes
  66441. */
  66442. dispose(): void;
  66443. /**
  66444. * Serialize the rendering pipeline (Used when exporting)
  66445. * @returns the serialized object
  66446. */
  66447. serialize(): any;
  66448. /**
  66449. * Parse the serialized pipeline
  66450. * @param source Source pipeline.
  66451. * @param scene The scene to load the pipeline to.
  66452. * @param rootUrl The URL of the serialized pipeline.
  66453. * @returns An instantiated pipeline from the serialized object.
  66454. */
  66455. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66456. /**
  66457. * Luminance steps
  66458. */
  66459. static LuminanceSteps: number;
  66460. }
  66461. }
  66462. declare module BABYLON {
  66463. /** @hidden */
  66464. export var tonemapPixelShader: {
  66465. name: string;
  66466. shader: string;
  66467. };
  66468. }
  66469. declare module BABYLON {
  66470. /** Defines operator used for tonemapping */
  66471. export enum TonemappingOperator {
  66472. /** Hable */
  66473. Hable = 0,
  66474. /** Reinhard */
  66475. Reinhard = 1,
  66476. /** HejiDawson */
  66477. HejiDawson = 2,
  66478. /** Photographic */
  66479. Photographic = 3
  66480. }
  66481. /**
  66482. * Defines a post process to apply tone mapping
  66483. */
  66484. export class TonemapPostProcess extends PostProcess {
  66485. private _operator;
  66486. /** Defines the required exposure adjustement */
  66487. exposureAdjustment: number;
  66488. /**
  66489. * Creates a new TonemapPostProcess
  66490. * @param name defines the name of the postprocess
  66491. * @param _operator defines the operator to use
  66492. * @param exposureAdjustment defines the required exposure adjustement
  66493. * @param camera defines the camera to use (can be null)
  66494. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66495. * @param engine defines the hosting engine (can be ignore if camera is set)
  66496. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66497. */
  66498. constructor(name: string, _operator: TonemappingOperator,
  66499. /** Defines the required exposure adjustement */
  66500. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66501. }
  66502. }
  66503. declare module BABYLON {
  66504. /** @hidden */
  66505. export var volumetricLightScatteringPixelShader: {
  66506. name: string;
  66507. shader: string;
  66508. };
  66509. }
  66510. declare module BABYLON {
  66511. /** @hidden */
  66512. export var volumetricLightScatteringPassVertexShader: {
  66513. name: string;
  66514. shader: string;
  66515. };
  66516. }
  66517. declare module BABYLON {
  66518. /** @hidden */
  66519. export var volumetricLightScatteringPassPixelShader: {
  66520. name: string;
  66521. shader: string;
  66522. };
  66523. }
  66524. declare module BABYLON {
  66525. /**
  66526. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66527. */
  66528. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66529. private _volumetricLightScatteringPass;
  66530. private _volumetricLightScatteringRTT;
  66531. private _viewPort;
  66532. private _screenCoordinates;
  66533. private _cachedDefines;
  66534. /**
  66535. * If not undefined, the mesh position is computed from the attached node position
  66536. */
  66537. attachedNode: {
  66538. position: Vector3;
  66539. };
  66540. /**
  66541. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66542. */
  66543. customMeshPosition: Vector3;
  66544. /**
  66545. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66546. */
  66547. useCustomMeshPosition: boolean;
  66548. /**
  66549. * If the post-process should inverse the light scattering direction
  66550. */
  66551. invert: boolean;
  66552. /**
  66553. * The internal mesh used by the post-process
  66554. */
  66555. mesh: Mesh;
  66556. /**
  66557. * @hidden
  66558. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66559. */
  66560. get useDiffuseColor(): boolean;
  66561. set useDiffuseColor(useDiffuseColor: boolean);
  66562. /**
  66563. * Array containing the excluded meshes not rendered in the internal pass
  66564. */
  66565. excludedMeshes: AbstractMesh[];
  66566. /**
  66567. * Controls the overall intensity of the post-process
  66568. */
  66569. exposure: number;
  66570. /**
  66571. * Dissipates each sample's contribution in range [0, 1]
  66572. */
  66573. decay: number;
  66574. /**
  66575. * Controls the overall intensity of each sample
  66576. */
  66577. weight: number;
  66578. /**
  66579. * Controls the density of each sample
  66580. */
  66581. density: number;
  66582. /**
  66583. * @constructor
  66584. * @param name The post-process name
  66585. * @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)
  66586. * @param camera The camera that the post-process will be attached to
  66587. * @param mesh The mesh used to create the light scattering
  66588. * @param samples The post-process quality, default 100
  66589. * @param samplingModeThe post-process filtering mode
  66590. * @param engine The babylon engine
  66591. * @param reusable If the post-process is reusable
  66592. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66593. */
  66594. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66595. /**
  66596. * Returns the string "VolumetricLightScatteringPostProcess"
  66597. * @returns "VolumetricLightScatteringPostProcess"
  66598. */
  66599. getClassName(): string;
  66600. private _isReady;
  66601. /**
  66602. * Sets the new light position for light scattering effect
  66603. * @param position The new custom light position
  66604. */
  66605. setCustomMeshPosition(position: Vector3): void;
  66606. /**
  66607. * Returns the light position for light scattering effect
  66608. * @return Vector3 The custom light position
  66609. */
  66610. getCustomMeshPosition(): Vector3;
  66611. /**
  66612. * Disposes the internal assets and detaches the post-process from the camera
  66613. */
  66614. dispose(camera: Camera): void;
  66615. /**
  66616. * Returns the render target texture used by the post-process
  66617. * @return the render target texture used by the post-process
  66618. */
  66619. getPass(): RenderTargetTexture;
  66620. private _meshExcluded;
  66621. private _createPass;
  66622. private _updateMeshScreenCoordinates;
  66623. /**
  66624. * Creates a default mesh for the Volumeric Light Scattering post-process
  66625. * @param name The mesh name
  66626. * @param scene The scene where to create the mesh
  66627. * @return the default mesh
  66628. */
  66629. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66630. }
  66631. }
  66632. declare module BABYLON {
  66633. interface Scene {
  66634. /** @hidden (Backing field) */
  66635. _boundingBoxRenderer: BoundingBoxRenderer;
  66636. /** @hidden (Backing field) */
  66637. _forceShowBoundingBoxes: boolean;
  66638. /**
  66639. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66640. */
  66641. forceShowBoundingBoxes: boolean;
  66642. /**
  66643. * Gets the bounding box renderer associated with the scene
  66644. * @returns a BoundingBoxRenderer
  66645. */
  66646. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66647. }
  66648. interface AbstractMesh {
  66649. /** @hidden (Backing field) */
  66650. _showBoundingBox: boolean;
  66651. /**
  66652. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66653. */
  66654. showBoundingBox: boolean;
  66655. }
  66656. /**
  66657. * Component responsible of rendering the bounding box of the meshes in a scene.
  66658. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66659. */
  66660. export class BoundingBoxRenderer implements ISceneComponent {
  66661. /**
  66662. * The component name helpfull to identify the component in the list of scene components.
  66663. */
  66664. readonly name: string;
  66665. /**
  66666. * The scene the component belongs to.
  66667. */
  66668. scene: Scene;
  66669. /**
  66670. * Color of the bounding box lines placed in front of an object
  66671. */
  66672. frontColor: Color3;
  66673. /**
  66674. * Color of the bounding box lines placed behind an object
  66675. */
  66676. backColor: Color3;
  66677. /**
  66678. * Defines if the renderer should show the back lines or not
  66679. */
  66680. showBackLines: boolean;
  66681. /**
  66682. * @hidden
  66683. */
  66684. renderList: SmartArray<BoundingBox>;
  66685. private _colorShader;
  66686. private _vertexBuffers;
  66687. private _indexBuffer;
  66688. private _fillIndexBuffer;
  66689. private _fillIndexData;
  66690. /**
  66691. * Instantiates a new bounding box renderer in a scene.
  66692. * @param scene the scene the renderer renders in
  66693. */
  66694. constructor(scene: Scene);
  66695. /**
  66696. * Registers the component in a given scene
  66697. */
  66698. register(): void;
  66699. private _evaluateSubMesh;
  66700. private _activeMesh;
  66701. private _prepareRessources;
  66702. private _createIndexBuffer;
  66703. /**
  66704. * Rebuilds the elements related to this component in case of
  66705. * context lost for instance.
  66706. */
  66707. rebuild(): void;
  66708. /**
  66709. * @hidden
  66710. */
  66711. reset(): void;
  66712. /**
  66713. * Render the bounding boxes of a specific rendering group
  66714. * @param renderingGroupId defines the rendering group to render
  66715. */
  66716. render(renderingGroupId: number): void;
  66717. /**
  66718. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66719. * @param mesh Define the mesh to render the occlusion bounding box for
  66720. */
  66721. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66722. /**
  66723. * Dispose and release the resources attached to this renderer.
  66724. */
  66725. dispose(): void;
  66726. }
  66727. }
  66728. declare module BABYLON {
  66729. interface Scene {
  66730. /** @hidden (Backing field) */
  66731. _depthRenderer: {
  66732. [id: string]: DepthRenderer;
  66733. };
  66734. /**
  66735. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66736. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66737. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66738. * @returns the created depth renderer
  66739. */
  66740. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66741. /**
  66742. * Disables a depth renderer for a given camera
  66743. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66744. */
  66745. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66746. }
  66747. /**
  66748. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66749. * in several rendering techniques.
  66750. */
  66751. export class DepthRendererSceneComponent implements ISceneComponent {
  66752. /**
  66753. * The component name helpfull to identify the component in the list of scene components.
  66754. */
  66755. readonly name: string;
  66756. /**
  66757. * The scene the component belongs to.
  66758. */
  66759. scene: Scene;
  66760. /**
  66761. * Creates a new instance of the component for the given scene
  66762. * @param scene Defines the scene to register the component in
  66763. */
  66764. constructor(scene: Scene);
  66765. /**
  66766. * Registers the component in a given scene
  66767. */
  66768. register(): void;
  66769. /**
  66770. * Rebuilds the elements related to this component in case of
  66771. * context lost for instance.
  66772. */
  66773. rebuild(): void;
  66774. /**
  66775. * Disposes the component and the associated ressources
  66776. */
  66777. dispose(): void;
  66778. private _gatherRenderTargets;
  66779. private _gatherActiveCameraRenderTargets;
  66780. }
  66781. }
  66782. declare module BABYLON {
  66783. /** @hidden */
  66784. export var outlinePixelShader: {
  66785. name: string;
  66786. shader: string;
  66787. };
  66788. }
  66789. declare module BABYLON {
  66790. /** @hidden */
  66791. export var outlineVertexShader: {
  66792. name: string;
  66793. shader: string;
  66794. };
  66795. }
  66796. declare module BABYLON {
  66797. interface Scene {
  66798. /** @hidden */
  66799. _outlineRenderer: OutlineRenderer;
  66800. /**
  66801. * Gets the outline renderer associated with the scene
  66802. * @returns a OutlineRenderer
  66803. */
  66804. getOutlineRenderer(): OutlineRenderer;
  66805. }
  66806. interface AbstractMesh {
  66807. /** @hidden (Backing field) */
  66808. _renderOutline: boolean;
  66809. /**
  66810. * Gets or sets a boolean indicating if the outline must be rendered as well
  66811. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66812. */
  66813. renderOutline: boolean;
  66814. /** @hidden (Backing field) */
  66815. _renderOverlay: boolean;
  66816. /**
  66817. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66818. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66819. */
  66820. renderOverlay: boolean;
  66821. }
  66822. /**
  66823. * This class is responsible to draw bothe outline/overlay of meshes.
  66824. * It should not be used directly but through the available method on mesh.
  66825. */
  66826. export class OutlineRenderer implements ISceneComponent {
  66827. /**
  66828. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66829. */
  66830. private static _StencilReference;
  66831. /**
  66832. * The name of the component. Each component must have a unique name.
  66833. */
  66834. name: string;
  66835. /**
  66836. * The scene the component belongs to.
  66837. */
  66838. scene: Scene;
  66839. /**
  66840. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66841. */
  66842. zOffset: number;
  66843. private _engine;
  66844. private _effect;
  66845. private _cachedDefines;
  66846. private _savedDepthWrite;
  66847. /**
  66848. * Instantiates a new outline renderer. (There could be only one per scene).
  66849. * @param scene Defines the scene it belongs to
  66850. */
  66851. constructor(scene: Scene);
  66852. /**
  66853. * Register the component to one instance of a scene.
  66854. */
  66855. register(): void;
  66856. /**
  66857. * Rebuilds the elements related to this component in case of
  66858. * context lost for instance.
  66859. */
  66860. rebuild(): void;
  66861. /**
  66862. * Disposes the component and the associated ressources.
  66863. */
  66864. dispose(): void;
  66865. /**
  66866. * Renders the outline in the canvas.
  66867. * @param subMesh Defines the sumesh to render
  66868. * @param batch Defines the batch of meshes in case of instances
  66869. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66870. */
  66871. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66872. /**
  66873. * Returns whether or not the outline renderer is ready for a given submesh.
  66874. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66875. * @param subMesh Defines the submesh to check readyness for
  66876. * @param useInstances Defines wheter wee are trying to render instances or not
  66877. * @returns true if ready otherwise false
  66878. */
  66879. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66880. private _beforeRenderingMesh;
  66881. private _afterRenderingMesh;
  66882. }
  66883. }
  66884. declare module BABYLON {
  66885. /**
  66886. * Defines the basic options interface of a Sprite Frame Source Size.
  66887. */
  66888. export interface ISpriteJSONSpriteSourceSize {
  66889. /**
  66890. * number of the original width of the Frame
  66891. */
  66892. w: number;
  66893. /**
  66894. * number of the original height of the Frame
  66895. */
  66896. h: number;
  66897. }
  66898. /**
  66899. * Defines the basic options interface of a Sprite Frame Data.
  66900. */
  66901. export interface ISpriteJSONSpriteFrameData {
  66902. /**
  66903. * number of the x offset of the Frame
  66904. */
  66905. x: number;
  66906. /**
  66907. * number of the y offset of the Frame
  66908. */
  66909. y: number;
  66910. /**
  66911. * number of the width of the Frame
  66912. */
  66913. w: number;
  66914. /**
  66915. * number of the height of the Frame
  66916. */
  66917. h: number;
  66918. }
  66919. /**
  66920. * Defines the basic options interface of a JSON Sprite.
  66921. */
  66922. export interface ISpriteJSONSprite {
  66923. /**
  66924. * string name of the Frame
  66925. */
  66926. filename: string;
  66927. /**
  66928. * ISpriteJSONSpriteFrame basic object of the frame data
  66929. */
  66930. frame: ISpriteJSONSpriteFrameData;
  66931. /**
  66932. * boolean to flag is the frame was rotated.
  66933. */
  66934. rotated: boolean;
  66935. /**
  66936. * boolean to flag is the frame was trimmed.
  66937. */
  66938. trimmed: boolean;
  66939. /**
  66940. * ISpriteJSONSpriteFrame basic object of the source data
  66941. */
  66942. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66943. /**
  66944. * ISpriteJSONSpriteFrame basic object of the source data
  66945. */
  66946. sourceSize: ISpriteJSONSpriteSourceSize;
  66947. }
  66948. /**
  66949. * Defines the basic options interface of a JSON atlas.
  66950. */
  66951. export interface ISpriteJSONAtlas {
  66952. /**
  66953. * Array of objects that contain the frame data.
  66954. */
  66955. frames: Array<ISpriteJSONSprite>;
  66956. /**
  66957. * object basic object containing the sprite meta data.
  66958. */
  66959. meta?: object;
  66960. }
  66961. }
  66962. declare module BABYLON {
  66963. /** @hidden */
  66964. export var spriteMapPixelShader: {
  66965. name: string;
  66966. shader: string;
  66967. };
  66968. }
  66969. declare module BABYLON {
  66970. /** @hidden */
  66971. export var spriteMapVertexShader: {
  66972. name: string;
  66973. shader: string;
  66974. };
  66975. }
  66976. declare module BABYLON {
  66977. /**
  66978. * Defines the basic options interface of a SpriteMap
  66979. */
  66980. export interface ISpriteMapOptions {
  66981. /**
  66982. * Vector2 of the number of cells in the grid.
  66983. */
  66984. stageSize?: Vector2;
  66985. /**
  66986. * Vector2 of the size of the output plane in World Units.
  66987. */
  66988. outputSize?: Vector2;
  66989. /**
  66990. * Vector3 of the position of the output plane in World Units.
  66991. */
  66992. outputPosition?: Vector3;
  66993. /**
  66994. * Vector3 of the rotation of the output plane.
  66995. */
  66996. outputRotation?: Vector3;
  66997. /**
  66998. * number of layers that the system will reserve in resources.
  66999. */
  67000. layerCount?: number;
  67001. /**
  67002. * number of max animation frames a single cell will reserve in resources.
  67003. */
  67004. maxAnimationFrames?: number;
  67005. /**
  67006. * number cell index of the base tile when the system compiles.
  67007. */
  67008. baseTile?: number;
  67009. /**
  67010. * boolean flip the sprite after its been repositioned by the framing data.
  67011. */
  67012. flipU?: boolean;
  67013. /**
  67014. * Vector3 scalar of the global RGB values of the SpriteMap.
  67015. */
  67016. colorMultiply?: Vector3;
  67017. }
  67018. /**
  67019. * Defines the IDisposable interface in order to be cleanable from resources.
  67020. */
  67021. export interface ISpriteMap extends IDisposable {
  67022. /**
  67023. * String name of the SpriteMap.
  67024. */
  67025. name: string;
  67026. /**
  67027. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67028. */
  67029. atlasJSON: ISpriteJSONAtlas;
  67030. /**
  67031. * Texture of the SpriteMap.
  67032. */
  67033. spriteSheet: Texture;
  67034. /**
  67035. * The parameters to initialize the SpriteMap with.
  67036. */
  67037. options: ISpriteMapOptions;
  67038. }
  67039. /**
  67040. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67041. */
  67042. export class SpriteMap implements ISpriteMap {
  67043. /** The Name of the spriteMap */
  67044. name: string;
  67045. /** The JSON file with the frame and meta data */
  67046. atlasJSON: ISpriteJSONAtlas;
  67047. /** The systems Sprite Sheet Texture */
  67048. spriteSheet: Texture;
  67049. /** Arguments passed with the Constructor */
  67050. options: ISpriteMapOptions;
  67051. /** Public Sprite Storage array, parsed from atlasJSON */
  67052. sprites: Array<ISpriteJSONSprite>;
  67053. /** Returns the Number of Sprites in the System */
  67054. get spriteCount(): number;
  67055. /** Returns the Position of Output Plane*/
  67056. get position(): Vector3;
  67057. /** Returns the Position of Output Plane*/
  67058. set position(v: Vector3);
  67059. /** Returns the Rotation of Output Plane*/
  67060. get rotation(): Vector3;
  67061. /** Returns the Rotation of Output Plane*/
  67062. set rotation(v: Vector3);
  67063. /** Sets the AnimationMap*/
  67064. get animationMap(): RawTexture;
  67065. /** Sets the AnimationMap*/
  67066. set animationMap(v: RawTexture);
  67067. /** Scene that the SpriteMap was created in */
  67068. private _scene;
  67069. /** Texture Buffer of Float32 that holds tile frame data*/
  67070. private _frameMap;
  67071. /** Texture Buffers of Float32 that holds tileMap data*/
  67072. private _tileMaps;
  67073. /** Texture Buffer of Float32 that holds Animation Data*/
  67074. private _animationMap;
  67075. /** Custom ShaderMaterial Central to the System*/
  67076. private _material;
  67077. /** Custom ShaderMaterial Central to the System*/
  67078. private _output;
  67079. /** Systems Time Ticker*/
  67080. private _time;
  67081. /**
  67082. * Creates a new SpriteMap
  67083. * @param name defines the SpriteMaps Name
  67084. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67085. * @param spriteSheet is the Texture that the Sprites are on.
  67086. * @param options a basic deployment configuration
  67087. * @param scene The Scene that the map is deployed on
  67088. */
  67089. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67090. /**
  67091. * Returns tileID location
  67092. * @returns Vector2 the cell position ID
  67093. */
  67094. getTileID(): Vector2;
  67095. /**
  67096. * Gets the UV location of the mouse over the SpriteMap.
  67097. * @returns Vector2 the UV position of the mouse interaction
  67098. */
  67099. getMousePosition(): Vector2;
  67100. /**
  67101. * Creates the "frame" texture Buffer
  67102. * -------------------------------------
  67103. * Structure of frames
  67104. * "filename": "Falling-Water-2.png",
  67105. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67106. * "rotated": true,
  67107. * "trimmed": true,
  67108. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67109. * "sourceSize": {"w":32,"h":32}
  67110. * @returns RawTexture of the frameMap
  67111. */
  67112. private _createFrameBuffer;
  67113. /**
  67114. * Creates the tileMap texture Buffer
  67115. * @param buffer normally and array of numbers, or a false to generate from scratch
  67116. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67117. * @returns RawTexture of the tileMap
  67118. */
  67119. private _createTileBuffer;
  67120. /**
  67121. * Modifies the data of the tileMaps
  67122. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67123. * @param pos is the iVector2 Coordinates of the Tile
  67124. * @param tile The SpriteIndex of the new Tile
  67125. */
  67126. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67127. /**
  67128. * Creates the animationMap texture Buffer
  67129. * @param buffer normally and array of numbers, or a false to generate from scratch
  67130. * @returns RawTexture of the animationMap
  67131. */
  67132. private _createTileAnimationBuffer;
  67133. /**
  67134. * Modifies the data of the animationMap
  67135. * @param cellID is the Index of the Sprite
  67136. * @param _frame is the target Animation frame
  67137. * @param toCell is the Target Index of the next frame of the animation
  67138. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67139. * @param speed is a global scalar of the time variable on the map.
  67140. */
  67141. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67142. /**
  67143. * Exports the .tilemaps file
  67144. */
  67145. saveTileMaps(): void;
  67146. /**
  67147. * Imports the .tilemaps file
  67148. * @param url of the .tilemaps file
  67149. */
  67150. loadTileMaps(url: string): void;
  67151. /**
  67152. * Release associated resources
  67153. */
  67154. dispose(): void;
  67155. }
  67156. }
  67157. declare module BABYLON {
  67158. /**
  67159. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67160. * @see http://doc.babylonjs.com/babylon101/sprites
  67161. */
  67162. export class SpritePackedManager extends SpriteManager {
  67163. /** defines the packed manager's name */
  67164. name: string;
  67165. /**
  67166. * Creates a new sprite manager from a packed sprite sheet
  67167. * @param name defines the manager's name
  67168. * @param imgUrl defines the sprite sheet url
  67169. * @param capacity defines the maximum allowed number of sprites
  67170. * @param scene defines the hosting scene
  67171. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67172. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67173. * @param samplingMode defines the smapling mode to use with spritesheet
  67174. * @param fromPacked set to true; do not alter
  67175. */
  67176. constructor(
  67177. /** defines the packed manager's name */
  67178. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67179. }
  67180. }
  67181. declare module BABYLON {
  67182. /**
  67183. * Defines the list of states available for a task inside a AssetsManager
  67184. */
  67185. export enum AssetTaskState {
  67186. /**
  67187. * Initialization
  67188. */
  67189. INIT = 0,
  67190. /**
  67191. * Running
  67192. */
  67193. RUNNING = 1,
  67194. /**
  67195. * Done
  67196. */
  67197. DONE = 2,
  67198. /**
  67199. * Error
  67200. */
  67201. ERROR = 3
  67202. }
  67203. /**
  67204. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67205. */
  67206. export abstract class AbstractAssetTask {
  67207. /**
  67208. * Task name
  67209. */ name: string;
  67210. /**
  67211. * Callback called when the task is successful
  67212. */
  67213. onSuccess: (task: any) => void;
  67214. /**
  67215. * Callback called when the task is not successful
  67216. */
  67217. onError: (task: any, message?: string, exception?: any) => void;
  67218. /**
  67219. * Creates a new AssetsManager
  67220. * @param name defines the name of the task
  67221. */
  67222. constructor(
  67223. /**
  67224. * Task name
  67225. */ name: string);
  67226. private _isCompleted;
  67227. private _taskState;
  67228. private _errorObject;
  67229. /**
  67230. * Get if the task is completed
  67231. */
  67232. get isCompleted(): boolean;
  67233. /**
  67234. * Gets the current state of the task
  67235. */
  67236. get taskState(): AssetTaskState;
  67237. /**
  67238. * Gets the current error object (if task is in error)
  67239. */
  67240. get errorObject(): {
  67241. message?: string;
  67242. exception?: any;
  67243. };
  67244. /**
  67245. * Internal only
  67246. * @hidden
  67247. */
  67248. _setErrorObject(message?: string, exception?: any): void;
  67249. /**
  67250. * Execute the current task
  67251. * @param scene defines the scene where you want your assets to be loaded
  67252. * @param onSuccess is a callback called when the task is successfully executed
  67253. * @param onError is a callback called if an error occurs
  67254. */
  67255. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67256. /**
  67257. * Execute the current task
  67258. * @param scene defines the scene where you want your assets to be loaded
  67259. * @param onSuccess is a callback called when the task is successfully executed
  67260. * @param onError is a callback called if an error occurs
  67261. */
  67262. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67263. /**
  67264. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67265. * This can be used with failed tasks that have the reason for failure fixed.
  67266. */
  67267. reset(): void;
  67268. private onErrorCallback;
  67269. private onDoneCallback;
  67270. }
  67271. /**
  67272. * Define the interface used by progress events raised during assets loading
  67273. */
  67274. export interface IAssetsProgressEvent {
  67275. /**
  67276. * Defines the number of remaining tasks to process
  67277. */
  67278. remainingCount: number;
  67279. /**
  67280. * Defines the total number of tasks
  67281. */
  67282. totalCount: number;
  67283. /**
  67284. * Defines the task that was just processed
  67285. */
  67286. task: AbstractAssetTask;
  67287. }
  67288. /**
  67289. * Class used to share progress information about assets loading
  67290. */
  67291. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67292. /**
  67293. * Defines the number of remaining tasks to process
  67294. */
  67295. remainingCount: number;
  67296. /**
  67297. * Defines the total number of tasks
  67298. */
  67299. totalCount: number;
  67300. /**
  67301. * Defines the task that was just processed
  67302. */
  67303. task: AbstractAssetTask;
  67304. /**
  67305. * Creates a AssetsProgressEvent
  67306. * @param remainingCount defines the number of remaining tasks to process
  67307. * @param totalCount defines the total number of tasks
  67308. * @param task defines the task that was just processed
  67309. */
  67310. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67311. }
  67312. /**
  67313. * Define a task used by AssetsManager to load meshes
  67314. */
  67315. export class MeshAssetTask extends AbstractAssetTask {
  67316. /**
  67317. * Defines the name of the task
  67318. */
  67319. name: string;
  67320. /**
  67321. * Defines the list of mesh's names you want to load
  67322. */
  67323. meshesNames: any;
  67324. /**
  67325. * Defines the root url to use as a base to load your meshes and associated resources
  67326. */
  67327. rootUrl: string;
  67328. /**
  67329. * Defines the filename of the scene to load from
  67330. */
  67331. sceneFilename: string;
  67332. /**
  67333. * Gets the list of loaded meshes
  67334. */
  67335. loadedMeshes: Array<AbstractMesh>;
  67336. /**
  67337. * Gets the list of loaded particle systems
  67338. */
  67339. loadedParticleSystems: Array<IParticleSystem>;
  67340. /**
  67341. * Gets the list of loaded skeletons
  67342. */
  67343. loadedSkeletons: Array<Skeleton>;
  67344. /**
  67345. * Gets the list of loaded animation groups
  67346. */
  67347. loadedAnimationGroups: Array<AnimationGroup>;
  67348. /**
  67349. * Callback called when the task is successful
  67350. */
  67351. onSuccess: (task: MeshAssetTask) => void;
  67352. /**
  67353. * Callback called when the task is successful
  67354. */
  67355. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67356. /**
  67357. * Creates a new MeshAssetTask
  67358. * @param name defines the name of the task
  67359. * @param meshesNames defines the list of mesh's names you want to load
  67360. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67361. * @param sceneFilename defines the filename of the scene to load from
  67362. */
  67363. constructor(
  67364. /**
  67365. * Defines the name of the task
  67366. */
  67367. name: string,
  67368. /**
  67369. * Defines the list of mesh's names you want to load
  67370. */
  67371. meshesNames: any,
  67372. /**
  67373. * Defines the root url to use as a base to load your meshes and associated resources
  67374. */
  67375. rootUrl: string,
  67376. /**
  67377. * Defines the filename of the scene to load from
  67378. */
  67379. sceneFilename: string);
  67380. /**
  67381. * Execute the current task
  67382. * @param scene defines the scene where you want your assets to be loaded
  67383. * @param onSuccess is a callback called when the task is successfully executed
  67384. * @param onError is a callback called if an error occurs
  67385. */
  67386. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67387. }
  67388. /**
  67389. * Define a task used by AssetsManager to load text content
  67390. */
  67391. export class TextFileAssetTask extends AbstractAssetTask {
  67392. /**
  67393. * Defines the name of the task
  67394. */
  67395. name: string;
  67396. /**
  67397. * Defines the location of the file to load
  67398. */
  67399. url: string;
  67400. /**
  67401. * Gets the loaded text string
  67402. */
  67403. text: string;
  67404. /**
  67405. * Callback called when the task is successful
  67406. */
  67407. onSuccess: (task: TextFileAssetTask) => void;
  67408. /**
  67409. * Callback called when the task is successful
  67410. */
  67411. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67412. /**
  67413. * Creates a new TextFileAssetTask object
  67414. * @param name defines the name of the task
  67415. * @param url defines the location of the file to load
  67416. */
  67417. constructor(
  67418. /**
  67419. * Defines the name of the task
  67420. */
  67421. name: string,
  67422. /**
  67423. * Defines the location of the file to load
  67424. */
  67425. url: string);
  67426. /**
  67427. * Execute the current task
  67428. * @param scene defines the scene where you want your assets to be loaded
  67429. * @param onSuccess is a callback called when the task is successfully executed
  67430. * @param onError is a callback called if an error occurs
  67431. */
  67432. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67433. }
  67434. /**
  67435. * Define a task used by AssetsManager to load binary data
  67436. */
  67437. export class BinaryFileAssetTask extends AbstractAssetTask {
  67438. /**
  67439. * Defines the name of the task
  67440. */
  67441. name: string;
  67442. /**
  67443. * Defines the location of the file to load
  67444. */
  67445. url: string;
  67446. /**
  67447. * Gets the lodaded data (as an array buffer)
  67448. */
  67449. data: ArrayBuffer;
  67450. /**
  67451. * Callback called when the task is successful
  67452. */
  67453. onSuccess: (task: BinaryFileAssetTask) => void;
  67454. /**
  67455. * Callback called when the task is successful
  67456. */
  67457. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67458. /**
  67459. * Creates a new BinaryFileAssetTask object
  67460. * @param name defines the name of the new task
  67461. * @param url defines the location of the file to load
  67462. */
  67463. constructor(
  67464. /**
  67465. * Defines the name of the task
  67466. */
  67467. name: string,
  67468. /**
  67469. * Defines the location of the file to load
  67470. */
  67471. url: string);
  67472. /**
  67473. * Execute the current task
  67474. * @param scene defines the scene where you want your assets to be loaded
  67475. * @param onSuccess is a callback called when the task is successfully executed
  67476. * @param onError is a callback called if an error occurs
  67477. */
  67478. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67479. }
  67480. /**
  67481. * Define a task used by AssetsManager to load images
  67482. */
  67483. export class ImageAssetTask extends AbstractAssetTask {
  67484. /**
  67485. * Defines the name of the task
  67486. */
  67487. name: string;
  67488. /**
  67489. * Defines the location of the image to load
  67490. */
  67491. url: string;
  67492. /**
  67493. * Gets the loaded images
  67494. */
  67495. image: HTMLImageElement;
  67496. /**
  67497. * Callback called when the task is successful
  67498. */
  67499. onSuccess: (task: ImageAssetTask) => void;
  67500. /**
  67501. * Callback called when the task is successful
  67502. */
  67503. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67504. /**
  67505. * Creates a new ImageAssetTask
  67506. * @param name defines the name of the task
  67507. * @param url defines the location of the image to load
  67508. */
  67509. constructor(
  67510. /**
  67511. * Defines the name of the task
  67512. */
  67513. name: string,
  67514. /**
  67515. * Defines the location of the image to load
  67516. */
  67517. url: string);
  67518. /**
  67519. * Execute the current task
  67520. * @param scene defines the scene where you want your assets to be loaded
  67521. * @param onSuccess is a callback called when the task is successfully executed
  67522. * @param onError is a callback called if an error occurs
  67523. */
  67524. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67525. }
  67526. /**
  67527. * Defines the interface used by texture loading tasks
  67528. */
  67529. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67530. /**
  67531. * Gets the loaded texture
  67532. */
  67533. texture: TEX;
  67534. }
  67535. /**
  67536. * Define a task used by AssetsManager to load 2D textures
  67537. */
  67538. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67539. /**
  67540. * Defines the name of the task
  67541. */
  67542. name: string;
  67543. /**
  67544. * Defines the location of the file to load
  67545. */
  67546. url: string;
  67547. /**
  67548. * Defines if mipmap should not be generated (default is false)
  67549. */
  67550. noMipmap?: boolean | undefined;
  67551. /**
  67552. * Defines if texture must be inverted on Y axis (default is false)
  67553. */
  67554. invertY?: boolean | undefined;
  67555. /**
  67556. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67557. */
  67558. samplingMode: number;
  67559. /**
  67560. * Gets the loaded texture
  67561. */
  67562. texture: Texture;
  67563. /**
  67564. * Callback called when the task is successful
  67565. */
  67566. onSuccess: (task: TextureAssetTask) => void;
  67567. /**
  67568. * Callback called when the task is successful
  67569. */
  67570. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67571. /**
  67572. * Creates a new TextureAssetTask object
  67573. * @param name defines the name of the task
  67574. * @param url defines the location of the file to load
  67575. * @param noMipmap defines if mipmap should not be generated (default is false)
  67576. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67577. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67578. */
  67579. constructor(
  67580. /**
  67581. * Defines the name of the task
  67582. */
  67583. name: string,
  67584. /**
  67585. * Defines the location of the file to load
  67586. */
  67587. url: string,
  67588. /**
  67589. * Defines if mipmap should not be generated (default is false)
  67590. */
  67591. noMipmap?: boolean | undefined,
  67592. /**
  67593. * Defines if texture must be inverted on Y axis (default is false)
  67594. */
  67595. invertY?: boolean | undefined,
  67596. /**
  67597. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67598. */
  67599. samplingMode?: number);
  67600. /**
  67601. * Execute the current task
  67602. * @param scene defines the scene where you want your assets to be loaded
  67603. * @param onSuccess is a callback called when the task is successfully executed
  67604. * @param onError is a callback called if an error occurs
  67605. */
  67606. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67607. }
  67608. /**
  67609. * Define a task used by AssetsManager to load cube textures
  67610. */
  67611. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67612. /**
  67613. * Defines the name of the task
  67614. */
  67615. name: string;
  67616. /**
  67617. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67618. */
  67619. url: string;
  67620. /**
  67621. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67622. */
  67623. extensions?: string[] | undefined;
  67624. /**
  67625. * Defines if mipmaps should not be generated (default is false)
  67626. */
  67627. noMipmap?: boolean | undefined;
  67628. /**
  67629. * Defines the explicit list of files (undefined by default)
  67630. */
  67631. files?: string[] | undefined;
  67632. /**
  67633. * Gets the loaded texture
  67634. */
  67635. texture: CubeTexture;
  67636. /**
  67637. * Callback called when the task is successful
  67638. */
  67639. onSuccess: (task: CubeTextureAssetTask) => void;
  67640. /**
  67641. * Callback called when the task is successful
  67642. */
  67643. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67644. /**
  67645. * Creates a new CubeTextureAssetTask
  67646. * @param name defines the name of the task
  67647. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67648. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67649. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67650. * @param files defines the explicit list of files (undefined by default)
  67651. */
  67652. constructor(
  67653. /**
  67654. * Defines the name of the task
  67655. */
  67656. name: string,
  67657. /**
  67658. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67659. */
  67660. url: string,
  67661. /**
  67662. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67663. */
  67664. extensions?: string[] | undefined,
  67665. /**
  67666. * Defines if mipmaps should not be generated (default is false)
  67667. */
  67668. noMipmap?: boolean | undefined,
  67669. /**
  67670. * Defines the explicit list of files (undefined by default)
  67671. */
  67672. files?: string[] | undefined);
  67673. /**
  67674. * Execute the current task
  67675. * @param scene defines the scene where you want your assets to be loaded
  67676. * @param onSuccess is a callback called when the task is successfully executed
  67677. * @param onError is a callback called if an error occurs
  67678. */
  67679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67680. }
  67681. /**
  67682. * Define a task used by AssetsManager to load HDR cube textures
  67683. */
  67684. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67685. /**
  67686. * Defines the name of the task
  67687. */
  67688. name: string;
  67689. /**
  67690. * Defines the location of the file to load
  67691. */
  67692. url: string;
  67693. /**
  67694. * Defines the desired size (the more it increases the longer the generation will be)
  67695. */
  67696. size: number;
  67697. /**
  67698. * Defines if mipmaps should not be generated (default is false)
  67699. */
  67700. noMipmap: boolean;
  67701. /**
  67702. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67703. */
  67704. generateHarmonics: boolean;
  67705. /**
  67706. * 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)
  67707. */
  67708. gammaSpace: boolean;
  67709. /**
  67710. * Internal Use Only
  67711. */
  67712. reserved: boolean;
  67713. /**
  67714. * Gets the loaded texture
  67715. */
  67716. texture: HDRCubeTexture;
  67717. /**
  67718. * Callback called when the task is successful
  67719. */
  67720. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67721. /**
  67722. * Callback called when the task is successful
  67723. */
  67724. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67725. /**
  67726. * Creates a new HDRCubeTextureAssetTask object
  67727. * @param name defines the name of the task
  67728. * @param url defines the location of the file to load
  67729. * @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.
  67730. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67731. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67732. * @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)
  67733. * @param reserved Internal use only
  67734. */
  67735. constructor(
  67736. /**
  67737. * Defines the name of the task
  67738. */
  67739. name: string,
  67740. /**
  67741. * Defines the location of the file to load
  67742. */
  67743. url: string,
  67744. /**
  67745. * Defines the desired size (the more it increases the longer the generation will be)
  67746. */
  67747. size: number,
  67748. /**
  67749. * Defines if mipmaps should not be generated (default is false)
  67750. */
  67751. noMipmap?: boolean,
  67752. /**
  67753. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67754. */
  67755. generateHarmonics?: boolean,
  67756. /**
  67757. * 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)
  67758. */
  67759. gammaSpace?: boolean,
  67760. /**
  67761. * Internal Use Only
  67762. */
  67763. reserved?: boolean);
  67764. /**
  67765. * Execute the current task
  67766. * @param scene defines the scene where you want your assets to be loaded
  67767. * @param onSuccess is a callback called when the task is successfully executed
  67768. * @param onError is a callback called if an error occurs
  67769. */
  67770. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67771. }
  67772. /**
  67773. * Define a task used by AssetsManager to load Equirectangular cube textures
  67774. */
  67775. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67776. /**
  67777. * Defines the name of the task
  67778. */
  67779. name: string;
  67780. /**
  67781. * Defines the location of the file to load
  67782. */
  67783. url: string;
  67784. /**
  67785. * Defines the desired size (the more it increases the longer the generation will be)
  67786. */
  67787. size: number;
  67788. /**
  67789. * Defines if mipmaps should not be generated (default is false)
  67790. */
  67791. noMipmap: boolean;
  67792. /**
  67793. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67794. * but the standard material would require them in Gamma space) (default is true)
  67795. */
  67796. gammaSpace: boolean;
  67797. /**
  67798. * Gets the loaded texture
  67799. */
  67800. texture: EquiRectangularCubeTexture;
  67801. /**
  67802. * Callback called when the task is successful
  67803. */
  67804. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67805. /**
  67806. * Callback called when the task is successful
  67807. */
  67808. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67809. /**
  67810. * Creates a new EquiRectangularCubeTextureAssetTask object
  67811. * @param name defines the name of the task
  67812. * @param url defines the location of the file to load
  67813. * @param size defines the desired size (the more it increases the longer the generation will be)
  67814. * If the size is omitted this implies you are using a preprocessed cubemap.
  67815. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67816. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67817. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67818. * (default is true)
  67819. */
  67820. constructor(
  67821. /**
  67822. * Defines the name of the task
  67823. */
  67824. name: string,
  67825. /**
  67826. * Defines the location of the file to load
  67827. */
  67828. url: string,
  67829. /**
  67830. * Defines the desired size (the more it increases the longer the generation will be)
  67831. */
  67832. size: number,
  67833. /**
  67834. * Defines if mipmaps should not be generated (default is false)
  67835. */
  67836. noMipmap?: boolean,
  67837. /**
  67838. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67839. * but the standard material would require them in Gamma space) (default is true)
  67840. */
  67841. gammaSpace?: boolean);
  67842. /**
  67843. * Execute the current task
  67844. * @param scene defines the scene where you want your assets to be loaded
  67845. * @param onSuccess is a callback called when the task is successfully executed
  67846. * @param onError is a callback called if an error occurs
  67847. */
  67848. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67849. }
  67850. /**
  67851. * This class can be used to easily import assets into a scene
  67852. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67853. */
  67854. export class AssetsManager {
  67855. private _scene;
  67856. private _isLoading;
  67857. protected _tasks: AbstractAssetTask[];
  67858. protected _waitingTasksCount: number;
  67859. protected _totalTasksCount: number;
  67860. /**
  67861. * Callback called when all tasks are processed
  67862. */
  67863. onFinish: (tasks: AbstractAssetTask[]) => void;
  67864. /**
  67865. * Callback called when a task is successful
  67866. */
  67867. onTaskSuccess: (task: AbstractAssetTask) => void;
  67868. /**
  67869. * Callback called when a task had an error
  67870. */
  67871. onTaskError: (task: AbstractAssetTask) => void;
  67872. /**
  67873. * Callback called when a task is done (whatever the result is)
  67874. */
  67875. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67876. /**
  67877. * Observable called when all tasks are processed
  67878. */
  67879. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67880. /**
  67881. * Observable called when a task had an error
  67882. */
  67883. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67884. /**
  67885. * Observable called when all tasks were executed
  67886. */
  67887. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67888. /**
  67889. * Observable called when a task is done (whatever the result is)
  67890. */
  67891. onProgressObservable: Observable<IAssetsProgressEvent>;
  67892. /**
  67893. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67894. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67895. */
  67896. useDefaultLoadingScreen: boolean;
  67897. /**
  67898. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67899. * when all assets have been downloaded.
  67900. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67901. */
  67902. autoHideLoadingUI: boolean;
  67903. /**
  67904. * Creates a new AssetsManager
  67905. * @param scene defines the scene to work on
  67906. */
  67907. constructor(scene: Scene);
  67908. /**
  67909. * Add a MeshAssetTask to the list of active tasks
  67910. * @param taskName defines the name of the new task
  67911. * @param meshesNames defines the name of meshes to load
  67912. * @param rootUrl defines the root url to use to locate files
  67913. * @param sceneFilename defines the filename of the scene file
  67914. * @returns a new MeshAssetTask object
  67915. */
  67916. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67917. /**
  67918. * Add a TextFileAssetTask to the list of active tasks
  67919. * @param taskName defines the name of the new task
  67920. * @param url defines the url of the file to load
  67921. * @returns a new TextFileAssetTask object
  67922. */
  67923. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67924. /**
  67925. * Add a BinaryFileAssetTask to the list of active tasks
  67926. * @param taskName defines the name of the new task
  67927. * @param url defines the url of the file to load
  67928. * @returns a new BinaryFileAssetTask object
  67929. */
  67930. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67931. /**
  67932. * Add a ImageAssetTask to the list of active tasks
  67933. * @param taskName defines the name of the new task
  67934. * @param url defines the url of the file to load
  67935. * @returns a new ImageAssetTask object
  67936. */
  67937. addImageTask(taskName: string, url: string): ImageAssetTask;
  67938. /**
  67939. * Add a TextureAssetTask to the list of active tasks
  67940. * @param taskName defines the name of the new task
  67941. * @param url defines the url of the file to load
  67942. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67943. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67944. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67945. * @returns a new TextureAssetTask object
  67946. */
  67947. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67948. /**
  67949. * Add a CubeTextureAssetTask to the list of active tasks
  67950. * @param taskName defines the name of the new task
  67951. * @param url defines the url of the file to load
  67952. * @param extensions defines the extension to use to load the cube map (can be null)
  67953. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67954. * @param files defines the list of files to load (can be null)
  67955. * @returns a new CubeTextureAssetTask object
  67956. */
  67957. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67958. /**
  67959. *
  67960. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67961. * @param taskName defines the name of the new task
  67962. * @param url defines the url of the file to load
  67963. * @param size defines the size you want for the cubemap (can be null)
  67964. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67965. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67966. * @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)
  67967. * @param reserved Internal use only
  67968. * @returns a new HDRCubeTextureAssetTask object
  67969. */
  67970. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67971. /**
  67972. *
  67973. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67974. * @param taskName defines the name of the new task
  67975. * @param url defines the url of the file to load
  67976. * @param size defines the size you want for the cubemap (can be null)
  67977. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67978. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67979. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67980. * @returns a new EquiRectangularCubeTextureAssetTask object
  67981. */
  67982. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67983. /**
  67984. * Remove a task from the assets manager.
  67985. * @param task the task to remove
  67986. */
  67987. removeTask(task: AbstractAssetTask): void;
  67988. private _decreaseWaitingTasksCount;
  67989. private _runTask;
  67990. /**
  67991. * Reset the AssetsManager and remove all tasks
  67992. * @return the current instance of the AssetsManager
  67993. */
  67994. reset(): AssetsManager;
  67995. /**
  67996. * Start the loading process
  67997. * @return the current instance of the AssetsManager
  67998. */
  67999. load(): AssetsManager;
  68000. /**
  68001. * Start the loading process as an async operation
  68002. * @return a promise returning the list of failed tasks
  68003. */
  68004. loadAsync(): Promise<void>;
  68005. }
  68006. }
  68007. declare module BABYLON {
  68008. /**
  68009. * Wrapper class for promise with external resolve and reject.
  68010. */
  68011. export class Deferred<T> {
  68012. /**
  68013. * The promise associated with this deferred object.
  68014. */
  68015. readonly promise: Promise<T>;
  68016. private _resolve;
  68017. private _reject;
  68018. /**
  68019. * The resolve method of the promise associated with this deferred object.
  68020. */
  68021. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68022. /**
  68023. * The reject method of the promise associated with this deferred object.
  68024. */
  68025. get reject(): (reason?: any) => void;
  68026. /**
  68027. * Constructor for this deferred object.
  68028. */
  68029. constructor();
  68030. }
  68031. }
  68032. declare module BABYLON {
  68033. /**
  68034. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68035. */
  68036. export class MeshExploder {
  68037. private _centerMesh;
  68038. private _meshes;
  68039. private _meshesOrigins;
  68040. private _toCenterVectors;
  68041. private _scaledDirection;
  68042. private _newPosition;
  68043. private _centerPosition;
  68044. /**
  68045. * Explodes meshes from a center mesh.
  68046. * @param meshes The meshes to explode.
  68047. * @param centerMesh The mesh to be center of explosion.
  68048. */
  68049. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68050. private _setCenterMesh;
  68051. /**
  68052. * Get class name
  68053. * @returns "MeshExploder"
  68054. */
  68055. getClassName(): string;
  68056. /**
  68057. * "Exploded meshes"
  68058. * @returns Array of meshes with the centerMesh at index 0.
  68059. */
  68060. getMeshes(): Array<Mesh>;
  68061. /**
  68062. * Explodes meshes giving a specific direction
  68063. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68064. */
  68065. explode(direction?: number): void;
  68066. }
  68067. }
  68068. declare module BABYLON {
  68069. /**
  68070. * Class used to help managing file picking and drag'n'drop
  68071. */
  68072. export class FilesInput {
  68073. /**
  68074. * List of files ready to be loaded
  68075. */
  68076. static get FilesToLoad(): {
  68077. [key: string]: File;
  68078. };
  68079. /**
  68080. * Callback called when a file is processed
  68081. */
  68082. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68083. private _engine;
  68084. private _currentScene;
  68085. private _sceneLoadedCallback;
  68086. private _progressCallback;
  68087. private _additionalRenderLoopLogicCallback;
  68088. private _textureLoadingCallback;
  68089. private _startingProcessingFilesCallback;
  68090. private _onReloadCallback;
  68091. private _errorCallback;
  68092. private _elementToMonitor;
  68093. private _sceneFileToLoad;
  68094. private _filesToLoad;
  68095. /**
  68096. * Creates a new FilesInput
  68097. * @param engine defines the rendering engine
  68098. * @param scene defines the hosting scene
  68099. * @param sceneLoadedCallback callback called when scene is loaded
  68100. * @param progressCallback callback called to track progress
  68101. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68102. * @param textureLoadingCallback callback called when a texture is loading
  68103. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68104. * @param onReloadCallback callback called when a reload is requested
  68105. * @param errorCallback callback call if an error occurs
  68106. */
  68107. 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);
  68108. private _dragEnterHandler;
  68109. private _dragOverHandler;
  68110. private _dropHandler;
  68111. /**
  68112. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68113. * @param elementToMonitor defines the DOM element to track
  68114. */
  68115. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68116. /**
  68117. * Release all associated resources
  68118. */
  68119. dispose(): void;
  68120. private renderFunction;
  68121. private drag;
  68122. private drop;
  68123. private _traverseFolder;
  68124. private _processFiles;
  68125. /**
  68126. * Load files from a drop event
  68127. * @param event defines the drop event to use as source
  68128. */
  68129. loadFiles(event: any): void;
  68130. private _processReload;
  68131. /**
  68132. * Reload the current scene from the loaded files
  68133. */
  68134. reload(): void;
  68135. }
  68136. }
  68137. declare module BABYLON {
  68138. /**
  68139. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68141. */
  68142. export class SceneOptimization {
  68143. /**
  68144. * Defines the priority of this optimization (0 by default which means first in the list)
  68145. */
  68146. priority: number;
  68147. /**
  68148. * Gets a string describing the action executed by the current optimization
  68149. * @returns description string
  68150. */
  68151. getDescription(): string;
  68152. /**
  68153. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68154. * @param scene defines the current scene where to apply this optimization
  68155. * @param optimizer defines the current optimizer
  68156. * @returns true if everything that can be done was applied
  68157. */
  68158. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68159. /**
  68160. * Creates the SceneOptimization object
  68161. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68162. * @param desc defines the description associated with the optimization
  68163. */
  68164. constructor(
  68165. /**
  68166. * Defines the priority of this optimization (0 by default which means first in the list)
  68167. */
  68168. priority?: number);
  68169. }
  68170. /**
  68171. * Defines an optimization used to reduce the size of render target textures
  68172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68173. */
  68174. export class TextureOptimization extends SceneOptimization {
  68175. /**
  68176. * Defines the priority of this optimization (0 by default which means first in the list)
  68177. */
  68178. priority: number;
  68179. /**
  68180. * 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
  68181. */
  68182. maximumSize: number;
  68183. /**
  68184. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68185. */
  68186. step: number;
  68187. /**
  68188. * Gets a string describing the action executed by the current optimization
  68189. * @returns description string
  68190. */
  68191. getDescription(): string;
  68192. /**
  68193. * Creates the TextureOptimization object
  68194. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68195. * @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
  68196. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68197. */
  68198. constructor(
  68199. /**
  68200. * Defines the priority of this optimization (0 by default which means first in the list)
  68201. */
  68202. priority?: number,
  68203. /**
  68204. * 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
  68205. */
  68206. maximumSize?: number,
  68207. /**
  68208. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68209. */
  68210. step?: number);
  68211. /**
  68212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68213. * @param scene defines the current scene where to apply this optimization
  68214. * @param optimizer defines the current optimizer
  68215. * @returns true if everything that can be done was applied
  68216. */
  68217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68218. }
  68219. /**
  68220. * Defines an optimization used to increase or decrease the rendering resolution
  68221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68222. */
  68223. export class HardwareScalingOptimization extends SceneOptimization {
  68224. /**
  68225. * Defines the priority of this optimization (0 by default which means first in the list)
  68226. */
  68227. priority: number;
  68228. /**
  68229. * Defines the maximum scale to use (2 by default)
  68230. */
  68231. maximumScale: number;
  68232. /**
  68233. * Defines the step to use between two passes (0.5 by default)
  68234. */
  68235. step: number;
  68236. private _currentScale;
  68237. private _directionOffset;
  68238. /**
  68239. * Gets a string describing the action executed by the current optimization
  68240. * @return description string
  68241. */
  68242. getDescription(): string;
  68243. /**
  68244. * Creates the HardwareScalingOptimization object
  68245. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68246. * @param maximumScale defines the maximum scale to use (2 by default)
  68247. * @param step defines the step to use between two passes (0.5 by default)
  68248. */
  68249. constructor(
  68250. /**
  68251. * Defines the priority of this optimization (0 by default which means first in the list)
  68252. */
  68253. priority?: number,
  68254. /**
  68255. * Defines the maximum scale to use (2 by default)
  68256. */
  68257. maximumScale?: number,
  68258. /**
  68259. * Defines the step to use between two passes (0.5 by default)
  68260. */
  68261. step?: number);
  68262. /**
  68263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68264. * @param scene defines the current scene where to apply this optimization
  68265. * @param optimizer defines the current optimizer
  68266. * @returns true if everything that can be done was applied
  68267. */
  68268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68269. }
  68270. /**
  68271. * Defines an optimization used to remove shadows
  68272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68273. */
  68274. export class ShadowsOptimization extends SceneOptimization {
  68275. /**
  68276. * Gets a string describing the action executed by the current optimization
  68277. * @return description string
  68278. */
  68279. getDescription(): string;
  68280. /**
  68281. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68282. * @param scene defines the current scene where to apply this optimization
  68283. * @param optimizer defines the current optimizer
  68284. * @returns true if everything that can be done was applied
  68285. */
  68286. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68287. }
  68288. /**
  68289. * Defines an optimization used to turn post-processes off
  68290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68291. */
  68292. export class PostProcessesOptimization extends SceneOptimization {
  68293. /**
  68294. * Gets a string describing the action executed by the current optimization
  68295. * @return description string
  68296. */
  68297. getDescription(): string;
  68298. /**
  68299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68300. * @param scene defines the current scene where to apply this optimization
  68301. * @param optimizer defines the current optimizer
  68302. * @returns true if everything that can be done was applied
  68303. */
  68304. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68305. }
  68306. /**
  68307. * Defines an optimization used to turn lens flares off
  68308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68309. */
  68310. export class LensFlaresOptimization extends SceneOptimization {
  68311. /**
  68312. * Gets a string describing the action executed by the current optimization
  68313. * @return description string
  68314. */
  68315. getDescription(): string;
  68316. /**
  68317. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68318. * @param scene defines the current scene where to apply this optimization
  68319. * @param optimizer defines the current optimizer
  68320. * @returns true if everything that can be done was applied
  68321. */
  68322. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68323. }
  68324. /**
  68325. * Defines an optimization based on user defined callback.
  68326. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68327. */
  68328. export class CustomOptimization extends SceneOptimization {
  68329. /**
  68330. * Callback called to apply the custom optimization.
  68331. */
  68332. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68333. /**
  68334. * Callback called to get custom description
  68335. */
  68336. onGetDescription: () => string;
  68337. /**
  68338. * Gets a string describing the action executed by the current optimization
  68339. * @returns description string
  68340. */
  68341. getDescription(): string;
  68342. /**
  68343. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68344. * @param scene defines the current scene where to apply this optimization
  68345. * @param optimizer defines the current optimizer
  68346. * @returns true if everything that can be done was applied
  68347. */
  68348. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68349. }
  68350. /**
  68351. * Defines an optimization used to turn particles off
  68352. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68353. */
  68354. export class ParticlesOptimization extends SceneOptimization {
  68355. /**
  68356. * Gets a string describing the action executed by the current optimization
  68357. * @return description string
  68358. */
  68359. getDescription(): string;
  68360. /**
  68361. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68362. * @param scene defines the current scene where to apply this optimization
  68363. * @param optimizer defines the current optimizer
  68364. * @returns true if everything that can be done was applied
  68365. */
  68366. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68367. }
  68368. /**
  68369. * Defines an optimization used to turn render targets off
  68370. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68371. */
  68372. export class RenderTargetsOptimization extends SceneOptimization {
  68373. /**
  68374. * Gets a string describing the action executed by the current optimization
  68375. * @return description string
  68376. */
  68377. getDescription(): string;
  68378. /**
  68379. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68380. * @param scene defines the current scene where to apply this optimization
  68381. * @param optimizer defines the current optimizer
  68382. * @returns true if everything that can be done was applied
  68383. */
  68384. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68385. }
  68386. /**
  68387. * Defines an optimization used to merge meshes with compatible materials
  68388. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68389. */
  68390. export class MergeMeshesOptimization extends SceneOptimization {
  68391. private static _UpdateSelectionTree;
  68392. /**
  68393. * Gets or sets a boolean which defines if optimization octree has to be updated
  68394. */
  68395. static get UpdateSelectionTree(): boolean;
  68396. /**
  68397. * Gets or sets a boolean which defines if optimization octree has to be updated
  68398. */
  68399. static set UpdateSelectionTree(value: boolean);
  68400. /**
  68401. * Gets a string describing the action executed by the current optimization
  68402. * @return description string
  68403. */
  68404. getDescription(): string;
  68405. private _canBeMerged;
  68406. /**
  68407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68408. * @param scene defines the current scene where to apply this optimization
  68409. * @param optimizer defines the current optimizer
  68410. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68411. * @returns true if everything that can be done was applied
  68412. */
  68413. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68414. }
  68415. /**
  68416. * Defines a list of options used by SceneOptimizer
  68417. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68418. */
  68419. export class SceneOptimizerOptions {
  68420. /**
  68421. * Defines the target frame rate to reach (60 by default)
  68422. */
  68423. targetFrameRate: number;
  68424. /**
  68425. * Defines the interval between two checkes (2000ms by default)
  68426. */
  68427. trackerDuration: number;
  68428. /**
  68429. * Gets the list of optimizations to apply
  68430. */
  68431. optimizations: SceneOptimization[];
  68432. /**
  68433. * Creates a new list of options used by SceneOptimizer
  68434. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68435. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68436. */
  68437. constructor(
  68438. /**
  68439. * Defines the target frame rate to reach (60 by default)
  68440. */
  68441. targetFrameRate?: number,
  68442. /**
  68443. * Defines the interval between two checkes (2000ms by default)
  68444. */
  68445. trackerDuration?: number);
  68446. /**
  68447. * Add a new optimization
  68448. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68449. * @returns the current SceneOptimizerOptions
  68450. */
  68451. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68452. /**
  68453. * Add a new custom optimization
  68454. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68455. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68456. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68457. * @returns the current SceneOptimizerOptions
  68458. */
  68459. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68460. /**
  68461. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68462. * @param targetFrameRate defines the target frame rate (60 by default)
  68463. * @returns a SceneOptimizerOptions object
  68464. */
  68465. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68466. /**
  68467. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68468. * @param targetFrameRate defines the target frame rate (60 by default)
  68469. * @returns a SceneOptimizerOptions object
  68470. */
  68471. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68472. /**
  68473. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68474. * @param targetFrameRate defines the target frame rate (60 by default)
  68475. * @returns a SceneOptimizerOptions object
  68476. */
  68477. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68478. }
  68479. /**
  68480. * Class used to run optimizations in order to reach a target frame rate
  68481. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68482. */
  68483. export class SceneOptimizer implements IDisposable {
  68484. private _isRunning;
  68485. private _options;
  68486. private _scene;
  68487. private _currentPriorityLevel;
  68488. private _targetFrameRate;
  68489. private _trackerDuration;
  68490. private _currentFrameRate;
  68491. private _sceneDisposeObserver;
  68492. private _improvementMode;
  68493. /**
  68494. * Defines an observable called when the optimizer reaches the target frame rate
  68495. */
  68496. onSuccessObservable: Observable<SceneOptimizer>;
  68497. /**
  68498. * Defines an observable called when the optimizer enables an optimization
  68499. */
  68500. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68501. /**
  68502. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68503. */
  68504. onFailureObservable: Observable<SceneOptimizer>;
  68505. /**
  68506. * Gets a boolean indicating if the optimizer is in improvement mode
  68507. */
  68508. get isInImprovementMode(): boolean;
  68509. /**
  68510. * Gets the current priority level (0 at start)
  68511. */
  68512. get currentPriorityLevel(): number;
  68513. /**
  68514. * Gets the current frame rate checked by the SceneOptimizer
  68515. */
  68516. get currentFrameRate(): number;
  68517. /**
  68518. * Gets or sets the current target frame rate (60 by default)
  68519. */
  68520. get targetFrameRate(): number;
  68521. /**
  68522. * Gets or sets the current target frame rate (60 by default)
  68523. */
  68524. set targetFrameRate(value: number);
  68525. /**
  68526. * Gets or sets the current interval between two checks (every 2000ms by default)
  68527. */
  68528. get trackerDuration(): number;
  68529. /**
  68530. * Gets or sets the current interval between two checks (every 2000ms by default)
  68531. */
  68532. set trackerDuration(value: number);
  68533. /**
  68534. * Gets the list of active optimizations
  68535. */
  68536. get optimizations(): SceneOptimization[];
  68537. /**
  68538. * Creates a new SceneOptimizer
  68539. * @param scene defines the scene to work on
  68540. * @param options defines the options to use with the SceneOptimizer
  68541. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68542. * @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)
  68543. */
  68544. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68545. /**
  68546. * Stops the current optimizer
  68547. */
  68548. stop(): void;
  68549. /**
  68550. * Reset the optimizer to initial step (current priority level = 0)
  68551. */
  68552. reset(): void;
  68553. /**
  68554. * Start the optimizer. By default it will try to reach a specific framerate
  68555. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68556. */
  68557. start(): void;
  68558. private _checkCurrentState;
  68559. /**
  68560. * Release all resources
  68561. */
  68562. dispose(): void;
  68563. /**
  68564. * Helper function to create a SceneOptimizer with one single line of code
  68565. * @param scene defines the scene to work on
  68566. * @param options defines the options to use with the SceneOptimizer
  68567. * @param onSuccess defines a callback to call on success
  68568. * @param onFailure defines a callback to call on failure
  68569. * @returns the new SceneOptimizer object
  68570. */
  68571. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68572. }
  68573. }
  68574. declare module BABYLON {
  68575. /**
  68576. * Class used to serialize a scene into a string
  68577. */
  68578. export class SceneSerializer {
  68579. /**
  68580. * Clear cache used by a previous serialization
  68581. */
  68582. static ClearCache(): void;
  68583. /**
  68584. * Serialize a scene into a JSON compatible object
  68585. * @param scene defines the scene to serialize
  68586. * @returns a JSON compatible object
  68587. */
  68588. static Serialize(scene: Scene): any;
  68589. /**
  68590. * Serialize a mesh into a JSON compatible object
  68591. * @param toSerialize defines the mesh to serialize
  68592. * @param withParents defines if parents must be serialized as well
  68593. * @param withChildren defines if children must be serialized as well
  68594. * @returns a JSON compatible object
  68595. */
  68596. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68597. }
  68598. }
  68599. declare module BABYLON {
  68600. /**
  68601. * Class used to host texture specific utilities
  68602. */
  68603. export class TextureTools {
  68604. /**
  68605. * Uses the GPU to create a copy texture rescaled at a given size
  68606. * @param texture Texture to copy from
  68607. * @param width defines the desired width
  68608. * @param height defines the desired height
  68609. * @param useBilinearMode defines if bilinear mode has to be used
  68610. * @return the generated texture
  68611. */
  68612. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68613. }
  68614. }
  68615. declare module BABYLON {
  68616. /**
  68617. * This represents the different options available for the video capture.
  68618. */
  68619. export interface VideoRecorderOptions {
  68620. /** Defines the mime type of the video. */
  68621. mimeType: string;
  68622. /** Defines the FPS the video should be recorded at. */
  68623. fps: number;
  68624. /** Defines the chunk size for the recording data. */
  68625. recordChunckSize: number;
  68626. /** The audio tracks to attach to the recording. */
  68627. audioTracks?: MediaStreamTrack[];
  68628. }
  68629. /**
  68630. * This can help with recording videos from BabylonJS.
  68631. * This is based on the available WebRTC functionalities of the browser.
  68632. *
  68633. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68634. */
  68635. export class VideoRecorder {
  68636. private static readonly _defaultOptions;
  68637. /**
  68638. * Returns whether or not the VideoRecorder is available in your browser.
  68639. * @param engine Defines the Babylon Engine.
  68640. * @returns true if supported otherwise false.
  68641. */
  68642. static IsSupported(engine: Engine): boolean;
  68643. private readonly _options;
  68644. private _canvas;
  68645. private _mediaRecorder;
  68646. private _recordedChunks;
  68647. private _fileName;
  68648. private _resolve;
  68649. private _reject;
  68650. /**
  68651. * True when a recording is already in progress.
  68652. */
  68653. get isRecording(): boolean;
  68654. /**
  68655. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68656. * @param engine Defines the BabylonJS Engine you wish to record.
  68657. * @param options Defines options that can be used to customize the capture.
  68658. */
  68659. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68660. /**
  68661. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68662. */
  68663. stopRecording(): void;
  68664. /**
  68665. * Starts recording the canvas for a max duration specified in parameters.
  68666. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68667. * If null no automatic download will start and you can rely on the promise to get the data back.
  68668. * @param maxDuration Defines the maximum recording time in seconds.
  68669. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68670. * @return A promise callback at the end of the recording with the video data in Blob.
  68671. */
  68672. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68673. /**
  68674. * Releases internal resources used during the recording.
  68675. */
  68676. dispose(): void;
  68677. private _handleDataAvailable;
  68678. private _handleError;
  68679. private _handleStop;
  68680. }
  68681. }
  68682. declare module BABYLON {
  68683. /**
  68684. * Class containing a set of static utilities functions for screenshots
  68685. */
  68686. export class ScreenshotTools {
  68687. /**
  68688. * Captures a screenshot of the current rendering
  68689. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68690. * @param engine defines the rendering engine
  68691. * @param camera defines the source camera
  68692. * @param size This parameter can be set to a single number or to an object with the
  68693. * following (optional) properties: precision, width, height. If a single number is passed,
  68694. * it will be used for both width and height. If an object is passed, the screenshot size
  68695. * will be derived from the parameters. The precision property is a multiplier allowing
  68696. * rendering at a higher or lower resolution
  68697. * @param successCallback defines the callback receives a single parameter which contains the
  68698. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68699. * src parameter of an <img> to display it
  68700. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68701. * Check your browser for supported MIME types
  68702. */
  68703. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68704. /**
  68705. * Captures a screenshot of the current rendering
  68706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68707. * @param engine defines the rendering engine
  68708. * @param camera defines the source camera
  68709. * @param size This parameter can be set to a single number or to an object with the
  68710. * following (optional) properties: precision, width, height. If a single number is passed,
  68711. * it will be used for both width and height. If an object is passed, the screenshot size
  68712. * will be derived from the parameters. The precision property is a multiplier allowing
  68713. * rendering at a higher or lower resolution
  68714. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68715. * Check your browser for supported MIME types
  68716. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68717. * to the src parameter of an <img> to display it
  68718. */
  68719. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68720. /**
  68721. * Generates an image screenshot from the specified camera.
  68722. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68723. * @param engine The engine to use for rendering
  68724. * @param camera The camera to use for rendering
  68725. * @param size This parameter can be set to a single number or to an object with the
  68726. * following (optional) properties: precision, width, height. If a single number is passed,
  68727. * it will be used for both width and height. If an object is passed, the screenshot size
  68728. * will be derived from the parameters. The precision property is a multiplier allowing
  68729. * rendering at a higher or lower resolution
  68730. * @param successCallback The callback receives a single parameter which contains the
  68731. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68732. * src parameter of an <img> to display it
  68733. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68734. * Check your browser for supported MIME types
  68735. * @param samples Texture samples (default: 1)
  68736. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68737. * @param fileName A name for for the downloaded file.
  68738. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68739. */
  68740. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68741. /**
  68742. * Generates an image screenshot from the specified camera.
  68743. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68744. * @param engine The engine to use for rendering
  68745. * @param camera The camera to use for rendering
  68746. * @param size This parameter can be set to a single number or to an object with the
  68747. * following (optional) properties: precision, width, height. If a single number is passed,
  68748. * it will be used for both width and height. If an object is passed, the screenshot size
  68749. * will be derived from the parameters. The precision property is a multiplier allowing
  68750. * rendering at a higher or lower resolution
  68751. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68752. * Check your browser for supported MIME types
  68753. * @param samples Texture samples (default: 1)
  68754. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68755. * @param fileName A name for for the downloaded file.
  68756. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68757. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68758. * to the src parameter of an <img> to display it
  68759. */
  68760. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68761. /**
  68762. * Gets height and width for screenshot size
  68763. * @private
  68764. */
  68765. private static _getScreenshotSize;
  68766. }
  68767. }
  68768. declare module BABYLON {
  68769. /**
  68770. * Interface for a data buffer
  68771. */
  68772. export interface IDataBuffer {
  68773. /**
  68774. * Reads bytes from the data buffer.
  68775. * @param byteOffset The byte offset to read
  68776. * @param byteLength The byte length to read
  68777. * @returns A promise that resolves when the bytes are read
  68778. */
  68779. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68780. /**
  68781. * The byte length of the buffer.
  68782. */
  68783. readonly byteLength: number;
  68784. }
  68785. /**
  68786. * Utility class for reading from a data buffer
  68787. */
  68788. export class DataReader {
  68789. /**
  68790. * The data buffer associated with this data reader.
  68791. */
  68792. readonly buffer: IDataBuffer;
  68793. /**
  68794. * The current byte offset from the beginning of the data buffer.
  68795. */
  68796. byteOffset: number;
  68797. private _dataView;
  68798. private _dataByteOffset;
  68799. /**
  68800. * Constructor
  68801. * @param buffer The buffer to read
  68802. */
  68803. constructor(buffer: IDataBuffer);
  68804. /**
  68805. * Loads the given byte length.
  68806. * @param byteLength The byte length to load
  68807. * @returns A promise that resolves when the load is complete
  68808. */
  68809. loadAsync(byteLength: number): Promise<void>;
  68810. /**
  68811. * Read a unsigned 32-bit integer from the currently loaded data range.
  68812. * @returns The 32-bit integer read
  68813. */
  68814. readUint32(): number;
  68815. /**
  68816. * Read a byte array from the currently loaded data range.
  68817. * @param byteLength The byte length to read
  68818. * @returns The byte array read
  68819. */
  68820. readUint8Array(byteLength: number): Uint8Array;
  68821. /**
  68822. * Read a string from the currently loaded data range.
  68823. * @param byteLength The byte length to read
  68824. * @returns The string read
  68825. */
  68826. readString(byteLength: number): string;
  68827. /**
  68828. * Skips the given byte length the currently loaded data range.
  68829. * @param byteLength The byte length to skip
  68830. */
  68831. skipBytes(byteLength: number): void;
  68832. }
  68833. }
  68834. declare module BABYLON {
  68835. /**
  68836. * Class for storing data to local storage if available or in-memory storage otherwise
  68837. */
  68838. export class DataStorage {
  68839. private static _Storage;
  68840. private static _GetStorage;
  68841. /**
  68842. * Reads a string from the data storage
  68843. * @param key The key to read
  68844. * @param defaultValue The value if the key doesn't exist
  68845. * @returns The string value
  68846. */
  68847. static ReadString(key: string, defaultValue: string): string;
  68848. /**
  68849. * Writes a string to the data storage
  68850. * @param key The key to write
  68851. * @param value The value to write
  68852. */
  68853. static WriteString(key: string, value: string): void;
  68854. /**
  68855. * Reads a boolean from the data storage
  68856. * @param key The key to read
  68857. * @param defaultValue The value if the key doesn't exist
  68858. * @returns The boolean value
  68859. */
  68860. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  68861. /**
  68862. * Writes a boolean to the data storage
  68863. * @param key The key to write
  68864. * @param value The value to write
  68865. */
  68866. static WriteBoolean(key: string, value: boolean): void;
  68867. /**
  68868. * Reads a number from the data storage
  68869. * @param key The key to read
  68870. * @param defaultValue The value if the key doesn't exist
  68871. * @returns The number value
  68872. */
  68873. static ReadNumber(key: string, defaultValue: number): number;
  68874. /**
  68875. * Writes a number to the data storage
  68876. * @param key The key to write
  68877. * @param value The value to write
  68878. */
  68879. static WriteNumber(key: string, value: number): void;
  68880. }
  68881. }
  68882. declare module BABYLON {
  68883. /**
  68884. * Options used for hit testing
  68885. */
  68886. export interface IWebXRHitTestOptions {
  68887. /**
  68888. * Only test when user interacted with the scene. Default - hit test every frame
  68889. */
  68890. testOnPointerDownOnly?: boolean;
  68891. /**
  68892. * The node to use to transform the local results to world coordinates
  68893. */
  68894. worldParentNode?: TransformNode;
  68895. }
  68896. /**
  68897. * Interface defining the babylon result of raycasting/hit-test
  68898. */
  68899. export interface IWebXRHitResult {
  68900. /**
  68901. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68902. */
  68903. transformationMatrix: Matrix;
  68904. /**
  68905. * The native hit test result
  68906. */
  68907. xrHitResult: XRHitResult;
  68908. }
  68909. /**
  68910. * The currently-working hit-test module.
  68911. * Hit test (or Ray-casting) is used to interact with the real world.
  68912. * For further information read here - https://github.com/immersive-web/hit-test
  68913. */
  68914. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68915. /**
  68916. * options to use when constructing this feature
  68917. */
  68918. readonly options: IWebXRHitTestOptions;
  68919. private _direction;
  68920. private _mat;
  68921. private _onSelectEnabled;
  68922. private _origin;
  68923. /**
  68924. * The module's name
  68925. */
  68926. static readonly Name: string;
  68927. /**
  68928. * The (Babylon) version of this module.
  68929. * This is an integer representing the implementation version.
  68930. * This number does not correspond to the WebXR specs version
  68931. */
  68932. static readonly Version: number;
  68933. /**
  68934. * Populated with the last native XR Hit Results
  68935. */
  68936. lastNativeXRHitResults: XRHitResult[];
  68937. /**
  68938. * Triggered when new babylon (transformed) hit test results are available
  68939. */
  68940. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68941. /**
  68942. * Creates a new instance of the (legacy version) hit test feature
  68943. * @param _xrSessionManager an instance of WebXRSessionManager
  68944. * @param options options to use when constructing this feature
  68945. */
  68946. constructor(_xrSessionManager: WebXRSessionManager,
  68947. /**
  68948. * options to use when constructing this feature
  68949. */
  68950. options?: IWebXRHitTestOptions);
  68951. /**
  68952. * execute a hit test with an XR Ray
  68953. *
  68954. * @param xrSession a native xrSession that will execute this hit test
  68955. * @param xrRay the ray (position and direction) to use for ray-casting
  68956. * @param referenceSpace native XR reference space to use for the hit-test
  68957. * @param filter filter function that will filter the results
  68958. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68959. */
  68960. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68961. /**
  68962. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68963. * @param event the (select) event to use to select with
  68964. * @param referenceSpace the reference space to use for this hit test
  68965. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68966. */
  68967. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68968. /**
  68969. * attach this feature
  68970. * Will usually be called by the features manager
  68971. *
  68972. * @returns true if successful.
  68973. */
  68974. attach(): boolean;
  68975. /**
  68976. * detach this feature.
  68977. * Will usually be called by the features manager
  68978. *
  68979. * @returns true if successful.
  68980. */
  68981. detach(): boolean;
  68982. /**
  68983. * Dispose this feature and all of the resources attached
  68984. */
  68985. dispose(): void;
  68986. protected _onXRFrame(frame: XRFrame): void;
  68987. private _onHitTestResults;
  68988. private _onSelect;
  68989. }
  68990. }
  68991. declare module BABYLON {
  68992. /**
  68993. * Options used in the plane detector module
  68994. */
  68995. export interface IWebXRPlaneDetectorOptions {
  68996. /**
  68997. * The node to use to transform the local results to world coordinates
  68998. */
  68999. worldParentNode?: TransformNode;
  69000. }
  69001. /**
  69002. * A babylon interface for a WebXR plane.
  69003. * A Plane is actually a polygon, built from N points in space
  69004. *
  69005. * Supported in chrome 79, not supported in canary 81 ATM
  69006. */
  69007. export interface IWebXRPlane {
  69008. /**
  69009. * a babylon-assigned ID for this polygon
  69010. */
  69011. id: number;
  69012. /**
  69013. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69014. */
  69015. polygonDefinition: Array<Vector3>;
  69016. /**
  69017. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69018. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69019. */
  69020. transformationMatrix: Matrix;
  69021. /**
  69022. * the native xr-plane object
  69023. */
  69024. xrPlane: XRPlane;
  69025. }
  69026. /**
  69027. * The plane detector is used to detect planes in the real world when in AR
  69028. * For more information see https://github.com/immersive-web/real-world-geometry/
  69029. */
  69030. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69031. private _options;
  69032. private _detectedPlanes;
  69033. private _enabled;
  69034. private _lastFrameDetected;
  69035. /**
  69036. * The module's name
  69037. */
  69038. static readonly Name: string;
  69039. /**
  69040. * The (Babylon) version of this module.
  69041. * This is an integer representing the implementation version.
  69042. * This number does not correspond to the WebXR specs version
  69043. */
  69044. static readonly Version: number;
  69045. /**
  69046. * Observers registered here will be executed when a new plane was added to the session
  69047. */
  69048. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69049. /**
  69050. * Observers registered here will be executed when a plane is no longer detected in the session
  69051. */
  69052. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69053. /**
  69054. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69055. * This can execute N times every frame
  69056. */
  69057. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69058. /**
  69059. * construct a new Plane Detector
  69060. * @param _xrSessionManager an instance of xr Session manager
  69061. * @param _options configuration to use when constructing this feature
  69062. */
  69063. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69064. /**
  69065. * Dispose this feature and all of the resources attached
  69066. */
  69067. dispose(): void;
  69068. protected _onXRFrame(frame: XRFrame): void;
  69069. private _init;
  69070. private _updatePlaneWithXRPlane;
  69071. /**
  69072. * avoiding using Array.find for global support.
  69073. * @param xrPlane the plane to find in the array
  69074. */
  69075. private findIndexInPlaneArray;
  69076. }
  69077. }
  69078. declare module BABYLON {
  69079. /**
  69080. * Configuration options of the anchor system
  69081. */
  69082. export interface IWebXRAnchorSystemOptions {
  69083. /**
  69084. * Should a new anchor be added every time a select event is triggered
  69085. */
  69086. addAnchorOnSelect?: boolean;
  69087. /**
  69088. * should the anchor system use plane detection.
  69089. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69090. */
  69091. usePlaneDetection?: boolean;
  69092. /**
  69093. * a node that will be used to convert local to world coordinates
  69094. */
  69095. worldParentNode?: TransformNode;
  69096. }
  69097. /**
  69098. * A babylon container for an XR Anchor
  69099. */
  69100. export interface IWebXRAnchor {
  69101. /**
  69102. * A babylon-assigned ID for this anchor
  69103. */
  69104. id: number;
  69105. /**
  69106. * Transformation matrix to apply to an object attached to this anchor
  69107. */
  69108. transformationMatrix: Matrix;
  69109. /**
  69110. * The native anchor object
  69111. */
  69112. xrAnchor: XRAnchor;
  69113. }
  69114. /**
  69115. * An implementation of the anchor system of WebXR.
  69116. * Note that the current documented implementation is not available in any browser. Future implementations
  69117. * will use the frame to create an anchor and not the session or a detected plane
  69118. * For further information see https://github.com/immersive-web/anchors/
  69119. */
  69120. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69121. private _options;
  69122. private _enabled;
  69123. private _hitTestModule;
  69124. private _lastFrameDetected;
  69125. private _onSelect;
  69126. private _planeDetector;
  69127. private _trackedAnchors;
  69128. /**
  69129. * The module's name
  69130. */
  69131. static readonly Name: string;
  69132. /**
  69133. * The (Babylon) version of this module.
  69134. * This is an integer representing the implementation version.
  69135. * This number does not correspond to the WebXR specs version
  69136. */
  69137. static readonly Version: number;
  69138. /**
  69139. * Observers registered here will be executed when a new anchor was added to the session
  69140. */
  69141. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69142. /**
  69143. * Observers registered here will be executed when an anchor was removed from the session
  69144. */
  69145. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69146. /**
  69147. * Observers registered here will be executed when an existing anchor updates
  69148. * This can execute N times every frame
  69149. */
  69150. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69151. /**
  69152. * constructs a new anchor system
  69153. * @param _xrSessionManager an instance of WebXRSessionManager
  69154. * @param _options configuration object for this feature
  69155. */
  69156. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69157. /**
  69158. * Add anchor at a specific XR point.
  69159. *
  69160. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69161. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69162. * @returns a promise the fulfills when the anchor was created
  69163. */
  69164. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69165. /**
  69166. * attach this feature
  69167. * Will usually be called by the features manager
  69168. *
  69169. * @returns true if successful.
  69170. */
  69171. attach(): boolean;
  69172. /**
  69173. * detach this feature.
  69174. * Will usually be called by the features manager
  69175. *
  69176. * @returns true if successful.
  69177. */
  69178. detach(): boolean;
  69179. /**
  69180. * Dispose this feature and all of the resources attached
  69181. */
  69182. dispose(): void;
  69183. /**
  69184. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69185. * @param hitTestModule the hit-test module to use.
  69186. */
  69187. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69188. /**
  69189. * set the plane detector to use in order to create anchors from frames
  69190. * @param planeDetector the plane-detector module to use
  69191. * @param enable enable plane-anchors. default is true
  69192. */
  69193. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69194. protected _onXRFrame(frame: XRFrame): void;
  69195. /**
  69196. * avoiding using Array.find for global support.
  69197. * @param xrAnchor the plane to find in the array
  69198. */
  69199. private _findIndexInAnchorArray;
  69200. private _updateAnchorWithXRFrame;
  69201. }
  69202. }
  69203. declare module BABYLON {
  69204. /**
  69205. * Options interface for the background remover plugin
  69206. */
  69207. export interface IWebXRBackgroundRemoverOptions {
  69208. /**
  69209. * Further background meshes to disable when entering AR
  69210. */
  69211. backgroundMeshes?: AbstractMesh[];
  69212. /**
  69213. * flags to configure the removal of the environment helper.
  69214. * If not set, the entire background will be removed. If set, flags should be set as well.
  69215. */
  69216. environmentHelperRemovalFlags?: {
  69217. /**
  69218. * Should the skybox be removed (default false)
  69219. */
  69220. skyBox?: boolean;
  69221. /**
  69222. * Should the ground be removed (default false)
  69223. */
  69224. ground?: boolean;
  69225. };
  69226. /**
  69227. * don't disable the environment helper
  69228. */
  69229. ignoreEnvironmentHelper?: boolean;
  69230. }
  69231. /**
  69232. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69233. */
  69234. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69235. /**
  69236. * read-only options to be used in this module
  69237. */
  69238. readonly options: IWebXRBackgroundRemoverOptions;
  69239. /**
  69240. * The module's name
  69241. */
  69242. static readonly Name: string;
  69243. /**
  69244. * The (Babylon) version of this module.
  69245. * This is an integer representing the implementation version.
  69246. * This number does not correspond to the WebXR specs version
  69247. */
  69248. static readonly Version: number;
  69249. /**
  69250. * registered observers will be triggered when the background state changes
  69251. */
  69252. onBackgroundStateChangedObservable: Observable<boolean>;
  69253. /**
  69254. * constructs a new background remover module
  69255. * @param _xrSessionManager the session manager for this module
  69256. * @param options read-only options to be used in this module
  69257. */
  69258. constructor(_xrSessionManager: WebXRSessionManager,
  69259. /**
  69260. * read-only options to be used in this module
  69261. */
  69262. options?: IWebXRBackgroundRemoverOptions);
  69263. /**
  69264. * attach this feature
  69265. * Will usually be called by the features manager
  69266. *
  69267. * @returns true if successful.
  69268. */
  69269. attach(): boolean;
  69270. /**
  69271. * detach this feature.
  69272. * Will usually be called by the features manager
  69273. *
  69274. * @returns true if successful.
  69275. */
  69276. detach(): boolean;
  69277. /**
  69278. * Dispose this feature and all of the resources attached
  69279. */
  69280. dispose(): void;
  69281. protected _onXRFrame(_xrFrame: XRFrame): void;
  69282. private _setBackgroundState;
  69283. }
  69284. }
  69285. declare module BABYLON {
  69286. /**
  69287. * Options for the controller physics feature
  69288. */
  69289. export class IWebXRControllerPhysicsOptions {
  69290. /**
  69291. * Should the headset get its own impostor
  69292. */
  69293. enableHeadsetImpostor?: boolean;
  69294. /**
  69295. * Optional parameters for the headset impostor
  69296. */
  69297. headsetImpostorParams?: {
  69298. /**
  69299. * The type of impostor to create. Default is sphere
  69300. */
  69301. impostorType: number;
  69302. /**
  69303. * the size of the impostor. Defaults to 10cm
  69304. */
  69305. impostorSize?: number | {
  69306. width: number;
  69307. height: number;
  69308. depth: number;
  69309. };
  69310. /**
  69311. * Friction definitions
  69312. */
  69313. friction?: number;
  69314. /**
  69315. * Restitution
  69316. */
  69317. restitution?: number;
  69318. };
  69319. /**
  69320. * The physics properties of the future impostors
  69321. */
  69322. physicsProperties?: {
  69323. /**
  69324. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69325. * Note that this requires a physics engine that supports mesh impostors!
  69326. */
  69327. useControllerMesh?: boolean;
  69328. /**
  69329. * The type of impostor to create. Default is sphere
  69330. */
  69331. impostorType?: number;
  69332. /**
  69333. * the size of the impostor. Defaults to 10cm
  69334. */
  69335. impostorSize?: number | {
  69336. width: number;
  69337. height: number;
  69338. depth: number;
  69339. };
  69340. /**
  69341. * Friction definitions
  69342. */
  69343. friction?: number;
  69344. /**
  69345. * Restitution
  69346. */
  69347. restitution?: number;
  69348. };
  69349. /**
  69350. * the xr input to use with this pointer selection
  69351. */
  69352. xrInput: WebXRInput;
  69353. }
  69354. /**
  69355. * Add physics impostor to your webxr controllers,
  69356. * including naive calculation of their linear and angular velocity
  69357. */
  69358. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69359. private readonly _options;
  69360. private _attachController;
  69361. private _controllers;
  69362. private _debugMode;
  69363. private _delta;
  69364. private _headsetImpostor?;
  69365. private _headsetMesh?;
  69366. private _lastTimestamp;
  69367. private _tmpQuaternion;
  69368. private _tmpVector;
  69369. /**
  69370. * The module's name
  69371. */
  69372. static readonly Name: string;
  69373. /**
  69374. * The (Babylon) version of this module.
  69375. * This is an integer representing the implementation version.
  69376. * This number does not correspond to the webxr specs version
  69377. */
  69378. static readonly Version: number;
  69379. /**
  69380. * Construct a new Controller Physics Feature
  69381. * @param _xrSessionManager the corresponding xr session manager
  69382. * @param _options options to create this feature with
  69383. */
  69384. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69385. /**
  69386. * @hidden
  69387. * enable debugging - will show console outputs and the impostor mesh
  69388. */
  69389. _enablePhysicsDebug(): void;
  69390. /**
  69391. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69392. * @param xrController the controller to add
  69393. */
  69394. addController(xrController: WebXRInputSource): void;
  69395. /**
  69396. * attach this feature
  69397. * Will usually be called by the features manager
  69398. *
  69399. * @returns true if successful.
  69400. */
  69401. attach(): boolean;
  69402. /**
  69403. * detach this feature.
  69404. * Will usually be called by the features manager
  69405. *
  69406. * @returns true if successful.
  69407. */
  69408. detach(): boolean;
  69409. /**
  69410. * Get the headset impostor, if enabled
  69411. * @returns the impostor
  69412. */
  69413. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69414. /**
  69415. * Get the physics impostor of a specific controller.
  69416. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69417. * @param controller the controller or the controller id of which to get the impostor
  69418. * @returns the impostor or null
  69419. */
  69420. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69421. /**
  69422. * Update the physics properties provided in the constructor
  69423. * @param newProperties the new properties object
  69424. */
  69425. setPhysicsProperties(newProperties: {
  69426. impostorType?: number;
  69427. impostorSize?: number | {
  69428. width: number;
  69429. height: number;
  69430. depth: number;
  69431. };
  69432. friction?: number;
  69433. restitution?: number;
  69434. }): void;
  69435. protected _onXRFrame(_xrFrame: any): void;
  69436. private _detachController;
  69437. }
  69438. }
  69439. declare module BABYLON {
  69440. /**
  69441. * The motion controller class for all microsoft mixed reality controllers
  69442. */
  69443. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69444. protected readonly _mapping: {
  69445. defaultButton: {
  69446. "valueNodeName": string;
  69447. "unpressedNodeName": string;
  69448. "pressedNodeName": string;
  69449. };
  69450. defaultAxis: {
  69451. "valueNodeName": string;
  69452. "minNodeName": string;
  69453. "maxNodeName": string;
  69454. };
  69455. buttons: {
  69456. "xr-standard-trigger": {
  69457. "rootNodeName": string;
  69458. "componentProperty": string;
  69459. "states": string[];
  69460. };
  69461. "xr-standard-squeeze": {
  69462. "rootNodeName": string;
  69463. "componentProperty": string;
  69464. "states": string[];
  69465. };
  69466. "xr-standard-touchpad": {
  69467. "rootNodeName": string;
  69468. "labelAnchorNodeName": string;
  69469. "touchPointNodeName": string;
  69470. };
  69471. "xr-standard-thumbstick": {
  69472. "rootNodeName": string;
  69473. "componentProperty": string;
  69474. "states": string[];
  69475. };
  69476. };
  69477. axes: {
  69478. "xr-standard-touchpad": {
  69479. "x-axis": {
  69480. "rootNodeName": string;
  69481. };
  69482. "y-axis": {
  69483. "rootNodeName": string;
  69484. };
  69485. };
  69486. "xr-standard-thumbstick": {
  69487. "x-axis": {
  69488. "rootNodeName": string;
  69489. };
  69490. "y-axis": {
  69491. "rootNodeName": string;
  69492. };
  69493. };
  69494. };
  69495. };
  69496. /**
  69497. * The base url used to load the left and right controller models
  69498. */
  69499. static MODEL_BASE_URL: string;
  69500. /**
  69501. * The name of the left controller model file
  69502. */
  69503. static MODEL_LEFT_FILENAME: string;
  69504. /**
  69505. * The name of the right controller model file
  69506. */
  69507. static MODEL_RIGHT_FILENAME: string;
  69508. profileId: string;
  69509. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69510. protected _getFilenameAndPath(): {
  69511. filename: string;
  69512. path: string;
  69513. };
  69514. protected _getModelLoadingConstraints(): boolean;
  69515. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69516. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69517. protected _updateModel(): void;
  69518. }
  69519. }
  69520. declare module BABYLON {
  69521. /**
  69522. * The motion controller class for oculus touch (quest, rift).
  69523. * This class supports legacy mapping as well the standard xr mapping
  69524. */
  69525. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69526. private _forceLegacyControllers;
  69527. private _modelRootNode;
  69528. /**
  69529. * The base url used to load the left and right controller models
  69530. */
  69531. static MODEL_BASE_URL: string;
  69532. /**
  69533. * The name of the left controller model file
  69534. */
  69535. static MODEL_LEFT_FILENAME: string;
  69536. /**
  69537. * The name of the right controller model file
  69538. */
  69539. static MODEL_RIGHT_FILENAME: string;
  69540. /**
  69541. * Base Url for the Quest controller model.
  69542. */
  69543. static QUEST_MODEL_BASE_URL: string;
  69544. profileId: string;
  69545. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69546. protected _getFilenameAndPath(): {
  69547. filename: string;
  69548. path: string;
  69549. };
  69550. protected _getModelLoadingConstraints(): boolean;
  69551. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69552. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69553. protected _updateModel(): void;
  69554. /**
  69555. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69556. * between the touch and touch 2.
  69557. */
  69558. private _isQuest;
  69559. }
  69560. }
  69561. declare module BABYLON {
  69562. /**
  69563. * The motion controller class for the standard HTC-Vive controllers
  69564. */
  69565. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69566. private _modelRootNode;
  69567. /**
  69568. * The base url used to load the left and right controller models
  69569. */
  69570. static MODEL_BASE_URL: string;
  69571. /**
  69572. * File name for the controller model.
  69573. */
  69574. static MODEL_FILENAME: string;
  69575. profileId: string;
  69576. /**
  69577. * Create a new Vive motion controller object
  69578. * @param scene the scene to use to create this controller
  69579. * @param gamepadObject the corresponding gamepad object
  69580. * @param handness the handness of the controller
  69581. */
  69582. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69583. protected _getFilenameAndPath(): {
  69584. filename: string;
  69585. path: string;
  69586. };
  69587. protected _getModelLoadingConstraints(): boolean;
  69588. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69589. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69590. protected _updateModel(): void;
  69591. }
  69592. }
  69593. declare module BABYLON {
  69594. /**
  69595. * A cursor which tracks a point on a path
  69596. */
  69597. export class PathCursor {
  69598. private path;
  69599. /**
  69600. * Stores path cursor callbacks for when an onchange event is triggered
  69601. */
  69602. private _onchange;
  69603. /**
  69604. * The value of the path cursor
  69605. */
  69606. value: number;
  69607. /**
  69608. * The animation array of the path cursor
  69609. */
  69610. animations: Animation[];
  69611. /**
  69612. * Initializes the path cursor
  69613. * @param path The path to track
  69614. */
  69615. constructor(path: Path2);
  69616. /**
  69617. * Gets the cursor point on the path
  69618. * @returns A point on the path cursor at the cursor location
  69619. */
  69620. getPoint(): Vector3;
  69621. /**
  69622. * Moves the cursor ahead by the step amount
  69623. * @param step The amount to move the cursor forward
  69624. * @returns This path cursor
  69625. */
  69626. moveAhead(step?: number): PathCursor;
  69627. /**
  69628. * Moves the cursor behind by the step amount
  69629. * @param step The amount to move the cursor back
  69630. * @returns This path cursor
  69631. */
  69632. moveBack(step?: number): PathCursor;
  69633. /**
  69634. * Moves the cursor by the step amount
  69635. * If the step amount is greater than one, an exception is thrown
  69636. * @param step The amount to move the cursor
  69637. * @returns This path cursor
  69638. */
  69639. move(step: number): PathCursor;
  69640. /**
  69641. * Ensures that the value is limited between zero and one
  69642. * @returns This path cursor
  69643. */
  69644. private ensureLimits;
  69645. /**
  69646. * Runs onchange callbacks on change (used by the animation engine)
  69647. * @returns This path cursor
  69648. */
  69649. private raiseOnChange;
  69650. /**
  69651. * Executes a function on change
  69652. * @param f A path cursor onchange callback
  69653. * @returns This path cursor
  69654. */
  69655. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69656. }
  69657. }
  69658. declare module BABYLON {
  69659. /** @hidden */
  69660. export var blurPixelShader: {
  69661. name: string;
  69662. shader: string;
  69663. };
  69664. }
  69665. declare module BABYLON {
  69666. /** @hidden */
  69667. export var pointCloudVertexDeclaration: {
  69668. name: string;
  69669. shader: string;
  69670. };
  69671. }
  69672. // Mixins
  69673. interface Window {
  69674. mozIndexedDB: IDBFactory;
  69675. webkitIndexedDB: IDBFactory;
  69676. msIndexedDB: IDBFactory;
  69677. webkitURL: typeof URL;
  69678. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69679. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69680. WebGLRenderingContext: WebGLRenderingContext;
  69681. MSGesture: MSGesture;
  69682. CANNON: any;
  69683. AudioContext: AudioContext;
  69684. webkitAudioContext: AudioContext;
  69685. PointerEvent: any;
  69686. Math: Math;
  69687. Uint8Array: Uint8ArrayConstructor;
  69688. Float32Array: Float32ArrayConstructor;
  69689. mozURL: typeof URL;
  69690. msURL: typeof URL;
  69691. VRFrameData: any; // WebVR, from specs 1.1
  69692. DracoDecoderModule: any;
  69693. setImmediate(handler: (...args: any[]) => void): number;
  69694. }
  69695. interface HTMLCanvasElement {
  69696. requestPointerLock(): void;
  69697. msRequestPointerLock?(): void;
  69698. mozRequestPointerLock?(): void;
  69699. webkitRequestPointerLock?(): void;
  69700. /** Track wether a record is in progress */
  69701. isRecording: boolean;
  69702. /** Capture Stream method defined by some browsers */
  69703. captureStream(fps?: number): MediaStream;
  69704. }
  69705. interface CanvasRenderingContext2D {
  69706. msImageSmoothingEnabled: boolean;
  69707. }
  69708. interface MouseEvent {
  69709. mozMovementX: number;
  69710. mozMovementY: number;
  69711. webkitMovementX: number;
  69712. webkitMovementY: number;
  69713. msMovementX: number;
  69714. msMovementY: number;
  69715. }
  69716. interface Navigator {
  69717. mozGetVRDevices: (any: any) => any;
  69718. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69719. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69720. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69721. webkitGetGamepads(): Gamepad[];
  69722. msGetGamepads(): Gamepad[];
  69723. webkitGamepads(): Gamepad[];
  69724. }
  69725. interface HTMLVideoElement {
  69726. mozSrcObject: any;
  69727. }
  69728. interface Math {
  69729. fround(x: number): number;
  69730. imul(a: number, b: number): number;
  69731. }
  69732. interface WebGLRenderingContext {
  69733. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69734. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69735. vertexAttribDivisor(index: number, divisor: number): void;
  69736. createVertexArray(): any;
  69737. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69738. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69739. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69740. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69741. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69742. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69743. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69744. // Queries
  69745. createQuery(): WebGLQuery;
  69746. deleteQuery(query: WebGLQuery): void;
  69747. beginQuery(target: number, query: WebGLQuery): void;
  69748. endQuery(target: number): void;
  69749. getQueryParameter(query: WebGLQuery, pname: number): any;
  69750. getQuery(target: number, pname: number): any;
  69751. MAX_SAMPLES: number;
  69752. RGBA8: number;
  69753. READ_FRAMEBUFFER: number;
  69754. DRAW_FRAMEBUFFER: number;
  69755. UNIFORM_BUFFER: number;
  69756. HALF_FLOAT_OES: number;
  69757. RGBA16F: number;
  69758. RGBA32F: number;
  69759. R32F: number;
  69760. RG32F: number;
  69761. RGB32F: number;
  69762. R16F: number;
  69763. RG16F: number;
  69764. RGB16F: number;
  69765. RED: number;
  69766. RG: number;
  69767. R8: number;
  69768. RG8: number;
  69769. UNSIGNED_INT_24_8: number;
  69770. DEPTH24_STENCIL8: number;
  69771. MIN: number;
  69772. MAX: number;
  69773. /* Multiple Render Targets */
  69774. drawBuffers(buffers: number[]): void;
  69775. readBuffer(src: number): void;
  69776. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69777. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69778. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69779. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69780. // Occlusion Query
  69781. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69782. ANY_SAMPLES_PASSED: number;
  69783. QUERY_RESULT_AVAILABLE: number;
  69784. QUERY_RESULT: number;
  69785. }
  69786. interface WebGLProgram {
  69787. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69788. }
  69789. interface EXT_disjoint_timer_query {
  69790. QUERY_COUNTER_BITS_EXT: number;
  69791. TIME_ELAPSED_EXT: number;
  69792. TIMESTAMP_EXT: number;
  69793. GPU_DISJOINT_EXT: number;
  69794. QUERY_RESULT_EXT: number;
  69795. QUERY_RESULT_AVAILABLE_EXT: number;
  69796. queryCounterEXT(query: WebGLQuery, target: number): void;
  69797. createQueryEXT(): WebGLQuery;
  69798. beginQueryEXT(target: number, query: WebGLQuery): void;
  69799. endQueryEXT(target: number): void;
  69800. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69801. deleteQueryEXT(query: WebGLQuery): void;
  69802. }
  69803. interface WebGLUniformLocation {
  69804. _currentState: any;
  69805. }
  69806. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69807. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69808. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69809. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69810. interface WebGLRenderingContext {
  69811. readonly RASTERIZER_DISCARD: number;
  69812. readonly DEPTH_COMPONENT24: number;
  69813. readonly TEXTURE_3D: number;
  69814. readonly TEXTURE_2D_ARRAY: number;
  69815. readonly TEXTURE_COMPARE_FUNC: number;
  69816. readonly TEXTURE_COMPARE_MODE: number;
  69817. readonly COMPARE_REF_TO_TEXTURE: number;
  69818. readonly TEXTURE_WRAP_R: number;
  69819. readonly HALF_FLOAT: number;
  69820. readonly RGB8: number;
  69821. readonly RED_INTEGER: number;
  69822. readonly RG_INTEGER: number;
  69823. readonly RGB_INTEGER: number;
  69824. readonly RGBA_INTEGER: number;
  69825. readonly R8_SNORM: number;
  69826. readonly RG8_SNORM: number;
  69827. readonly RGB8_SNORM: number;
  69828. readonly RGBA8_SNORM: number;
  69829. readonly R8I: number;
  69830. readonly RG8I: number;
  69831. readonly RGB8I: number;
  69832. readonly RGBA8I: number;
  69833. readonly R8UI: number;
  69834. readonly RG8UI: number;
  69835. readonly RGB8UI: number;
  69836. readonly RGBA8UI: number;
  69837. readonly R16I: number;
  69838. readonly RG16I: number;
  69839. readonly RGB16I: number;
  69840. readonly RGBA16I: number;
  69841. readonly R16UI: number;
  69842. readonly RG16UI: number;
  69843. readonly RGB16UI: number;
  69844. readonly RGBA16UI: number;
  69845. readonly R32I: number;
  69846. readonly RG32I: number;
  69847. readonly RGB32I: number;
  69848. readonly RGBA32I: number;
  69849. readonly R32UI: number;
  69850. readonly RG32UI: number;
  69851. readonly RGB32UI: number;
  69852. readonly RGBA32UI: number;
  69853. readonly RGB10_A2UI: number;
  69854. readonly R11F_G11F_B10F: number;
  69855. readonly RGB9_E5: number;
  69856. readonly RGB10_A2: number;
  69857. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69858. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69859. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69860. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69861. readonly DEPTH_COMPONENT32F: number;
  69862. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69863. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69864. 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;
  69865. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69866. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69867. readonly TRANSFORM_FEEDBACK: number;
  69868. readonly INTERLEAVED_ATTRIBS: number;
  69869. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69870. createTransformFeedback(): WebGLTransformFeedback;
  69871. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69872. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69873. beginTransformFeedback(primitiveMode: number): void;
  69874. endTransformFeedback(): void;
  69875. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69876. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69877. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69878. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69879. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69880. }
  69881. interface ImageBitmap {
  69882. readonly width: number;
  69883. readonly height: number;
  69884. close(): void;
  69885. }
  69886. interface WebGLQuery extends WebGLObject {
  69887. }
  69888. declare var WebGLQuery: {
  69889. prototype: WebGLQuery;
  69890. new(): WebGLQuery;
  69891. };
  69892. interface WebGLSampler extends WebGLObject {
  69893. }
  69894. declare var WebGLSampler: {
  69895. prototype: WebGLSampler;
  69896. new(): WebGLSampler;
  69897. };
  69898. interface WebGLSync extends WebGLObject {
  69899. }
  69900. declare var WebGLSync: {
  69901. prototype: WebGLSync;
  69902. new(): WebGLSync;
  69903. };
  69904. interface WebGLTransformFeedback extends WebGLObject {
  69905. }
  69906. declare var WebGLTransformFeedback: {
  69907. prototype: WebGLTransformFeedback;
  69908. new(): WebGLTransformFeedback;
  69909. };
  69910. interface WebGLVertexArrayObject extends WebGLObject {
  69911. }
  69912. declare var WebGLVertexArrayObject: {
  69913. prototype: WebGLVertexArrayObject;
  69914. new(): WebGLVertexArrayObject;
  69915. };
  69916. // Type definitions for WebVR API
  69917. // Project: https://w3c.github.io/webvr/
  69918. // Definitions by: six a <https://github.com/lostfictions>
  69919. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69920. interface VRDisplay extends EventTarget {
  69921. /**
  69922. * Dictionary of capabilities describing the VRDisplay.
  69923. */
  69924. readonly capabilities: VRDisplayCapabilities;
  69925. /**
  69926. * z-depth defining the far plane of the eye view frustum
  69927. * enables mapping of values in the render target depth
  69928. * attachment to scene coordinates. Initially set to 10000.0.
  69929. */
  69930. depthFar: number;
  69931. /**
  69932. * z-depth defining the near plane of the eye view frustum
  69933. * enables mapping of values in the render target depth
  69934. * attachment to scene coordinates. Initially set to 0.01.
  69935. */
  69936. depthNear: number;
  69937. /**
  69938. * An identifier for this distinct VRDisplay. Used as an
  69939. * association point in the Gamepad API.
  69940. */
  69941. readonly displayId: number;
  69942. /**
  69943. * A display name, a user-readable name identifying it.
  69944. */
  69945. readonly displayName: string;
  69946. readonly isConnected: boolean;
  69947. readonly isPresenting: boolean;
  69948. /**
  69949. * If this VRDisplay supports room-scale experiences, the optional
  69950. * stage attribute contains details on the room-scale parameters.
  69951. */
  69952. readonly stageParameters: VRStageParameters | null;
  69953. /**
  69954. * Passing the value returned by `requestAnimationFrame` to
  69955. * `cancelAnimationFrame` will unregister the callback.
  69956. * @param handle Define the hanle of the request to cancel
  69957. */
  69958. cancelAnimationFrame(handle: number): void;
  69959. /**
  69960. * Stops presenting to the VRDisplay.
  69961. * @returns a promise to know when it stopped
  69962. */
  69963. exitPresent(): Promise<void>;
  69964. /**
  69965. * Return the current VREyeParameters for the given eye.
  69966. * @param whichEye Define the eye we want the parameter for
  69967. * @returns the eye parameters
  69968. */
  69969. getEyeParameters(whichEye: string): VREyeParameters;
  69970. /**
  69971. * Populates the passed VRFrameData with the information required to render
  69972. * the current frame.
  69973. * @param frameData Define the data structure to populate
  69974. * @returns true if ok otherwise false
  69975. */
  69976. getFrameData(frameData: VRFrameData): boolean;
  69977. /**
  69978. * Get the layers currently being presented.
  69979. * @returns the list of VR layers
  69980. */
  69981. getLayers(): VRLayer[];
  69982. /**
  69983. * Return a VRPose containing the future predicted pose of the VRDisplay
  69984. * when the current frame will be presented. The value returned will not
  69985. * change until JavaScript has returned control to the browser.
  69986. *
  69987. * The VRPose will contain the position, orientation, velocity,
  69988. * and acceleration of each of these properties.
  69989. * @returns the pose object
  69990. */
  69991. getPose(): VRPose;
  69992. /**
  69993. * Return the current instantaneous pose of the VRDisplay, with no
  69994. * prediction applied.
  69995. * @returns the current instantaneous pose
  69996. */
  69997. getImmediatePose(): VRPose;
  69998. /**
  69999. * The callback passed to `requestAnimationFrame` will be called
  70000. * any time a new frame should be rendered. When the VRDisplay is
  70001. * presenting the callback will be called at the native refresh
  70002. * rate of the HMD. When not presenting this function acts
  70003. * identically to how window.requestAnimationFrame acts. Content should
  70004. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70005. * asynchronously from other displays and at differing refresh rates.
  70006. * @param callback Define the eaction to run next frame
  70007. * @returns the request handle it
  70008. */
  70009. requestAnimationFrame(callback: FrameRequestCallback): number;
  70010. /**
  70011. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70012. * Repeat calls while already presenting will update the VRLayers being displayed.
  70013. * @param layers Define the list of layer to present
  70014. * @returns a promise to know when the request has been fulfilled
  70015. */
  70016. requestPresent(layers: VRLayer[]): Promise<void>;
  70017. /**
  70018. * Reset the pose for this display, treating its current position and
  70019. * orientation as the "origin/zero" values. VRPose.position,
  70020. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70021. * updated when calling resetPose(). This should be called in only
  70022. * sitting-space experiences.
  70023. */
  70024. resetPose(): void;
  70025. /**
  70026. * The VRLayer provided to the VRDisplay will be captured and presented
  70027. * in the HMD. Calling this function has the same effect on the source
  70028. * canvas as any other operation that uses its source image, and canvases
  70029. * created without preserveDrawingBuffer set to true will be cleared.
  70030. * @param pose Define the pose to submit
  70031. */
  70032. submitFrame(pose?: VRPose): void;
  70033. }
  70034. declare var VRDisplay: {
  70035. prototype: VRDisplay;
  70036. new(): VRDisplay;
  70037. };
  70038. interface VRLayer {
  70039. leftBounds?: number[] | Float32Array | null;
  70040. rightBounds?: number[] | Float32Array | null;
  70041. source?: HTMLCanvasElement | null;
  70042. }
  70043. interface VRDisplayCapabilities {
  70044. readonly canPresent: boolean;
  70045. readonly hasExternalDisplay: boolean;
  70046. readonly hasOrientation: boolean;
  70047. readonly hasPosition: boolean;
  70048. readonly maxLayers: number;
  70049. }
  70050. interface VREyeParameters {
  70051. /** @deprecated */
  70052. readonly fieldOfView: VRFieldOfView;
  70053. readonly offset: Float32Array;
  70054. readonly renderHeight: number;
  70055. readonly renderWidth: number;
  70056. }
  70057. interface VRFieldOfView {
  70058. readonly downDegrees: number;
  70059. readonly leftDegrees: number;
  70060. readonly rightDegrees: number;
  70061. readonly upDegrees: number;
  70062. }
  70063. interface VRFrameData {
  70064. readonly leftProjectionMatrix: Float32Array;
  70065. readonly leftViewMatrix: Float32Array;
  70066. readonly pose: VRPose;
  70067. readonly rightProjectionMatrix: Float32Array;
  70068. readonly rightViewMatrix: Float32Array;
  70069. readonly timestamp: number;
  70070. }
  70071. interface VRPose {
  70072. readonly angularAcceleration: Float32Array | null;
  70073. readonly angularVelocity: Float32Array | null;
  70074. readonly linearAcceleration: Float32Array | null;
  70075. readonly linearVelocity: Float32Array | null;
  70076. readonly orientation: Float32Array | null;
  70077. readonly position: Float32Array | null;
  70078. readonly timestamp: number;
  70079. }
  70080. interface VRStageParameters {
  70081. sittingToStandingTransform?: Float32Array;
  70082. sizeX?: number;
  70083. sizeY?: number;
  70084. }
  70085. interface Navigator {
  70086. getVRDisplays(): Promise<VRDisplay[]>;
  70087. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70088. }
  70089. interface Window {
  70090. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70091. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70092. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70093. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70094. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70095. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70096. }
  70097. interface Gamepad {
  70098. readonly displayId: number;
  70099. }
  70100. type XRSessionMode =
  70101. | "inline"
  70102. | "immersive-vr"
  70103. | "immersive-ar";
  70104. type XRReferenceSpaceType =
  70105. | "viewer"
  70106. | "local"
  70107. | "local-floor"
  70108. | "bounded-floor"
  70109. | "unbounded";
  70110. type XREnvironmentBlendMode =
  70111. | "opaque"
  70112. | "additive"
  70113. | "alpha-blend";
  70114. type XRVisibilityState =
  70115. | "visible"
  70116. | "visible-blurred"
  70117. | "hidden";
  70118. type XRHandedness =
  70119. | "none"
  70120. | "left"
  70121. | "right";
  70122. type XRTargetRayMode =
  70123. | "gaze"
  70124. | "tracked-pointer"
  70125. | "screen";
  70126. type XREye =
  70127. | "none"
  70128. | "left"
  70129. | "right";
  70130. interface XRSpace extends EventTarget {
  70131. }
  70132. interface XRRenderState {
  70133. depthNear?: number;
  70134. depthFar?: number;
  70135. inlineVerticalFieldOfView?: number;
  70136. baseLayer?: XRWebGLLayer;
  70137. }
  70138. interface XRInputSource {
  70139. handedness: XRHandedness;
  70140. targetRayMode: XRTargetRayMode;
  70141. targetRaySpace: XRSpace;
  70142. gripSpace: XRSpace | undefined;
  70143. gamepad: Gamepad | undefined;
  70144. profiles: Array<string>;
  70145. }
  70146. interface XRSessionInit {
  70147. optionalFeatures?: XRReferenceSpaceType[];
  70148. requiredFeatures?: XRReferenceSpaceType[];
  70149. }
  70150. interface XRSession extends XRAnchorCreator {
  70151. addEventListener: Function;
  70152. removeEventListener: Function;
  70153. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70154. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70155. requestAnimationFrame: Function;
  70156. end(): Promise<void>;
  70157. renderState: XRRenderState;
  70158. inputSources: Array<XRInputSource>;
  70159. // AR hit test
  70160. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70161. updateWorldTrackingState(options: {
  70162. planeDetectionState?: { enabled: boolean; }
  70163. }): void;
  70164. }
  70165. interface XRReferenceSpace extends XRSpace {
  70166. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70167. onreset: any;
  70168. }
  70169. type XRPlaneSet = Set<XRPlane>;
  70170. type XRAnchorSet = Set<XRAnchor>;
  70171. interface XRFrame {
  70172. session: XRSession;
  70173. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70174. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70175. // Anchors
  70176. trackedAnchors?: XRAnchorSet;
  70177. // Planes
  70178. worldInformation: {
  70179. detectedPlanes?: XRPlaneSet;
  70180. };
  70181. }
  70182. interface XRViewerPose extends XRPose {
  70183. views: Array<XRView>;
  70184. }
  70185. interface XRPose {
  70186. transform: XRRigidTransform;
  70187. emulatedPosition: boolean;
  70188. }
  70189. interface XRWebGLLayerOptions {
  70190. antialias?: boolean;
  70191. depth?: boolean;
  70192. stencil?: boolean;
  70193. alpha?: boolean;
  70194. multiview?: boolean;
  70195. framebufferScaleFactor?: number;
  70196. }
  70197. declare var XRWebGLLayer: {
  70198. prototype: XRWebGLLayer;
  70199. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70200. };
  70201. interface XRWebGLLayer {
  70202. framebuffer: WebGLFramebuffer;
  70203. framebufferWidth: number;
  70204. framebufferHeight: number;
  70205. getViewport: Function;
  70206. }
  70207. declare class XRRigidTransform {
  70208. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70209. position: DOMPointReadOnly;
  70210. orientation: DOMPointReadOnly;
  70211. matrix: Float32Array;
  70212. inverse: XRRigidTransform;
  70213. }
  70214. interface XRView {
  70215. eye: XREye;
  70216. projectionMatrix: Float32Array;
  70217. transform: XRRigidTransform;
  70218. }
  70219. interface XRInputSourceChangeEvent {
  70220. session: XRSession;
  70221. removed: Array<XRInputSource>;
  70222. added: Array<XRInputSource>;
  70223. }
  70224. interface XRInputSourceEvent extends Event {
  70225. readonly frame: XRFrame;
  70226. readonly inputSource: XRInputSource;
  70227. }
  70228. // Experimental(er) features
  70229. declare class XRRay {
  70230. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70231. origin: DOMPointReadOnly;
  70232. direction: DOMPointReadOnly;
  70233. matrix: Float32Array;
  70234. }
  70235. interface XRHitResult {
  70236. hitMatrix: Float32Array;
  70237. }
  70238. interface XRAnchor {
  70239. // remove?
  70240. id?: string;
  70241. anchorSpace: XRSpace;
  70242. lastChangedTime: number;
  70243. detach(): void;
  70244. }
  70245. interface XRPlane extends XRAnchorCreator {
  70246. orientation: "Horizontal" | "Vertical";
  70247. planeSpace: XRSpace;
  70248. polygon: Array<DOMPointReadOnly>;
  70249. lastChangedTime: number;
  70250. }
  70251. interface XRAnchorCreator {
  70252. // AR Anchors
  70253. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70254. }